* {
  box-sizing: border-box;
}

:root {
  --bg-deep: #04111f;
  --bg-mid: #0b2138;
  --bg-glow: #123b63;
  --panel: rgba(6, 20, 36, 0.82);
  --panel-strong: rgba(10, 27, 48, 0.94);
  --panel-border: rgba(148, 220, 255, 0.2);
  --text-main: #ecf7ff;
  --text-soft: rgba(236, 247, 255, 0.74);
  --accent: #88f6ff;
  --accent-strong: #45c8ff;
  --warning: #ff8f70;
  --success: #9effcf;
  --shadow-lg: 0 30px 80px rgba(2, 8, 18, 0.46);
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px 20px 40px;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(136, 246, 255, 0.15), transparent 18%),
    radial-gradient(circle at 80% 10%, rgba(142, 124, 255, 0.2), transparent 20%),
    radial-gradient(circle at 70% 70%, rgba(69, 200, 255, 0.12), transparent 18%),
    linear-gradient(180deg, #020914 0%, var(--bg-deep) 30%, var(--bg-mid) 100%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image:
    radial-gradient(circle at 12% 24%, rgba(255, 255, 255, 0.85) 0 1px, transparent 1.2px),
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.2px),
    radial-gradient(circle at 38% 82%, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.2px),
    radial-gradient(circle at 84% 62%, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.2px),
    radial-gradient(circle at 56% 40%, rgba(255, 255, 255, 0.6) 0 1px, transparent 1.2px);
  opacity: 0.45;
}

body::after {
  background:
    linear-gradient(90deg, transparent 0%, rgba(136, 246, 255, 0.06) 50%, transparent 100%);
  mix-blend-mode: screen;
  opacity: 0.35;
}

.app-shell {
  width: min(1240px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  margin-bottom: 20px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4.3vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f3fbff;
  text-shadow:
    0 0 18px rgba(136, 246, 255, 0.24),
    0 0 42px rgba(69, 200, 255, 0.16);
}

.subtitle {
  width: min(700px, 100%);
  margin: 12px auto 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-soft);
}

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

.display {
  display: grid;
  grid-template-columns: 92px 92px minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: min(92vw, 430px);
  padding: 8px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(13, 32, 58, 0.96), rgba(5, 18, 34, 0.96));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.panel-kicker,
.modal-eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.68rem;
  font-weight: 700;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 7px 9px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.display input {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
}

.display input:read-only {
  cursor: default;
}

.level-card {
  padding: 8px 10px;
  min-height: 58px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}

.level-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.level-meta strong {
  color: var(--text-main);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.level-progress {
  position: relative;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(136, 246, 255, 0.08);
}

.level-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 12px rgba(69, 200, 255, 0.28);
  transition: width 0.22s ease;
}

.level-target {
  grid-column: 2 / 3;
  margin-top: -2px;
  color: var(--text-soft);
  font-size: 0.64rem;
  text-align: right;
}

.board-frame {
  position: relative;
  padding: 18px;
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(6, 24, 44, 0.96), rgba(3, 14, 28, 0.98));
  border: 1px solid rgba(136, 246, 255, 0.16);
  box-shadow:
    var(--shadow-lg),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.board-glow {
  position: absolute;
  inset: 14px;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(136, 246, 255, 0.18), transparent 36%),
    radial-gradient(circle at bottom, rgba(99, 104, 255, 0.18), transparent 38%);
  pointer-events: none;
}

canvas {
  position: relative;
  display: block;
  width: min(90vw, 520px);
  height: auto;
  border-radius: 20px;
  border: 2px solid rgba(136, 246, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(234, 246, 255, 0.98), rgba(205, 230, 250, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    inset 0 -16px 26px rgba(19, 49, 81, 0.08);
  image-rendering: pixelated;
  touch-action: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 9, 20, 0.72);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(92vw, 560px);
  padding: 28px 28px 24px;
  border: 1px solid rgba(136, 246, 255, 0.2);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(10, 28, 51, 0.98), rgba(4, 16, 32, 0.98));
  box-shadow: var(--shadow-lg);
}

.modal-title {
  margin: 10px 0 12px;
  font-size: 1.7rem;
  line-height: 1.2;
  color: var(--text-main);
}

.modal-score {
  margin-bottom: 24px;
  font-size: 1.1rem;
  color: var(--text-soft);
}

.modal-score span {
  font-weight: 800;
  color: var(--accent);
}

.modal-button {
  width: 100%;
  padding: 13px 0;
  border: none;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #06233b;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.modal-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(69, 200, 255, 0.25);
}

.question-modal {
  width: min(94vw, 680px);
}

.question-meta {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.4;
}

.question-title {
  margin-bottom: 10px;
}

.question-prompt {
  margin: 0 0 18px;
  color: var(--text-main);
  font-size: 1.08rem;
  line-height: 1.6;
}

.question-options {
  display: grid;
  gap: 10px;
}

.builder-sentence,
.builder-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.builder-placeholder {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.builder-chip {
  padding: 9px 12px;
  border: 1px solid rgba(136, 246, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.builder-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(136, 246, 255, 0.34);
}

.builder-chip.is-placed {
  background: rgba(136, 246, 255, 0.14);
  border-color: rgba(136, 246, 255, 0.26);
}

.builder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.builder-confirm {
  width: auto;
  min-width: 140px;
}

.builder-reset {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
}

.question-option {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(136, 246, 255, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  color: var(--text-main);
  font-size: 0.98rem;
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.question-option:hover {
  transform: translateY(-1px);
  border-color: rgba(136, 246, 255, 0.34);
}

.question-option:disabled {
  cursor: default;
}

.question-option.is-correct {
  border-color: rgba(158, 255, 207, 0.45);
  background: rgba(158, 255, 207, 0.12);
}

.question-option.is-wrong {
  border-color: rgba(255, 143, 112, 0.45);
  background: rgba(255, 143, 112, 0.12);
}

.question-feedback {
  min-height: 24px;
  margin-top: 14px;
  font-size: 0.96rem;
  color: var(--text-soft);
}

.question-feedback.is-correct {
  color: var(--success);
}

.question-feedback.is-wrong {
  color: var(--warning);
}

@media (max-width: 860px) {
  .display {
    grid-template-columns: 92px 92px minmax(180px, 1fr);
    width: min(100%, 430px);
  }
}

@media (max-width: 560px) {
  body {
    padding-inline: 12px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .display {
    grid-template-columns: 24% 24% 1fr;
    width: 96vw;
    padding: 6px;
    gap: 4px;
  }

  .stat-card {
    min-height: 44px;
    padding: 4px;
    font-size: 0.5rem;
  }

  .display input {
    font-size: 0.75rem;
  }

  .level-card {
    grid-template-columns: auto 1fr;
    min-height: 44px;
    padding: 4px 6px;
    gap: 4px 6px;
  }

  .level-meta {
    font-size: 0.5rem;
  }

  .level-meta strong {
    font-size: 0.7rem;
  }

  .level-target {
    font-size: 0.55rem;
  }

  .board-frame {
    padding: 4px;
    border-radius: 12px;
  }

  .board-glow {
    inset: 4px;
    border-radius: 10px;
  }

  canvas {
    width: 96vw;
    height: auto;
    max-width: 520px;
    border-radius: 10px;
  }

  .modal {
    padding: 22px 18px 18px;
  }
}
