@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700;800&family=Sora:wght@500;700;800&display=swap');

:root {
  --bg0: #102548;
  --bg1: #1a3f72;
  --bg2: #245590;
  --panel: rgba(16, 42, 78, 0.82);
  --panel-strong: rgba(18, 47, 88, 0.92);
  --border: rgba(168, 210, 255, 0.34);
  --border-strong: rgba(194, 225, 255, 0.58);
  --text: #ebf4ff;
  --muted: #a8c1e7;
  --accent: #ffd37a;
  --accent-cool: #6fe0ff;
  --good: #45df9e;
  --bad: #ff6d73;
  --shadow: 0 16px 32px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(980px 620px at 8% -14%, rgba(111, 224, 255, 0.22), transparent 64%),
    radial-gradient(920px 560px at 100% -18%, rgba(255, 211, 122, 0.18), transparent 62%),
    linear-gradient(158deg, var(--bg2), var(--bg1) 48%, var(--bg0));
  background-attachment: fixed;
}

body.phone-turn-waiting {
  background:
    radial-gradient(950px 600px at 8% -14%, rgba(111, 224, 255, 0.14), transparent 64%),
    radial-gradient(860px 540px at 100% -18%, rgba(143, 173, 255, 0.14), transparent 62%),
    linear-gradient(158deg, #14365f, #0f2a4f 48%, #08142b);
}

body.phone-turn-active {
  background:
    radial-gradient(1020px 640px at 8% -14%, rgba(111, 224, 255, 0.2), transparent 64%),
    radial-gradient(940px 560px at 100% -18%, rgba(255, 211, 122, 0.2), transparent 62%),
    linear-gradient(158deg, #154a70, #12395f 48%, #0a223f);
}

body.phone-turn-active .panel {
  border-color: rgba(255, 211, 122, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 211, 122, 0.2), var(--shadow);
}

body.phone-turn-active #submitGuessBtn {
  background: linear-gradient(165deg, #2f92d9, #1f68ab 72%);
}

.app {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(4px);
}

.header h1 {
  margin: 0 0 6px;
}

.hint {
  color: var(--muted);
  margin: 0;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid rgba(132, 183, 255, 0.5);
  border-radius: 12px;
  color: #f4f9ff;
  background: linear-gradient(165deg, #2d80ff, #1b58b4 72%);
  padding: 9px 12px;
  cursor: pointer;
  font-family: 'Sora', 'Space Grotesk', sans-serif;
  font-weight: 700;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.24);
}

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

#status {
  min-height: 1.2rem;
  padding: 2px 2px 0;
}

.control-field {
  display: grid;
  gap: 4px;
  min-width: 110px;
}

.control-field span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.round-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.round-top h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.7vw + 0.8rem, 2rem);
}

.round-state-bar {
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.round-state-bar > div {
  border: 1px solid rgba(146, 196, 255, 0.48);
  border-radius: 10px;
  background: rgba(20, 52, 95, 0.82);
  padding: 8px 10px;
  font-weight: 700;
}

.guess-row {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#guessInput {
  border: 1px solid rgba(127, 177, 250, 0.45);
  background: rgba(19, 47, 86, 0.8);
}

#submitGuessBtn {
  background: linear-gradient(165deg, #39b8e6, #248ac6 72%);
}

.answers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
  justify-content: center;
  gap: 10px;
}

.answer-cell {
  min-height: 92px;
  border: 1px solid rgba(134, 181, 251, 0.5);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  background: linear-gradient(165deg, rgba(43, 96, 172, 0.95), rgba(25, 64, 124, 0.95) 72%);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
}

.answer-cell:hover:not(.revealed) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  filter: brightness(1.08);
}

.answer-cell.revealed {
  border-color: rgba(255, 211, 122, 0.94);
  background: linear-gradient(165deg, #4a76ad, #2f598e 72%);
  box-shadow: 0 0 0 2px rgba(255, 211, 122, 0.2);
}

.answer-rank {
  font-weight: 900;
  font-size: 1.2rem;
}

.answer-text {
  font-weight: 700;
}

.answer-points {
  font-weight: 900;
  font-size: 1.35rem;
  color: var(--accent);
}

.teams-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.teams-head h3 {
  margin: 0;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.join-panel {
  text-align: center;
  display: grid;
  gap: 6px;
}

.team-card {
  min-height: 180px;
  border: 1px solid rgba(130, 177, 247, 0.48);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(35, 84, 149, 0.93), rgba(22, 58, 113, 0.93));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.team-card.is-active {
  border-color: rgba(255, 211, 122, 0.95);
  box-shadow: 0 0 0 3px rgba(255, 211, 122, 0.28), 0 0 24px rgba(255, 211, 122, 0.2), 0 10px 24px rgba(8, 20, 44, 0.36);
  transform: translateY(-3px) scale(1.02);
}

.team-card.is-dimmed {
  opacity: 0.5;
  filter: saturate(0.7);
}

.team-card.is-out {
  border-color: rgba(255, 109, 115, 0.84);
  background: linear-gradient(165deg, rgba(89, 35, 48, 0.92), rgba(62, 24, 35, 0.92));
}

.team-name {
  font-weight: 800;
  font-size: clamp(1rem, 1vw + 0.85rem, 1.4rem);
  line-height: 1.2;
  text-align: center;
  display: grid;
  place-items: center;
  flex: 1;
}

.team-score {
  text-align: center;
  font-size: clamp(1.2rem, 1.3vw + 0.9rem, 1.7rem);
  font-weight: 900;
  color: var(--accent);
}

.team-strikes {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.team-strikes span {
  display: inline-block;
  margin-left: 5px;
  opacity: 0.25;
  color: var(--bad);
  font-weight: 900;
  font-size: 1.1rem;
}

.team-strikes span.on {
  opacity: 1;
}

.stack {
  display: grid;
  gap: 8px;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(127, 177, 250, 0.44);
  border-radius: 10px;
  background: rgba(19, 47, 86, 0.8);
  color: var(--text);
  padding: 9px 10px;
}

.stack {
  display: grid;
  gap: 8px;
}

.hidden {
  display: none;
}

.app.is-start .header,
.app.is-start .controls-row,
.app.is-start .join-panel {
  text-align: center;
}

.app.is-start .controls-row {
  justify-content: center;
}

.app.is-start .control-field,
.app.is-start #nextBtn,
.app.is-start #revealAllBtn,
.app.is-start #status,
.app.is-start .round-panel,
.app.is-start .guess-panel,
.app.is-start .teams-panel {
  display: none;
}

.app.is-start .control-field {
  justify-items: center;
}

.app.is-start #startBtn {
  min-width: 180px;
}

.app:not(.is-start) .control-field {
  display: none;
}

.app:not(.is-start) .controls-row {
  justify-content: center;
}

@media (max-width: 760px) {
  .controls-row {
    align-items: stretch;
  }

  .control-field {
    min-width: 0;
    flex: 1 1 40%;
  }

  .round-top {
    flex-direction: column;
  }

  .round-state-bar {
    grid-template-columns: 1fr;
  }

  .guess-row {
    grid-template-columns: 1fr;
  }

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