*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --gold: #ffd60a;
  --line: #d2d2d7;
  --done: #1d9e4a;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.top {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.4rem;
}

.brand {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

h1 {
  font-size: 1.7rem;
  letter-spacing: -0.05em;
  font-weight: 650;
}

.lede {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 40rem;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
}

.stage {
  position: relative;
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.06);
  min-height: 620px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1.2rem;
  padding: 0.75rem 1rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

.hud-block span {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-block strong {
  display: block;
  font-size: 1.28rem;
  font-weight: 650;
  letter-spacing: -0.04em;
}

.play {
  position: relative;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.4rem 1.2rem 1.2rem;
}

.kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.prompt {
  font-size: clamp(2.1rem, 7vw, 4.4rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.15;
  text-align: center;
  max-width: 16ch;
  word-break: break-word;
}

.prompt.sentence {
  font-size: clamp(1.35rem, 3.8vw, 2.15rem);
  max-width: 28ch;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.prompt.flash {
  animation: word-in 0.28s cubic-bezier(0.2, 1.3, 0.3, 1);
}

.prompt.pop {
  animation: word-pop 0.32s ease;
}

.coming {
  margin-top: 0.45rem;
  font-size: clamp(1.1rem, 3.4vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-align: center;
  max-width: 16ch;
  color: #1d1d1f;
  opacity: 0.32;
  min-height: 1.35em;
  pointer-events: none;
  user-select: none;
}

.prompt.sentence + .coming {
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  max-width: 28ch;
  font-weight: 550;
}

.glyph.done {
  color: var(--done);
}

.glyph.next {
  color: #ffffff;
  background: var(--text);
  border-radius: 8px;
  padding: 0 0.08em;
  box-shadow: 0 3px 0 #000;
}

.glyph.gap {
  display: inline-block;
  min-width: 0.42em;
  padding: 0 0.22em;
  margin: 0 0.04em;
}

.glyph.rest {
  color: #c7c7cc;
}

.echo {
  min-height: 1.25rem;
  margin-top: 0.45rem;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--accent);
}

.board {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  pointer-events: none;
}

.key-row {
  display: flex;
  gap: 0.28rem;
}

.key-row:nth-child(2) {
  padding-left: 0.95rem;
}

.key-row:nth-child(3) {
  padding-left: 2.05rem;
}

.key {
  min-width: 42px;
  height: 42px;
  padding: 0 0.28rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #f5f5f7;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 2px 0 #d2d2d7;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.key.home::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translateX(-50%);
  opacity: 0.35;
}

.key-space {
  min-width: 220px;
  height: 38px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--muted);
}

.key.lit {
  background: var(--gold);
  color: #1d1d1f;
  border-color: #e0b800;
  box-shadow: 0 0 0 3px rgba(255, 214, 10, 0.45), 0 6px 16px rgba(255, 214, 10, 0.35);
  transform: translateY(-1px);
}

.key.lit.key-space {
  color: #1d1d1f;
  animation: space-pulse 0.9s ease-in-out infinite;
}

@keyframes space-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(255, 214, 10, 0.45), 0 6px 16px rgba(255, 214, 10, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 214, 10, 0.28), 0 8px 22px rgba(255, 214, 10, 0.5);
  }
}

.key.hit {
  animation: key-hit 0.22s ease;
}

@keyframes key-hit {
  0% {
    transform: translateY(1px) scale(0.96);
  }
  100% {
    transform: translateY(-1px) scale(1);
  }
}

.type-catch {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: 0;
  caret-color: transparent;
  font-size: 16px;
}

.hint {
  padding: 0.55rem 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
  border-top: 1px solid var(--line);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.72);
}

.overlay.hidden,
.hidden {
  display: none !important;
}

.overlay-card {
  width: min(100%, 440px);
  max-height: calc(100% - 0.4rem);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.05rem 1.15rem 1.2rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

.ready-card {
  text-align: center;
}

.ready-count {
  font-size: 5.2rem;
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 1;
  margin: 0.35rem 0 0.45rem;
}

.score-brand {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.overlay h2 {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  margin: 0.12rem 0 0.35rem;
}

.overlay-copy {
  color: var(--muted);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}

.modes {
  display: grid;
  gap: 0.55rem;
}

.mode-btn {
  text-align: left;
  border: none;
  border-radius: 16px;
  padding: 0.75rem 0.85rem;
  background: #f2f2f7;
  color: var(--text);
  cursor: pointer;
}

.mode-btn strong {
  display: block;
  font-size: 1.05rem;
}

.mode-btn span {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.mode-btn.gold {
  background: var(--gold);
}

.mode-btn.gold span {
  color: #5c4a00;
}

.mode-btn:hover {
  filter: brightness(0.98);
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.end-stats div {
  background: #f5f5f7;
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
}

.end-stats span {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.end-stats strong {
  font-size: 1.25rem;
}

.board-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 160px;
  overflow: auto;
  margin: 0 0 0.7rem;
}

.board-empty,
.board-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.42rem 0.6rem;
  border-radius: 12px;
  background: #f5f5f7;
  font-size: 0.88rem;
}

.board-name {
  font-weight: 650;
}

.board-score {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.board-empty {
  grid-template-columns: 1fr;
  color: var(--muted);
}

.board-row.mine {
  background: #fff6c2;
}

.board-form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.board-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem 0.75rem;
  font: inherit;
}

.board-status {
  min-height: 1.15em;
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.btn-play,
.btn-ghost {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.62rem 0.8rem;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.btn-play {
  background: var(--gold);
  color: #1d1d1f;
  box-shadow: 0 4px 0 #b89600;
  margin-bottom: 0.45rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.hud .btn-ghost {
  width: auto;
  margin-left: auto;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

@keyframes word-in {
  from {
    opacity: 0.2;
    transform: scale(0.86) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes word-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  .hud-block strong {
    font-size: 1.05rem;
  }

  .play {
    min-height: 360px;
  }

  .key {
    min-width: 28px;
    height: 32px;
    font-size: 0.72rem;
    border-radius: 7px;
  }

  .key-space {
    min-width: 150px;
    height: 30px;
  }

  .key-row {
    gap: 0.18rem;
  }

  .key-row:nth-child(2) {
    padding-left: 0.55rem;
  }

  .key-row:nth-child(3) {
    padding-left: 1.2rem;
  }
}
