:root {
  --bg: #fff4f8;
  --surface: #ffffff;
  --border: #f7cfe0;
  --text: #8a3d5c;
  --muted: #d089a8;
  --p1: #f8a1c5;
  --p2: #ed5f91;
  --accent: #ed5f91;
  --halo1: rgba(248, 161, 197, 0.4);
  --halo2: rgba(237, 95, 145, 0.18);
  --halo3: rgba(248, 161, 197, 0.22);
  --shadow: 0 12px 36px rgba(237, 95, 145, 0.12);
  --radius: 22px;
  --pill: 999px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --grad: linear-gradient(135deg, #f8a1c5 0%, #ed5f91 100%);
  color-scheme: light;
}

html.dark {
  --bg: #2a1520;
  --surface: #3a1f2c;
  --border: #6b3d50;
  --text: #ffe8f0;
  --muted: #e0b0c0;
  --p1: #f8a1c5;
  --p2: #ed5f91;
  --accent: #f8a1c5;
  --halo1: rgba(248, 161, 197, 0.2);
  --halo2: rgba(237, 95, 145, 0.16);
  --halo3: rgba(248, 161, 197, 0.12);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.bg-halos {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 12% 8%, var(--halo1), transparent 58%),
    radial-gradient(ellipse 55% 40% at 88% 18%, var(--halo2), transparent 55%),
    radial-gradient(ellipse 45% 35% at 70% 85%, var(--halo3), transparent 55%),
    radial-gradient(ellipse 50% 40% at 30% 100%, var(--halo1), transparent 60%);
}

.topbar,
.app,
.banner {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  max-width: 560px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 42px;
  width: auto;
  display: block;
}

.brand-mark {
  height: 34px;
  width: auto;
  display: block;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 650;
  font-variation-settings: "SOFT" 100;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  color: var(--p2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.text-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--pill);
  cursor: pointer;
}

.text-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.icon-btn.muted-sound {
  opacity: 0.45;
}

.icon-btn:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--p1);
  outline-offset: 2px;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 3rem;
}

.banner {
  text-align: center;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.banner.hidden,
.hidden {
  display: none !important;
}

h1,
h2,
.display {
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: clamp(1.9rem, 6vw, 2.45rem);
}

h2 {
  font-size: 1.45rem;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 1.05rem;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  text-align: center;
  font-weight: 800;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  border-radius: var(--pill);
  padding: 0.95rem 1.35rem;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 24px rgba(237, 95, 145, 0.28);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.btn-row .btn {
  flex: 1 1 140px;
}

.hero-home {
  text-align: center;
  padding: 1.25rem 0 0.35rem;
}

.hero-home .logo-hero {
  width: min(280px, 78vw);
  height: auto;
  margin: 0 auto 0.85rem;
  display: block;
}

.hero-home h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.error {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.center {
  text-align: center;
}

.code-big {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  margin: 0.4rem 0 1rem;
}

.players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.player-slot {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem 0.75rem;
  text-align: center;
  background: var(--bg);
}

.player-slot .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin: 0 auto 0.55rem;
}

.player-slot.p1 .dot {
  background: var(--p1);
}

.player-slot.p2 .dot {
  background: var(--p2);
}

.player-slot .name {
  font-weight: 800;
}

.player-slot .status {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.player-slot.empty {
  opacity: 0.65;
  border-style: dashed;
}

.game-checks {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.game-check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  cursor: pointer;
  font-weight: 700;
}

.game-check input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--p1);
}

.wait-pulse {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 72px;
  margin: 0.5rem 0 1rem;
}

.wait-pulse .logo-mark {
  height: 56px;
  width: auto;
  animation: pulse-soft 1.6s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--p1) 12%, var(--surface));
  color: var(--accent);
  font-weight: 800;
  font-size: 0.85rem;
}

.round-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  gap: 0.75rem;
}

.subject {
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin: 0.4rem 0 1rem;
}

.slider-block {
  margin-bottom: 1.25rem;
}

.slider-block .ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  gap: 0.5rem;
}

.slider-block input[type="range"] {
  width: 100%;
  accent-color: var(--p1);
}

.slider-block .val {
  text-align: right;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--muted);
}

.choice-grid {
  display: grid;
  gap: 0.75rem;
}

.choice-btn {
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.choice-btn.selected {
  border-color: var(--p1);
  background: color-mix(in srgb, var(--p1) 12%, var(--surface));
}

.choice-btn.p2.selected {
  border-color: var(--p2);
  background: color-mix(in srgb, var(--p2) 16%, var(--surface));
}

.section-label {
  font-weight: 800;
  margin: 0.4rem 0 0.65rem;
  font-size: 0.95rem;
}

.top10-layout {
  display: grid;
  gap: 1rem;
}

.rank-list,
.pool-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rank-slot,
.pool-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
}

.rank-slot {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.rank-slot .num {
  width: 1.6rem;
  color: var(--muted);
  font-weight: 800;
}

.rank-slot.filled {
  border-color: var(--p1);
}

.pool-item:active,
.rank-slot:active {
  transform: scale(0.99);
}

.answer-status {
  margin: 0.75rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--p2) 14%, var(--surface));
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
}

.reveal-score {
  text-align: center;
  margin: 0.5rem 0 1.1rem;
}

.reveal-score .num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.track {
  margin-bottom: 1.1rem;
}

.track .label {
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.track-bar {
  position: relative;
  height: 16px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--border) 70%, var(--bg));
  margin: 1.1rem 0 0.4rem;
}

.marker {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.marker.true {
  background: var(--p1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--p1) 30%, transparent);
}

.marker.guess {
  background: transparent;
  border: 3px solid var(--p2);
}

.marker.true.p2 {
  background: var(--p2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--p2) 30%, transparent);
}

.marker.guess.p1 {
  border-color: var(--p1);
}

.flip-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  perspective: 900px;
  margin: 1rem 0;
}

.flip-card {
  min-height: 120px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-weight: 800;
  animation: fade-up 0.45s ease both;
}

.flip-card .who {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.flip-card.sync {
  border-color: var(--p1);
}

.sync-badge {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0.5rem 0 1rem;
}

.rank-reveal {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.rank-reveal-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.92rem;
}

.rank-reveal-row .tag {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.rank-reveal-row.perfect .tag {
  color: var(--p1);
  font-weight: 800;
}

.prefer-reveal {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.prefer-line {
  padding: 0.85rem;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.results {
  text-align: center;
}

.overlap {
  position: relative;
  width: 160px;
  height: 120px;
  margin: 1.2rem auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlap .logo-mark {
  height: 96px;
  width: auto;
  animation: pulse-soft 2s ease-in-out infinite;
}

.percent-big {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 700;
  margin: 0.2rem 0;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.verdict {
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin: 0 0 1.25rem;
}

.game-scores {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
}

.game-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 700;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen-enter {
  animation: fade-up 0.4s ease both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #2a1520;
    --surface: #3a1f2c;
    --border: #6b3d50;
    --text: #ffe8f0;
    --muted: #e0b0c0;
    --halo1: rgba(248, 161, 197, 0.2);
    --halo2: rgba(237, 95, 145, 0.16);
    --halo3: rgba(248, 161, 197, 0.12);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
