* { box-sizing: border-box; }

body {
  font-family: 'Noto Sans Kannada', 'Tunga', sans-serif;
  background-color: #121213;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><text x="10" y="40" font-family="sans-serif" font-size="28" fill="%23ffffff" opacity="0.035">ಕ</text><text x="65" y="95" font-family="sans-serif" font-size="28" fill="%23ffffff" opacity="0.035">ಡ</text></svg>');
  background-repeat: repeat;
  color: #fff;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-bottom: 1px solid #3a3a3c;
  width: 100%;
  max-width: 500px;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.logo {
  flex-shrink: 0;
  border-radius: 6px;
}

h1 {
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 1px;
}

.score {
  font-size: 0.95rem;
  font-weight: bold;
  color: #b59f3b;
  margin-left: auto;
}

#help-btn {
  background: #3a3a3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

#help-btn:hover {
  background: #565758;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.help-box {
  position: relative;
  background: #1f1f21;
  border: 1px solid #3a3a3c;
  border-radius: 8px;
  max-width: 460px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  line-height: 1.6;
}

.help-box h2 {
  margin-top: 0;
}

.help-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.help-legend {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.help-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
}

.swatch.correct { background: #538d4e; }
.swatch.present { background: #b59f3b; }
.swatch.absent { background: #3a3a3c; }

#new-game {
  background: #538d4e;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}

#new-game:hover {
  background: #6aaa64;
}

.message {
  min-height: 1.4em;
  font-size: 1.1rem;
  margin-bottom: 10px;
  text-align: center;
}

.hints-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.hint-btn {
  background: #3a3a3c;
  color: #fff;
  border: 1px solid #565758;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.hint-btn:hover {
  background: #565758;
}

.grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.row {
  display: grid;
  gap: 6px;
  grid-auto-flow: column;
  position: relative;
}

/* Animated arrow marking the row that's currently in play. */
.row.active::before {
  content: "▸";
  position: absolute;
  left: -26px;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  color: #6aaa64;
  font-size: 1.5rem;
  animation: arrow-nudge 0.9s ease-in-out infinite;
}

@keyframes arrow-nudge {
  0%, 100% { transform: translateX(-3px); opacity: 0.45; }
  50% { transform: translateX(3px); opacity: 1; }
}

.tile {
  width: 52px;
  height: 52px;
  border: 2px solid #3a3a3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
  text-transform: none;
  background: #121213;
}

.tile.filled {
  border-color: #565758;
}

.tile.correct {
  background: #538d4e;
  border-color: #538d4e;
}

.tile.present {
  background: #b59f3b;
  border-color: #b59f3b;
}

.tile.absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 600px;
  width: 100%;
}

.kbd-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.key {
  background: #818384;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px 0;
  min-width: 34px;
  font-size: 1.1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.key:hover {
  background: #9a9b9c;
}

.key.wide {
  min-width: 60px;
  font-size: 0.85rem;
  padding: 10px 8px;
}

.key.submit {
  background: #3b7ddd;
  color: #fff;
  font-weight: bold;
}

.key.submit:hover { background: #5a95e6; }

.key.backspace { background: #565758; }

.key.backspace:hover { background: #6b6c6d; }

.key.correct { background: #538d4e; }
.key.present { background: #b59f3b; }
.key.absent { background: #3a3a3c; color: #888; }

/* Compact layout for phones so the grid and the ⌫ / ಸಲ್ಲಿಸಿ controls
   stay on screen together — otherwise the tall keyboard pushes the submit
   button below the fold and the game feels stuck after the first guess. */
@media (max-width: 480px) {
  body { padding: 10px; }

  header { gap: 8px; padding-bottom: 8px; margin-bottom: 8px; }
  h1 { font-size: 1.3rem; }

  .message { font-size: 1rem; margin-bottom: 6px; }
  .hints-row { margin-bottom: 8px; }
  .hint-btn { padding: 5px 10px; }

  .grid { gap: 4px; margin-bottom: 10px; }
  .row { gap: 4px; }
  .tile { width: 40px; height: 40px; font-size: 1.4rem; }

  .keyboard { gap: 4px; }
  .kbd-row { gap: 3px; }
  .key { min-width: 24px; padding: 8px 0; font-size: 0.95rem; }
  .key.wide { min-width: 52px; padding: 8px 6px; }
}
