:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2ff;
  --ink: #151827;
  --muted: #68708a;
  --line: #dfe5f2;
  --blue: #3763ff;
  --blue-2: #2448d8;
  --coral: #ff6b6b;
  --mint: #17c3a5;
  --yellow: #ffd166;
  --purple: #8b5cf6;
  --shadow: 0 10px 28px rgba(28, 35, 69, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #ecf5ff 0%, var(--bg) 38%, #fff7ec 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.app {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  gap: 14px;
}

.topbar,
.section-head,
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 76px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-weight: 900;
  font-size: 0.78rem;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.05rem, 10vw, 3.3rem);
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

.status,
.round-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 900;
}

.status {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel,
.arena {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.user-list,
.players,
.invites {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.choice,
.player,
.invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
}

.choice strong,
.player strong,
.invite strong {
  font-size: 1.08rem;
}

.choice span,
.player div div {
  color: var(--muted);
  font-weight: 800;
}

.choice.active {
  border-color: var(--blue);
  background: #eef2ff;
  box-shadow: inset 0 0 0 1px rgba(55, 99, 255, 0.24);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 60px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f1f5ff;
  color: var(--ink);
  outline: none;
  font-weight: 900;
  font-size: 1.12rem;
}

input:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(55, 99, 255, 0.13);
}

.primary,
.ghost {
  min-height: 60px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 950;
}

.primary {
  width: 100%;
  margin-top: 14px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 18px rgba(55, 99, 255, 0.22);
}

.primary:active,
.ghost:active,
.choice:active {
  transform: scale(0.985);
}

.ghost {
  width: auto;
  background: #eef2ff;
  color: var(--blue-2);
  border: 1px solid #d7defe;
}

.error {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--coral);
  font-weight: 900;
}

.game {
  display: grid;
  gap: 14px;
}

.scoreboard {
  position: sticky;
  top: 8px;
  z-index: 2;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.score {
  min-width: 92px;
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  background: #f7f9ff;
}

.score:last-child {
  text-align: left;
}

.score span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.score strong {
  font-size: 2.3rem;
  line-height: 1;
  color: var(--blue);
}

.round-pill {
  display: grid;
  place-items: center;
  min-width: 78px;
  min-height: 50px;
  background: #fff7df;
  color: #9a6410;
  border-color: #ffe4a3;
}

.arena {
  min-height: calc(100vh - 208px);
  display: grid;
  align-content: center;
  gap: 18px;
}

.game-message {
  display: grid;
  place-items: center;
  min-height: 76px;
  margin: 0;
  font-size: clamp(1.42rem, 6.8vw, 2.18rem);
  line-height: 1.18;
  font-weight: 950;
  text-align: center;
  text-wrap: balance;
}

.game-toast {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid #b8f0e4;
  border-radius: 8px;
  padding: 9px 10px 9px 14px;
  background: rgba(233, 251, 246, 0.96);
  color: #0f766e;
  box-shadow: 0 10px 24px rgba(28, 35, 69, 0.12);
  backdrop-filter: blur(14px);
  font-weight: 950;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.game-toast[data-visible="true"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.game-toast[data-tone="error"] {
  border-color: #ffc6c6;
  background: rgba(255, 241, 241, 0.97);
  color: #c24141;
}

.toast-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: inherit;
  font-size: 1.35rem;
  font-weight: 950;
  line-height: 1;
}

.letters {
  display: grid;
  grid-template-columns: 1fr 34px 1fr;
  gap: 10px;
  align-items: center;
}

.timer {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 7px solid #dfe7ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  background: var(--surface);
  color: var(--blue);
  font-size: 2.25rem;
  font-weight: 950;
  box-shadow: var(--shadow);
}

.timer.danger {
  border-color: #ffe0e0;
  border-top-color: var(--coral);
  color: var(--coral);
  animation: tick 0.55s ease infinite alternate;
}

.letter-chip {
  display: grid;
  place-items: center;
  min-height: 96px;
  border-radius: 8px;
  background: #fff2c2;
  color: #2a2530;
  border: 1px solid #ffe39b;
  font-size: 3.35rem;
  font-weight: 950;
}

.letter-chip:first-child {
  background: #dffaf4;
  border-color: #b6f0e4;
}

.letter-chip:last-child {
  background: #ffe4ef;
  border-color: #ffc1d8;
}

.arrow {
  color: var(--muted);
  font-weight: 950;
  text-align: center;
}

.letter-form,
.answer-form {
  display: grid;
  gap: 0;
}

.letter-form input {
  min-height: 76px;
  text-align: center;
  font-size: 2.6rem;
  background: #fff7df;
}

.answer-form input {
  min-height: 66px;
  text-align: center;
}

.notice {
  border-radius: 8px;
  padding: 14px;
  font-weight: 900;
  line-height: 1.4;
  text-align: center;
  background: #e9fbf6;
  color: #0f766e;
  border: 1px solid #b8f0e4;
}

.pulse {
  animation: pulse 0.35s ease both;
}

@keyframes pulse {
  0% {
    transform: scale(0.985);
    opacity: 0.78;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes tick {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.045);
  }
}

@media (max-width: 380px) {
  .app {
    padding-inline: 10px;
  }

  .score {
    min-width: 78px;
  }

  .score strong {
    font-size: 2rem;
  }

  .round-pill {
    min-width: 66px;
    padding-inline: 8px;
  }

  .letter-chip {
    min-height: 84px;
    font-size: 3rem;
  }
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .arena {
    min-height: 520px;
  }
}
