* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-dark: #0b1220;
  --text: #ffffff;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --danger: #ef4444;
  --board-bg: #000000;
  --board-line: rgba(255, 255, 255, 0.1);
  --tile-bg: #ffffff;
  --tile-border: #d6d6d6;
  --tile-text: #111827;
  --cell-size: 26px;
  --cell-gap: 2px;
  --board-cols: 22;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px 18px;
  -ms-touch-action: manipulation;
  touch-action: manipulation;
}

h1 {
  font-size: 24px;
  margin-bottom: 10px;
  text-align: center;
}

.game-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* BOARD */
.board-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background: transparent;
  display: flex;
  justify-content: center;
  padding-bottom: 6px;
}
  grid-template-columns: repeat(22, var(--cell-size));
  gap: 2px;
  flex-shrink: 0;
  padding: 14px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--cell-size) + var(--cell-gap) - 1px),
      var(--board-line) calc(var(--cell-size) + var(--cell-gap) - 1px),
      var(--board-line) calc(var(--cell-size) + var(--cell-gap))
    ),
    var(--board-bg);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255,255,255,0.04);
  grid-template-columns: repeat(var(--board-cols), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  gap: var(--cell-gap);
  width: var(--cell-size);
  height: var(--cell-size);
  background: #1e293b;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: calc(var(--cell-size) * 0.45);
  line-height: 1;
  flex-shrink: 0;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--cell-size) + var(--cell-gap) - 1px),
      var(--board-line) calc(var(--cell-size) + var(--cell-gap) - 1px),
      var(--board-line) calc(var(--cell-size) + var(--cell-gap))
    ),
    var(--board-bg);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255,255,255,0.04);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
}

.cell.playable {
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: 2px;
  color: var(--tile-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.cell.playable.active {
  box-shadow:
    inset 0 0 0 3px var(--blue),
    0 0 0 1px rgba(59, 130, 246, 0.15);
}

.cell.playable.filled {
  background: #ffffff;
}

.cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
  color: #111827;
  pointer-events: none;
}

.cell-letter {
  font-size: 15px;
  line-height: 1;
  transform: translateY(1px);
}

.animate {
  animation: popIn 0.23s ease-out;
}

@keyframes popIn {
  0% {
    transform: scale(0.35);
    opacity: 0;
  }
  80% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* QUESTIONS */
.questions-section {
  background: var(--panel);
  width: 100%;
  max-width: 560px;
  padding: 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.question-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.question-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  font-size: 13px;
  font-weight: 700;
}

.question-display h2 {
  font-size: 16px;
  line-height: 1.35;
  font-weight: 700;
}

.input-area {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

input {
  width: 100%;
  max-width: 280px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

input::placeholder {
  color: #64748b;
}

button {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease, transform 0.12s ease;
}

button:active {
  transform: translateY(1px);
}

#checkBtn {
  padding: 10px 16px;
  background: var(--accent);
  color: #0f172a;
  font-size: 14px;
}

#checkBtn:hover {
  background: var(--accent-dark);
}

.btn-previous-questions {
  align-self: center;
  padding: 10px 14px;
  background: var(--blue);
  color: white;
  font-size: 14px;
}

.btn-previous-questions:hover {
  background: var(--blue-dark);
}

#feedback {
  min-height: 20px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

#feedback.success {
  color: var(--accent);
}

#feedback.error {
  color: var(--danger);
}

/* PREVIOUS QUESTIONS */
.prev-questions-dropdown {
  display: none;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel-dark);
  border: 1px solid rgba(34,197,94,0.12);
  border-radius: 8px;
  padding: 8px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

.prev-questions-dropdown.open {
  display: block;
}

.prev-item {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
}

.prev-item:last-child {
  margin-bottom: 0;
}

.prev-item .question-text {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.prev-item .answer-text {
  color: #86efac;
  font-size: 13px;
}

/* TABLET / DESKTOP */
@media (min-width: 768px) {
  :root {
    --cell-size: 30px;
  }

  body {
    padding: 16px 14px 24px;
  }

  h1 {
    font-size: 28px;
    margin-bottom: 14px;
  }

  .game-container {
    gap: 18px;
  }

  .question-display h2 {
    font-size: 18px;
  }
}

@media (min-width: 1100px) {
  .game-container {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
  }

  .board-wrapper {
    width: auto;
    flex: 0 0 auto;
  }

  .questions-section {
    max-width: 420px;
    flex: 0 0 420px;
    margin-top: 6px;
  }
}