:root {
  --sky-top: #9fe7ff;
  --sky-mid: #e0f7ff;
  --sky-bottom: #fff5d7;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-border: rgba(16, 68, 92, 0.12);
  --ink: #163244;
  --muted: #4d6977;
  --accent: #ff8b42;
  --accent-strong: #ea5f1b;
  --success: #2b9f64;
  --danger: #c94a4a;
  --shadow: 0 20px 50px rgba(22, 50, 68, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 28%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 48%, var(--sky-bottom) 100%);
}

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

body::before {
  top: 4rem;
  left: -5rem;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  filter: blur(20px);
}

body::after {
  right: -3rem;
  bottom: 8rem;
  width: 12rem;
  height: 12rem;
  border-radius: 36% 64% 57% 43%;
  background: rgba(255, 159, 67, 0.18);
  filter: blur(12px);
}

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 60ch;
  margin: 12px 0 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #24627f;
}

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
}

.game-toolbar span,
.difficulty-control,
.burst-readout,
.repeat-pill,
button,
kbd {
  border-radius: 999px;
}

.game-toolbar span,
.difficulty-control,
.burst-readout {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(16, 68, 92, 0.1);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
}

.difficulty-control {
  display: grid;
  grid-template-columns: auto minmax(110px, 150px);
  align-items: center;
  gap: 12px;
}

.difficulty-control span {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  white-space: nowrap;
}

.difficulty-control input {
  width: 100%;
  accent-color: #ffd64d;
  cursor: pointer;
}

.burst-readout {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 10px;
}

.burst-readout span {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  white-space: nowrap;
}

.burst-readout strong {
  min-width: 2.4ch;
  color: #163244;
  font-size: 1.15rem;
  line-height: 1;
  text-align: right;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.game-panel,
.info-panel {
  min-width: 0;
}

.canvas-frame,
.card,
.stat-card {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.canvas-frame {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  background: linear-gradient(180deg, #93e8ff 0%, #ebfbff 68%, #f8df9d 100%);
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(19, 46, 62, 0.18);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  max-width: 460px;
  padding: 28px;
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(10, 25, 35, 0.18);
  max-height: 100%;
  overflow: auto;
}

.overlay-card h2 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4.5vw, 3rem);
  letter-spacing: -0.05em;
}

.overlay-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.overlay-tip {
  margin-top: 14px !important;
  font-size: 0.92rem;
}

button {
  margin-top: 20px;
  padding: 14px 24px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(234, 95, 27, 0.24);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(234, 95, 27, 0.3);
}

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

kbd {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background: rgba(22, 50, 68, 0.08);
  border: 1px solid rgba(22, 50, 68, 0.12);
  color: var(--ink);
  font-size: 0.9rem;
}

.info-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
}

.card,
.stat-card {
  border-radius: 24px;
}

.card {
  padding: 20px;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.word-display {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.06em;
}

.repeat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.2rem;
  padding: 0.6rem 0.9rem;
  background: rgba(43, 159, 100, 0.12);
  color: var(--success);
  font-weight: 800;
}

.repeat-track {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.repeat-chip {
  flex: 1;
  min-height: 0.85rem;
  border-radius: 999px;
  background: rgba(22, 50, 68, 0.1);
  overflow: hidden;
}

.repeat-chip::after {
  content: "";
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffb15c, #ff7d30);
  transition: width 120ms linear;
}

.repeat-chip.is-complete::after {
  width: 100%;
  background: linear-gradient(90deg, #4dcf86, #2b9f64);
}

.repeat-chip.is-active::after {
  width: var(--fill, 0%);
}

.card-note {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.next-letter {
  font-size: clamp(3rem, 8vw, 4.5rem);
  line-height: 1;
  font-weight: 800;
  color: var(--accent-strong);
  letter-spacing: -0.08em;
}

.typed-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 3rem;
  margin-top: 16px;
}

.typed-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2.2rem;
  padding: 0 0.6rem;
  border-radius: 14px;
  background: rgba(22, 50, 68, 0.08);
  color: var(--muted);
  font-weight: 700;
}

.typed-letter.is-hit {
  background: rgba(43, 159, 100, 0.14);
  color: var(--success);
}

.typed-letter.is-miss {
  background: rgba(201, 74, 74, 0.14);
  color: var(--danger);
  outline: 2px solid rgba(201, 74, 74, 0.24);
}

.typed-letter.is-next {
  background: rgba(255, 214, 77, 0.32);
  color: #6f5200;
  outline: 2px solid rgba(218, 170, 0, 0.34);
}

.typed-letter.is-gap {
  min-width: 0.8rem;
  background: transparent;
  padding: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 18px;
}

.stat-label {
  display: block;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #34657e;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.controls-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 1100px) {
  .hero {
    align-items: start;
    flex-direction: column;
  }

  .info-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 14px 28px;
  }

  canvas {
    aspect-ratio: 4 / 3;
  }

  .canvas-frame {
    padding: 8px;
    border-radius: 20px;
  }

  .overlay {
    inset: 8px;
    padding: 16px;
  }

  .overlay-card,
  .card,
  .stat-card {
    border-radius: 20px;
  }

  .overlay-card {
    padding: 18px;
  }

  .overlay-card h2 {
    margin-bottom: 8px;
    font-size: clamp(1.6rem, 8vw, 2.25rem);
  }

  button {
    margin-top: 14px;
    padding: 12px 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .info-panel {
    grid-template-columns: 1fr;
  }
}
