:root {
  --navy: #071e49;
  --blue: #123d88;
  --orange: #f28a16;
  --orange-deep: #df6f05;
  --paper: #f8fbff;
  --ink: #0a1833;
  --muted: #66738a;
  --line: #dce5f1;
  --green: #17a673;
  --red: #e34f55;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", "Avenir Next", Arial, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.hidden { display: none !important; }
.action-icon { display: grid; place-items: center; width: 28px; font-size: 25px; }
.feedback-icon { font-size: 48px; font-weight: 1000; line-height: 1; }

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: 24px clamp(20px, 4vw, 70px) 64px;
  background:
    radial-gradient(circle at 8% 18%, rgba(242, 138, 22, .11), transparent 22rem),
    radial-gradient(circle at 92% 78%, rgba(18, 61, 136, .12), transparent 28rem),
    linear-gradient(135deg, #fff 0%, #f6faff 58%, #eef5ff 100%);
}
.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: radial-gradient(#123d88 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, transparent, #000 28%, transparent);
}
.orbit {
  position: absolute;
  border: 2px solid rgba(18, 61, 136, .08);
  border-radius: 50%;
  pointer-events: none;
}
.orbit-one { width: 540px; height: 540px; right: -240px; top: -250px; }
.orbit-two { width: 360px; height: 360px; left: -190px; bottom: -170px; border-color: rgba(242, 138, 22, .12); }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: 0 auto;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(7, 30, 73, .1);
}
.brand { display: grid; width: max-content; color: var(--navy); line-height: 1; text-align: center; }
.brand span { font-family: Georgia, serif; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.brand strong { margin: 3px 0 2px; font-family: "Brush Script MT", "Segoe Script", cursive; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.05em; }
.brand small { font-family: Georgia, serif; font-size: 8px; font-weight: 800; letter-spacing: .22em; }
.game-label, .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
}
.game-label {
  padding: 10px 14px;
  color: white;
  background: var(--navy);
  border-radius: 999px;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.sound-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); background: white; }
.sound-button svg { width: 20px; }

.home-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .82fr);
  align-items: center;
  gap: clamp(20px, 4vw, 70px);
  width: min(1180px, 100%);
  min-height: calc(100vh - 170px);
  margin: 0 auto;
}
.hero-copy { max-width: 650px; }
.hero-copy .eyebrow {
  color: var(--orange-deep);
  padding: 9px 13px;
  border: 1px solid rgba(242, 138, 22, .26);
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
}
.hero-copy h1 {
  margin: 22px 0 18px;
  color: var(--navy);
  font-size: clamp(52px, 7.2vw, 102px);
  line-height: .88;
  letter-spacing: -.065em;
}
.hero-copy h1 em { color: var(--orange); font-style: normal; }
.hero-copy > p { max-width: 600px; margin: 0 0 30px; color: var(--muted); font-size: clamp(17px, 1.7vw, 21px); line-height: 1.55; }
.time-picker { display: grid; gap: 10px; margin: -8px 0 24px; }
.time-picker > span { display: flex; align-items: center; gap: 7px; color: var(--navy); font-size: 13px; font-weight: 900; }
.time-picker svg { width: 17px; }
.time-picker > div { display: flex; flex-wrap: wrap; gap: 7px; }
.time-picker button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--blue); background: white; font-size: 13px; font-weight: 900; }
.time-picker button.selected { color: white; border-color: var(--orange); background: var(--orange); }
.role-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.primary-action, .secondary-action {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 226px;
  padding: 16px 20px;
  border-radius: 18px;
  border: 0;
  box-shadow: 0 14px 32px rgba(7, 30, 73, .13);
  transition: transform .2s ease, box-shadow .2s ease;
}
.primary-action:hover, .secondary-action:hover, .wide-action:hover, .next-action:hover { transform: translateY(-2px); }
.primary-action { color: white; background: linear-gradient(135deg, var(--navy), var(--blue)); }
.secondary-action { color: var(--navy); background: white; border: 1px solid var(--line); }
.primary-action svg, .secondary-action svg { width: 27px; height: 27px; }
.primary-action span, .secondary-action span { display: grid; text-align: left; font-size: 17px; font-weight: 900; }
.primary-action small, .secondary-action small { margin-bottom: 2px; opacity: .7; font-size: 9px; letter-spacing: .13em; }

.mascot-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: min(690px, 70vh);
}
.mascot {
  position: relative;
  width: min(440px, 100%);
  height: 100%;
  overflow: hidden;
  border: 5px solid white;
  border-radius: 46% 46% 40px 40px;
  background: var(--navy);
  box-shadow: 0 30px 70px rgba(7, 30, 73, .24);
}
.mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.math-chip {
  position: absolute;
  z-index: 2;
  padding: 14px 18px;
  border: 4px solid white;
  border-radius: 18px;
  color: white;
  font-size: clamp(20px, 3vw, 36px);
  font-weight: 1000;
  box-shadow: 0 12px 28px rgba(7, 30, 73, .22);
  transform: rotate(-5deg);
}
.chip-a { left: -15px; top: 24%; background: var(--blue); }
.chip-b { right: -18px; bottom: 20%; background: var(--orange); transform: rotate(6deg); }

.back-button {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 18px auto 0;
  width: min(1180px, 100%);
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 900;
}
.center-panel, .finish-panel {
  position: relative;
  z-index: 2;
  width: min(520px, 100%);
  margin: clamp(34px, 7vh, 80px) auto 0;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 28px 65px rgba(7, 30, 73, .12);
  text-align: center;
}
.center-panel h2, .finish-panel h2, .room-card h2, .players-card h2 {
  margin: 9px 0 8px;
  color: var(--navy);
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -.04em;
}
.center-panel > p { margin: 0 0 26px; color: var(--muted); }
.panel-icon, .trophy {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  transform: rotate(-4deg);
}
.panel-icon svg, .trophy svg { width: 30px; height: 30px; }
.join-panel label { display: grid; gap: 7px; margin-top: 16px; color: var(--navy); font-size: 13px; font-weight: 900; text-align: left; }
.join-panel input {
  width: 100%;
  padding: 15px 17px;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: white;
  color: var(--ink);
  font-size: 17px;
}
.join-panel label:first-of-type input { text-transform: uppercase; font-size: 27px; font-weight: 1000; letter-spacing: .18em; text-align: center; }
.join-panel input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(242, 138, 22, .12); }
.avatar-picker { margin: 20px 0 0; padding: 0; border: 0; text-align: left; }
.avatar-picker legend { margin-bottom: 10px; color: var(--navy); font-size: 13px; font-weight: 900; }
.avatar-picker > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.avatar-picker button { display: grid; place-items: center; gap: 3px; padding: 7px 4px; border: 2px solid var(--line); border-radius: 14px; color: var(--muted); background: white; font-size: 10px; font-weight: 900; }
.avatar-picker button.selected { border-color: var(--orange); color: var(--orange-deep); background: #fff8ee; }
.avatar-picker img { width: 58px; height: 58px; object-fit: contain; }
.wide-action, .next-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 22px;
  padding: 16px 20px;
  border: 0;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  font-size: 17px;
  font-weight: 1000;
  box-shadow: 0 12px 26px rgba(242, 138, 22, .25);
  transition: .2s ease;
}
.error { display: flex; align-items: center; gap: 7px; color: #b4232a !important; font-size: 14px !important; font-weight: 800; }
.floating-error { position: fixed; z-index: 10; left: 50%; bottom: 52px; transform: translateX(-50%); padding: 11px 16px; border: 1px solid #f2b5b8; border-radius: 12px; background: #fff0f1; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.host-lobby {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 20px;
  width: min(1100px, 100%);
  margin: 24px auto 0;
}
.room-card, .players-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 22px 55px rgba(7, 30, 73, .1);
}
.room-card { text-align: center; }
.room-card h2 { font-size: 28px; }
.qr { width: min(220px, 80%); aspect-ratio: 1; margin: 12px auto 18px; border-radius: 16px; }
.room-code {
  position: relative;
  display: grid;
  padding: 13px;
  border: 2px dashed rgba(18, 61, 136, .25);
  border-radius: 16px;
  background: #f5f9ff;
}
.room-code small { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.room-code strong { color: var(--navy); font-size: 35px; letter-spacing: .15em; }
.room-code button { position: absolute; right: 12px; top: 50%; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: white; color: var(--blue); transform: translateY(-50%); }
.players-card { display: flex; flex-direction: column; min-height: 520px; }
.players-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.players-title h2 { font-size: 34px; }
.live-dot { padding: 7px 10px; border-radius: 999px; color: #087553; background: #e1faef; font-size: 10px; font-weight: 1000; letter-spacing: .1em; }
.live-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #15a875; animation: pulse 1.3s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.player-cloud { display: flex; flex: 1; flex-wrap: wrap; align-content: flex-start; gap: 11px; padding: 20px 0; }
.player-cloud > span { display: flex; align-items: center; gap: 8px; height: 47px; padding: 5px 13px 5px 6px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--navy); font-weight: 900; animation: pop .35s both; }
.player-cloud img { width: 38px; height: 38px; margin-left: -2px; border-radius: 50%; background: #edf4ff; object-fit: contain; }
@keyframes pop { from { opacity: 0; transform: scale(.8); } }
.empty { display: grid; place-items: center; width: 100%; padding-top: 70px; color: #9aa7ba; }
.empty svg { width: 48px; height: 48px; }

.waiting-panel { overflow: hidden; padding-top: 205px; }
.mascot.compact { position: absolute; top: -150px; left: 50%; width: 220px; height: 330px; border-width: 4px; border-radius: 42% 42% 30px 30px; transform: translateX(-50%); }
.waiting-avatar { position: absolute; z-index: 2; top: 125px; right: calc(50% - 120px); width: 72px; height: 72px; border: 4px solid white; border-radius: 50%; background: #edf4ff; object-fit: contain; box-shadow: 0 8px 20px rgba(7,30,73,.2); }
.waiting { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.waiting i { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); animation: bounce 1s infinite alternate; }
.waiting i:nth-child(2) { animation-delay: .2s; }
.waiting i:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { to { transform: translateY(-8px); opacity: .45; } }

.game-board {
  position: relative;
  z-index: 2;
  width: min(1040px, 100%);
  margin: 24px auto 0;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 30px;
  background: var(--navy);
  box-shadow: 0 26px 70px rgba(7, 30, 73, .25);
}
.round-top { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto; align-items: center; gap: 18px; color: white; font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.round-top > span { display: flex; align-items: center; gap: 6px; }
.timer { min-width: 62px; justify-content: center; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.12); font-size: 16px; }
.timer svg { width: 18px; }
.timer.urgent { color: white; background: var(--red); animation: pulse .6s infinite; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.16); }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--orange); transition: width .4s ease; }
.question-card { margin: 30px 0; padding: clamp(24px, 5vw, 48px); border-radius: 24px; background: white; text-align: center; }
.question-card small { color: var(--muted); font-size: 11px; font-weight: 1000; letter-spacing: .18em; }
.question-card div { margin-top: 4px; color: var(--navy); font-size: clamp(72px, 12vw, 140px); font-weight: 1000; line-height: 1; letter-spacing: -.04em; }
.question-card b { color: var(--orange); }
.host-bottom { display: grid; grid-template-columns: minmax(280px, .9fr) 1fr; align-items: end; gap: 24px; }
.mini-ranking { color: white; }
.mini-ranking h3 { margin: 0 0 8px; }
.mini-ranking > div, .full-ranking > div { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.13); }
.mini-ranking img, .full-ranking img { width: 28px; height: 28px; border-radius: 50%; background: white; object-fit: contain; }
.mini-ranking span { color: var(--orange); }
.next-action { justify-self: end; width: min(300px, 100%); }
.player-status { display: flex; justify-content: space-between; margin-bottom: 18px; color: white; font-size: 17px; font-weight: 900; }
.player-status strong { color: var(--orange); }
.player-status span { display: flex; align-items: center; gap: 8px; }
.player-status img { width: 42px; height: 42px; border-radius: 50%; background: white; object-fit: contain; }
.answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.answer { min-height: 84px; border: 0; border-radius: 18px; color: white; font-size: 35px; font-weight: 1000; box-shadow: inset 0 -5px 0 rgba(0,0,0,.14); transition: transform .15s ease; }
.answer:hover { transform: scale(1.015); }
.answer-1 { background: #2476df; }
.answer-2 { background: #eb5a56; }
.answer-3 { background: #e1a41a; }
.answer-4 { background: #28a573; }
.feedback { display: flex; align-items: center; justify-content: center; gap: 15px; min-height: 120px; border-radius: 20px; color: white; }
.feedback > svg { width: 44px; height: 44px; }
.feedback div { display: grid; }
.feedback strong { font-size: 28px; }
.feedback span { font-size: 16px; }
.feedback.correct { background: var(--green); }
.feedback.wrong { background: var(--red); }

.finish-panel { width: min(760px, 100%); margin-top: 26px; }
.finish-panel h2 { font-size: 42px; }
.podium { display: flex; align-items: end; justify-content: center; gap: 10px; margin: 38px 0 20px; }
.place { position: relative; display: grid; place-items: center; width: 31%; min-height: 140px; padding: 18px 10px; border-radius: 20px 20px 8px 8px; color: var(--navy); background: #eaf1fb; }
.place-1 { order: 2; min-height: 185px; color: white; background: linear-gradient(145deg, var(--orange), var(--orange-deep)); }
.place-2 { order: 1; }
.place-3 { order: 3; }
.place svg { position: absolute; top: -25px; color: #ffd15c; fill: #ffd15c; }
.place span { font-size: 24px; font-weight: 1000; }
.place b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.place strong { margin-top: 5px; font-size: 13px; }
.place > img { width: 64px; height: 64px; margin-bottom: 4px; border-radius: 50%; background: white; object-fit: contain; }
.full-ranking { color: var(--navy); text-align: left; }
.full-ranking > div { border-color: var(--line); }
.full-ranking span { color: var(--orange-deep); }

footer { position: absolute; z-index: 2; left: 0; right: 0; bottom: 16px; color: #8590a2; font-size: 11px; text-align: center; letter-spacing: .04em; }
footer strong { color: var(--blue); }

@media (max-width: 800px) {
  .app-shell { padding: 18px 16px 58px; overflow-y: auto; }
  .game-label { font-size: 9px; padding: 8px 10px; }
  .home-grid { grid-template-columns: 1fr; padding-top: 34px; text-align: center; }
  .hero-copy > p { margin-left: auto; margin-right: auto; }
  .time-picker > span, .time-picker > div { justify-content: center; }
  .role-actions { justify-content: center; }
  .primary-action, .secondary-action { flex: 1; min-width: min(210px, 100%); }
  .mascot-stage { height: 480px; width: min(390px, 100%); margin: 0 auto; }
  .mascot { border-radius: 42% 42% 28px 28px; }
  .chip-a { left: 0; }
  .chip-b { right: 0; }
  .host-lobby { grid-template-columns: 1fr; }
  .players-card { min-height: 360px; }
  .round-top { grid-template-columns: 1fr auto auto; }
  .round-top .progress { grid-column: 1 / -1; grid-row: 2; }
  .host-bottom { grid-template-columns: 1fr; }
  .next-action { justify-self: stretch; }
}

@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .brand strong { font-size: 26px; }
  .game-label { max-width: 115px; line-height: 1.25; border-radius: 12px; }
  .hero-copy h1 { font-size: 54px; }
  .home-grid { min-height: auto; }
  .mascot-stage { height: 420px; }
  .center-panel, .finish-panel, .room-card, .players-card { padding: 24px 18px; border-radius: 22px; }
  .question-card { margin: 20px 0; }
  .question-card div { font-size: 76px; }
  .answer { min-height: 72px; font-size: 30px; }
  .podium { gap: 5px; }
  .place { width: 33%; padding: 14px 4px; }
  .place b { font-size: 12px; }
  .room-code strong { font-size: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
