/* ============================================================
   ZAKOVAT — Zamin maktabi
   Tokens
   Color   — navy #0E2A5E, blue #1B4FA0, blue-light #3D6FC4,
             gold #D9A441, gold-dark #A97524, paper #F4F7FC, ink #0F1B2E
   Type    — Fraunces (display / crest voice), Manrope (interface)
   ============================================================ */

:root{
  --navy: #0E2A5E;
  --blue: #1B4FA0;
  --blue-light: #3D6FC4;
  --blue-pale: #E7EEFA;
  --gold: #D9A441;
  --gold-dark: #A97524;
  --gold-soft: #F1D48C;
  --paper: #F6F8FC;
  --ink: #0F1B2E;
  --ink-soft: #4C5A72;
  --white: #FFFFFF;

  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "Manrope", system-ui, sans-serif;

  --radius-lg: 28px;
  --radius-md: 16px;
  --shadow-deep: 0 30px 60px -20px rgba(14, 42, 94, 0.45);
}

*{ box-sizing: border-box; }
[hidden]{ display: none !important; }

:focus-visible{
  outline: 3px solid var(--gold-soft);
  outline-offset: 3px;
}

html, body{
  height: 100%;
}

body{
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(circle at 50% -10%, #1E4A94 0%, var(--navy) 46%, #081A3D 100%);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-ornament{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(217,164,65,0.12), transparent 40%),
    radial-gradient(circle at 88% 82%, rgba(217,164,65,0.10), transparent 42%);
}

/* ---------------- Topbar ---------------- */

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 48px);
  background: rgba(8, 26, 61, 0.58);
  border-bottom: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 12px 32px rgba(3, 14, 35, 0.18);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
}

@supports not ((backdrop-filter: blur(1px))){
  .topbar{ background: rgba(8, 26, 61, 0.94); }
}

.brand{
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  min-width: 0;
}

.brand-logo{
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: 0 0 46px;
  object-fit: contain;
}

.brand-text{
  min-width: 0;
}

.brand-eyebrow{
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--gold-soft);
  margin-bottom: 2px;
}

.brand-title{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(22px, 3vw, 30px);
  color: var(--white);
  margin: 0;
  letter-spacing: 0.01em;
}

.icon-btn{
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--white);
  padding: 10px 16px 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover{ background: rgba(255,255,255,0.16); transform: translateY(-1px); }

.icon-btn.plain{
  background: transparent;
  border: none;
  padding: 6px;
  color: var(--white);
}
.icon-btn.plain:hover{ color: var(--white); background: rgba(255,255,255,0.16); }

.icon-btn-label{ display: inline-block; }
@media (max-width: 460px){ .icon-btn-label{ display: none; } .icon-btn{ padding: 10px; } .btn-google-label{ display: none; } .btn-google{ padding: 10px; } }

body.gameplay-active .language-switcher{ display: none; }
body.gameplay-active #hostModeBtn{
  position: fixed;
  left: 18px;
  top: calc(100vh - 60px);
  bottom: auto;
  z-index: 8;
}
body.gameplay-active #openAdmin{
  position: fixed;
  top: 28px;
  right: 18px;
  z-index: 8;
}
body.gameplay-active .teams-bar{
  margin-right: 130px;
}

.teams-bar{
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 6px;
  border-radius: 999px;
}
.team-chip{
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--blue-pale);
  transition: background 0.18s ease, color 0.18s ease;
}
.team-chip:hover{ background: rgba(255,255,255,0.08); }
.team-chip.active{
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: var(--navy);
  box-shadow: 0 8px 18px rgba(0,0,0,0.22);
}
.team-name{
  font-size: 12.5px;
  font-weight: 700;
  outline: none;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-name:focus{ text-decoration: underline; }
.team-score{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  min-width: 1.3em;
  text-align: center;
  transition: transform 0.25s ease;
}
.team-score.bump{ transform: scale(1.35); }
.score-reset{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--blue-pale);
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
  margin-left: 2px;
}
.score-reset:hover{ background: rgba(255,255,255,0.22); }
@media (max-width: 640px){
  .teams-bar{ order: 3; width: 100%; justify-content: center; margin-top: 4px; }
  .topbar{ flex-wrap: wrap; row-gap: 10px; }
}
@media (max-width: 380px){
  .team-name{ max-width: 60px; }
}

.back-btn{ gap: 6px; }
.team-chips{ display: flex; flex-wrap: wrap; gap: 6px; }

.language-switcher{
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
}
.language-btn{
  border: 0;
  border-radius: 999px;
  min-width: 33px;
  padding: 6px 7px;
  cursor: pointer;
  color: var(--blue-pale);
  background: transparent;
  font: 800 10px var(--font-body);
  letter-spacing: .03em;
}
.language-btn.active{ color: var(--navy); background: var(--gold); }

/* ---------------- Home screen: topic library ---------------- */

.home-screen{
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(10px, 4vh, 30px) 20px 70px;
}

.firebase-notice{
  background: #FDE7C8;
  color: #7A4A0A;
  border: 1px solid #F0C58A;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 18px;
  text-align: center;
}
.firebase-notice code{ background: rgba(0,0,0,0.08); padding: 1px 6px; border-radius: 5px; }

.auth-bar{
  display: flex;
  align-items: center;
}
.btn-google{
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 9px 16px 9px 12px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
  white-space: nowrap;
}
.btn-google:hover{ transform: translateY(-1px); }
.auth-user{
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 6px 8px 6px 6px;
}
.auth-avatar{ width: 30px; height: 30px; border-radius: 50%; }
.auth-name{ color: var(--white); font-weight: 700; font-size: 13.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-admin-badge{
  background: var(--gold);
  color: var(--navy);
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.home-intro{
  text-align: center;
  margin-bottom: 22px;
}
.home-title{
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--white);
  font-size: clamp(26px, 4vw, 34px);
  margin: 0 0 8px;
}
.home-sub{
  color: rgba(231,238,250,0.75);
  margin: 0;
  font-size: 14.5px;
}

.settings-row{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
}
.team-count-picker{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--blue-pale);
  font-weight: 700;
  font-size: 13.5px;
}
.stepper{
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  overflow: hidden;
}
.stepper button{
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.stepper button:hover{ background: rgba(255,255,255,0.16); }
.stepper span{
  min-width: 34px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--white);
  font-size: 16px;
}

.topic-search-input{
  display: block;
  width: min(100%, 420px);
  margin: 0 auto 18px;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.topic-search-input::placeholder{ color: rgba(231,238,250,0.55); }
.topic-search-input:focus{
  outline: none;
  border-color: var(--gold);
  background: rgba(255,255,255,0.13);
}

.topic-tabs{
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.topic-tab{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--blue-pale);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.topic-tab:hover{ background: rgba(255,255,255,0.14); }
.topic-tab.active{
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
}

.topics-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  align-items: stretch;
}

.topic-card{
  background: var(--paper);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 190px;
  height: 100%;
  box-shadow: 0 20px 40px -16px rgba(0,0,0,0.4);
}
.topic-card-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topic-badge{
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--blue-pale);
  color: var(--blue);
}
.topic-badge.custom{ background: #EFE3FB; color: #7C3FBF; }
.topic-owner{
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: -2px 0 0;
}
.topics-loading{
  color: var(--blue-pale);
  text-align: center;
  grid-column: 1 / -1;
  padding: 30px;
  font-size: 14px;
}
.topic-card-actions{ display: flex; gap: 2px; }
.topic-rename, .topic-delete{
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  color: var(--ink-soft);
}
.topic-rename:hover{ background: var(--blue-pale); color: var(--blue); }
.topic-delete:hover{ background: #FBE7E7; color: #C24444; }
.topic-delete.admin-delete{ color: #C24444; }
.topic-name{
  font-family: var(--font-display);
  font-size: 19px;
  margin: 4px 0 0;
  color: var(--ink);
}
.topic-count{
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 6px;
  flex: 1;
}
.topic-play{ width: 100%; }
.topic-card-bottom{ display: flex; align-items: center; gap: 8px; margin-top: auto; }
.topic-card-bottom .topic-play{ flex: 1; }
.topic-save{
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1.5px solid rgba(14,42,94,.18);
  border-radius: 50%;
  background: var(--white);
  color: var(--gold-dark);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.topic-save:hover, .topic-save.is-saved{ color: var(--white); background: var(--gold-dark); border-color: var(--gold-dark); }

.topic-card-new{
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(255,255,255,0.07);
  border: 2px dashed rgba(255,255,255,0.32);
  color: var(--blue-pale);
  cursor: pointer;
  min-height: 190px;
  box-shadow: none;
  transition: background 0.18s ease;
}
.topic-card-new:hover{ background: rgba(255,255,255,0.13); }
.topic-card-new-icon{
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}
.topic-card-new p{ margin: 6px 0 0; font-weight: 600; font-size: 14px; }

/* ---------------- Stage / Wheel ---------------- */

.stage{
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: clamp(10px, 4vh, 30px) 20px 60px;
}

.host-exit-btn{
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 8;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(8, 26, 61, 0.72);
  color: var(--blue-pale);
  font: 700 12px var(--font-body);
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.host-exit-btn:hover{ background: rgba(8, 26, 61, 0.95); color: var(--white); }

.host-scoreboard{
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 7;
  width: min(28vw, 300px);
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  background: rgba(8, 26, 61, 0.78);
  color: var(--white);
  box-shadow: 0 24px 50px rgba(0,0,0,0.28);
  backdrop-filter: blur(12px);
}
.host-scoreboard-kicker{
  color: var(--gold-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.host-scoreboard h2{
  margin: 4px 0 14px;
  font: 600 24px var(--font-display);
}
.host-score-row{
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 10px;
  color: var(--blue-pale);
}
.host-score-row.active{ background: rgba(217,164,65,0.18); color: var(--white); }
.host-score-rank{ color: var(--gold-soft); font: 700 16px var(--font-display); }
.host-score-name{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.host-score-value{ color: var(--gold-soft); font: 700 20px var(--font-display); }

body.host-mode{ overflow: hidden; }
body.host-mode .topbar{ display: none; }
body.host-mode .stage{ min-height: 100vh; align-items: center; padding: 24px; }
body.host-mode .wheel-zone{ max-width: 760px; }
body.host-mode .wheel-frame{ width: min(68vh, 620px); }
body.host-mode .hint{ font-size: 15px; }

@media (max-width: 760px){
  body.gameplay-active #hostModeBtn{ left: 12px; bottom: 12px; }
  .host-scoreboard{ top: auto; right: 12px; bottom: 12px; width: min(72vw, 290px); padding: 14px; }
  body.host-mode .ambient-controls{ top: 12px; right: 12px; bottom: auto; }
  .host-scoreboard h2{ font-size: 20px; margin-bottom: 8px; }
  .host-score-row{ padding: 7px 6px; }
  body.host-mode .stage{ padding: 64px 14px 150px; }
  body.host-mode .wheel-frame{ width: min(82vw, 480px); }
}

.wheel-zone{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 620px;
}

.ambient-controls{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(14, 42, 94, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.ambient-toggle{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.ambient-toggle:hover{ background: rgba(255,255,255,0.2); }
.ambient-toggle.muted{ color: rgba(255,255,255,0.5); }
.ambient-slider{
  width: 90px;
  accent-color: var(--gold);
  cursor: pointer;
}
@media (max-width: 480px){
  .ambient-controls{ right: 12px; bottom: 12px; padding: 6px 10px 6px 6px; }
  .ambient-slider{ width: 64px; }
}

.wheel-frame{
  position: relative;
  width: min(78vw, 480px);
  aspect-ratio: 1/1;
}

.wheel-pointer{
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid var(--gold);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
  z-index: 5;
}
.wheel-pointer::after{
  content: "";
  position: absolute;
  top: -30px; left: -6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold-dark);
}

.wheel-rim{
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--gold), var(--gold-soft), var(--gold), var(--gold-dark), var(--gold));
  padding: 14px;
  box-shadow: var(--shadow-deep), inset 0 0 0 2px rgba(255,255,255,0.35);
}

.wheel-rotor{
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--white);
  box-shadow: inset 0 0 0 3px rgba(14,42,94,0.15);
  will-change: transform;
  contain: layout paint;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.wheel-rotor svg{ display: block; width: 100%; height: 100%; }

.wheel-hub{
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: var(--hub-size, 32%);
  aspect-ratio: 1/1;
  border-radius: 50%;
  background: var(--white);
  border: 4px solid var(--gold);
  box-shadow: 0 10px 24px rgba(14,42,94,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 4;
}
.wheel-hub:hover{ transform: translate(-50%, -50%) scale(1.04); }
.wheel-hub:active{ transform: translate(-50%, -50%) scale(0.97); }
.wheel-hub:disabled{ cursor: not-allowed; opacity: 0.75; }
.hub-logo{ width: 100%; height: 100%; object-fit: contain; }

.wheel-hub.spinning .hub-logo{
  animation: hub-pulse 0.9s ease-in-out infinite;
}
@keyframes hub-pulse{
  0%, 100%{ transform: scale(1); }
  50%{ transform: scale(1.08); }
}

.legend{
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
}
.legend-item{
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue-pale);
  font-size: 13.5px;
  font-weight: 600;
}
.dot{ width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-a{ background: var(--blue-light); }
.dot-b{ background: var(--gold); }
.dot-c{ background: #7C3FBF; }

.hint{
  color: rgba(231,238,250,0.75);
  font-size: 13.5px;
  margin: 0;
  text-align: center;
}

.wheel-rotor.empty{
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-pale);
}
.wheel-rotor.empty::after{
  content: "?";
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--blue-light);
}

/* ---------------- Overlay shared ---------------- */

.overlay{
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 18, 38, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, 2dvh) max(12px, 2vw);
  overflow: auto;
  animation: overlay-in 0.25s ease;
}
.overlay[hidden]{ display: none; }
@keyframes overlay-in{ from{ opacity: 0; } to{ opacity: 1; } }

/* ---------------- Winner screen ---------------- */

.winner-overlay{
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
  background: radial-gradient(circle at 50% 34%, rgba(61,111,196,0.38), rgba(8,18,38,0.94) 68%);
  backdrop-filter: blur(9px);
  animation: winner-in 0.45s ease both;
}
.winner-overlay[hidden]{ display: none; }
@keyframes winner-in{ from{ opacity: 0; } to{ opacity: 1; } }
.winner-card{
  position: relative;
  z-index: 1;
  width: min(92vw, 560px);
  max-height: min(90vh, 720px);
  overflow: auto;
  padding: 38px clamp(20px, 5vw, 48px) 30px;
  text-align: center;
  background: linear-gradient(150deg, rgba(255,255,255,0.98), rgba(231,238,250,0.98));
  border: 2px solid rgba(241,212,140,0.8);
  border-radius: 30px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.5), 0 0 0 10px rgba(217,164,65,0.08);
  animation: winner-card-in 0.7s cubic-bezier(0.2,0.85,0.3,1.2) both;
}
@keyframes winner-card-in{ from{ transform: translateY(30px) scale(.86); opacity: 0; } to{ transform: translateY(0) scale(1); opacity: 1; } }
.winner-rays{ position: absolute; width: 320px; height: 320px; top: -190px; left: 50%; transform: translateX(-50%); background: repeating-conic-gradient(from 0deg, rgba(217,164,65,.18) 0 7deg, transparent 7deg 18deg); border-radius: 50%; animation: rays-spin 18s linear infinite; pointer-events: none; }
@keyframes rays-spin{ to{ transform: translateX(-50%) rotate(360deg); } }
.winner-medal{ position: relative; display: grid; place-items: center; width: 78px; height: 78px; margin: 0 auto 15px; color: var(--navy); background: linear-gradient(145deg, var(--gold-soft), var(--gold)); border: 5px solid var(--white); border-radius: 50%; box-shadow: 0 12px 25px rgba(169,117,36,.35), 0 0 0 4px rgba(217,164,65,.2); animation: medal-bob 2.8s ease-in-out infinite; }
@keyframes medal-bob{ 50%{ transform: translateY(-7px) rotate(2deg); } }
.winner-kicker{ position: relative; margin: 0 0 5px; color: var(--gold-dark); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.winner-title{ position: relative; margin: 0; color: var(--navy); font: 600 clamp(30px, 7vw, 48px)/1.05 var(--font-display); }
.winner-message{ position: relative; margin: 12px 0 20px; color: var(--ink-soft); font-size: 14px; }
.winner-scores{ position: relative; margin: 0 auto 24px; max-width: 410px; text-align: left; }
.winner-scores-heading{ margin-bottom: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.winner-score-row{ display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; color: var(--ink); border-bottom: 1px solid rgba(14,42,94,.1); }
.winner-score-row.leader{ color: var(--navy); background: rgba(217,164,65,.16); border-radius: 12px; border-bottom-color: transparent; }
.winner-rank{ color: var(--gold-dark); font: 700 18px var(--font-display); }
.winner-team-name{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 800; }
.winner-score-row strong{ color: var(--blue); font: 700 22px var(--font-display); }
.winner-actions{ position: relative; display: flex; gap: 10px; }
.winner-actions .btn{ flex: 1; }
.winner-actions .btn-ghost{ border-color: rgba(27,79,160,.22); }
.winner-confetti{ position: absolute; inset: 0; pointer-events: none; }
.winner-confetti i{ position: absolute; top: -20px; left: calc(var(--i) * 2.94%); width: 8px; height: 15px; background: var(--gold); animation: confetti-fall 2.8s linear calc(var(--i) * -.08s) infinite; }
.winner-confetti i:nth-child(3n){ background: var(--blue-light); width: 6px; height: 10px; }
.winner-confetti i:nth-child(4n){ background: #F4F7FC; border: 1px solid rgba(217,164,65,.8); border-radius: 50%; }
@keyframes confetti-fall{ 0%{ transform: translate3d(0,-5vh,0) rotate(0); opacity: 0; } 12%{ opacity: 1; } 100%{ transform: translate3d(calc((var(--i) - 17) * 2px), 108vh, 0) rotate(680deg); opacity: .1; } }
@media (max-width: 420px){ .winner-card{ padding-top: 28px; } .winner-actions{ flex-direction: column-reverse; } }

/* ---------------- Envelope ---------------- */

.envelope-stage{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: min(320px, calc(100dvh - 24px));
}

.envelope{
  position: relative;
  width: 260px;
  cursor: pointer;
  animation: drop-in 0.5s cubic-bezier(0.2,0.9,0.3,1.2);
}
@keyframes drop-in{
  from{ transform: translateY(-40px) scale(0.85); opacity: 0; }
  to{ transform: translateY(0) scale(1); opacity: 1; }
}

.envelope-badge{
  position: absolute;
  top: -16px; left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
  font-size: 12.5px;
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
  z-index: 3;
  white-space: nowrap;
}

.envelope-back{
  width: 100%;
  aspect-ratio: 16/11;
  background: linear-gradient(160deg, var(--blue-light), var(--blue) 60%);
  border-radius: 10px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}

.envelope-front{
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
}

.envelope-flap{
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 62%;
  background: var(--white);
  clip-path: polygon(0 0, 100% 0, 50% 78%);
  transform-origin: top center;
  transition: transform 0.6s cubic-bezier(0.6,0.1,0.2,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.envelope-seal{
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 46px; height: 46px;
  background: var(--gold);
  color: var(--navy);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
  transition: opacity 0.3s ease;
  z-index: 2;
}

.envelope.open .envelope-flap{ transform: rotateX(180deg); }
.envelope.open .envelope-seal{ opacity: 0; }

.envelope-cta{
  text-align: center;
  color: var(--blue-pale);
  font-size: 13px;
  margin-top: 16px;
  font-weight: 600;
}

/* ---------------- Game setup card ---------------- */

.setup-card{
  width: min(92vw, 440px);
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 34px);
  box-shadow: var(--shadow-deep);
  animation: card-in 0.4s cubic-bezier(0.2,0.85,0.3,1.1);
  border: 1px solid rgba(14,42,94,0.08);
  text-align: center;
}
.setup-title{
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 24px);
  color: var(--ink);
  margin: 0 0 4px;
}
.setup-sub{
  color: var(--ink-soft);
  font-size: 13.5px;
  margin: 0 0 22px;
}
.setup-card .settings-row{
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.setup-card .team-count-picker{
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--blue-pale);
  border-radius: 14px;
  padding: 12px 18px;
}
.setup-card .team-count-picker span{
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}
.setup-card .stepper{
  background: var(--white);
  border: 1px solid rgba(14,42,94,0.12);
}
.setup-card .stepper button{ color: var(--blue); }
.setup-card .stepper span{ color: var(--ink); }
.setup-timer-box{
  background: rgba(27, 79, 160, 0.05);
  border: 1px solid rgba(14, 42, 94, 0.08);
  border-radius: 16px;
  padding: 14px 14px 12px;
  margin-bottom: 16px;
}
.setup-timer-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 10px;
}
.setup-timer-value{
  color: var(--blue);
  font-weight: 900;
}
.setup-timer-box input[type="range"]{
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
}
.question-count-range{
  height: 28px;
  accent-color: var(--blue);
  background: transparent;
  cursor: grab;
  touch-action: pan-x;
}
.question-count-range:active{ cursor: grabbing; }
.question-count-range::-webkit-slider-runnable-track{
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) 0 var(--question-progress, 10%), rgba(14,42,94,0.14) var(--question-progress, 10%) 100%);
}
.question-count-range::-moz-range-track{
  height: 8px;
  border-radius: 999px;
  background: rgba(14,42,94,0.14);
}
.question-count-range::-moz-range-progress{
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
}
.question-count-range::-webkit-slider-thumb{
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 2px 8px rgba(14,42,94,0.28);
  -webkit-appearance: none;
}
.question-count-range::-moz-range-thumb{
  width: 16px;
  height: 16px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 2px 8px rgba(14,42,94,0.28);
}
.setup-timer-input-row{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.setup-timer-input-row input{
  width: 110px;
  background: var(--white);
  border: 1px solid rgba(14,42,94,0.12);
  border-radius: 10px;
  padding: 9px 10px;
  font: 700 14px var(--font-body);
  color: var(--ink);
}
.setup-timer-input-row span{
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}
.setup-toggle-row{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(14,42,94,0.08);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}
.toggle-switch{
  position: relative;
  width: 52px;
  min-width: 52px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: rgba(14,42,94,0.18);
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-switch.on{ background: var(--blue); }
.toggle-switch .toggle-thumb{
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: transform 0.2s ease;
}
.toggle-switch.on .toggle-thumb{ transform: translateX(22px); }
.setup-actions{
  display: flex;
  gap: 10px;
}
.setup-actions .btn{ flex: 1; }

/* ---------------- Question card ---------------- */

.question-card{
  width: min(92vw, 720px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: clamp(12px, 2dvh, 22px) clamp(14px, 2.5vw, 30px);
  box-shadow: var(--shadow-deep);
  animation: card-in 0.4s cubic-bezier(0.2,0.85,0.3,1.1);
  border: 1px solid rgba(14,42,94,0.08);
}
.question-card.question-reveal-effect{
  animation: question-reveal 1.1s cubic-bezier(0.18, 0.88, 0.32, 1.12) both;
}
@keyframes question-reveal{
  0%{ opacity: 0; transform: translateY(30px) scale(.88) rotateX(8deg); box-shadow: 0 0 0 rgba(217,164,65,0); }
  55%{ opacity: 1; transform: translateY(-5px) scale(1.015) rotateX(0); box-shadow: 0 0 42px rgba(217,164,65,.34), var(--shadow-deep); }
  100%{ opacity: 1; transform: translateY(0) scale(1) rotateX(0); box-shadow: var(--shadow-deep); }
}
@keyframes card-in{
  from{ transform: scale(0.92) translateY(10px); opacity: 0; }
  to{ transform: scale(1) translateY(0); opacity: 1; }
}

.question-tag{
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--blue);
  background: var(--blue-pale);
  padding: 6px 14px;
  border-radius: 999px;
}

.question-text{
  font-family: var(--font-display);
  font-size: clamp(20px, min(3vw, 4dvh), 36px);
  line-height: 1.18;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--ink);
  margin: 12px 0 6px;
}

.question-meta{
  color: var(--gold-dark);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}
.question-timer{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 0 0 clamp(10px, 2dvh, 18px);
  padding: 12px 16px;
  color: var(--blue);
  background: var(--blue-pale);
  border: 1px solid rgba(27,79,160,.16);
  border-radius: 16px;
}
.timer-header{ grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.question-timer-label{ font-size: 12px; font-weight: 800; }
.timer-header-actions{ display: flex; align-items: center; gap: 8px; }
.question-timer strong{ min-width: 48px; font-family: var(--font-display); font-size: clamp(28px, min(6vw, 7dvh), 56px); letter-spacing: .04em; }
.timer-duration{ grid-column: 1 / -1; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.timer-duration input{ width: 54px; padding: 5px 6px; border: 1px solid rgba(27,79,160,.24); border-radius: 7px; background: var(--white); color: var(--ink); font: 700 12px var(--font-body); text-align: center; }
.timer-duration input:focus{ outline: 2px solid rgba(27,79,160,.3); outline-offset: 1px; }
.timer-control{ border: 0; border-radius: 999px; padding: 7px 12px; cursor: pointer; background: var(--blue); color: var(--white); font: 700 11px var(--font-body); }
.timer-control:hover{ background: var(--navy); }
.timer-reset{ background: transparent; color: var(--blue); border: 1px solid rgba(27,79,160,.24); }
.timer-reset:hover{ background: rgba(27,79,160,.1); }
.question-timer.timer-danger{ color: #BD4A35; background: #FFF1EB; border-color: #F2B7A7; }
.question-timer.timer-danger .timer-control{ background: #BD4A35; }
.question-timer.timer-ended{ color: #A92B2B; background: #FCE7E7; border-color: #E8AAAA; }
.answer-reveal-btn{ margin-bottom: 20px; }
.answer-box{
  margin-top: 10px;
  background: var(--blue-pale);
  border: 1px solid rgba(27,79,160,0.18);
  border-radius: 12px;
  padding: 10px 14px;
  animation: card-in 0.2s ease;
}
.answer-box-label{
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--blue);
  margin-bottom: 4px;
}
.answer-box p{
  max-height: min(24dvh, 220px);
  overflow-y: auto;
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  font-size: clamp(18px, min(2.8vw, 4dvh), 32px);
  line-height: 1.18;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.answer-box p.long-answer{ font-size: clamp(20px, min(3.5vw, 4.8dvh), 42px); }

.answering-team{
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-dark);
  margin: 0 0 14px;
}

.btn{
  border: none;
  border-radius: 999px;
  padding: 13px 26px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary{
  background: var(--blue);
  color: var(--white);
  width: 100%;
  box-shadow: 0 10px 20px rgba(27,79,160,0.35);
}
.btn-primary:hover{ background: var(--navy); transform: translateY(-1px); }

.btn-ghost{
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--blue-pale);
  padding: 8px 16px;
  font-size: 13px;
}
.btn-ghost:hover{ background: var(--blue-pale); }

.question-actions{
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.team-answer-row{
  display: grid;
  grid-template-columns: minmax(100px, .65fr) 1.8fr;
  align-items: center;
  gap: 7px;
  padding: 7px;
  background: rgba(27,79,160,.05);
  border: 1px solid rgba(27,79,160,.12);
  border-radius: 14px;
}
.team-answer-row.has-result{ border-color: rgba(30,142,90,.4); background: rgba(30,142,90,.08); }
.team-answer-name{
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-answer-buttons{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.team-result{
  min-height: 32px;
  padding: 6px 5px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.15;
  color: var(--white);
}
.team-result.on-time{
  background: #1E8E5A;
  box-shadow: 0 6px 14px rgba(30,142,90,0.25);
}
.team-result.on-time:hover{ background: #176B44; transform: translateY(-1px); }
.team-result.early{
  background: var(--blue);
  box-shadow: 0 6px 14px rgba(27,79,160,0.22);
}
.team-result.early:hover{ background: var(--navy); transform: translateY(-1px); }
.team-result.incorrect{
  background: var(--white);
  color: #C24444;
  border: 1.5px solid #F0C7C7;
}
.team-result.incorrect:hover{ background: #FBE7E7; transform: translateY(-1px); }
.team-result.selected{ outline: 3px solid var(--gold); outline-offset: 1px; transform: translateY(-1px); }
@media (max-width: 560px){
  .team-answer-row{ grid-template-columns: 1fr; gap: 7px; }
  .team-answer-buttons{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .team-result{ font-size: 10px; }
}
@media (max-height: 700px) and (min-width: 561px){
  .question-card{ padding-block: 12px; }
  .question-text{ margin-block: 10px 5px; }
  .question-meta{ margin-bottom: 8px; }
  .answer-reveal-btn{ margin-bottom: 10px; }
  .answer-box{ padding-block: 8px; }
  .question-actions{ gap: 6px; margin-top: 10px; }
  .team-answer-row{ padding: 6px 8px; }
  .team-result{ min-height: 32px; padding-block: 6px; }
}
@media (max-width: 420px){
  .overlay{ padding: 8px; }
  .envelope-stage{ min-height: calc(100dvh - 16px); }
  .question-card{ max-height: calc(100dvh - 16px); padding: 10px; }
  .question-text{ font-size: clamp(19px, 6vw, 28px); line-height: 1.15; }
  .question-timer{ gap: 7px; padding: 8px 10px; }
  .question-timer strong{ font-size: clamp(26px, 9vw, 38px); }
  .timer-control{ padding: 6px 8px; }
  .timer-header-actions{ gap: 6px; }
  .answer-box p{ max-height: 22dvh; font-size: clamp(17px, 6vw, 26px); }
  .answer-box p.long-answer{ font-size: clamp(17px, 5.5vw, 25px); }
  .team-answer-row{ padding: 8px; }
}
.btn-correct{
  flex: 1;
  background: #1E8E5A;
  color: var(--white);
  box-shadow: 0 10px 20px rgba(30,142,90,0.35);
}
.btn-correct:hover{ background: #176B44; transform: translateY(-1px); }
.btn-wrong{
  flex: 1;
  background: var(--white);
  color: #C24444;
  border: 1.5px solid #F0C7C7;
}
.btn-wrong:hover{ background: #FBE7E7; transform: translateY(-1px); }

/* ---------------- Generic modal ---------------- */

.modal-overlay{
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 18, 38, 0.72);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.modal-overlay[hidden]{ display: none; }

.modal-card{
  width: min(92vw, 780px);
  background: rgba(18, 27, 42, 0.98);
  border: 1px solid rgba(168, 182, 214, 0.2);
  border-radius: 18px;
  box-shadow: var(--shadow-deep);
  padding: 22px 22px 18px;
  animation: overlay-in 0.22s ease;
}

.modal-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-header h3{
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 24px);
  color: var(--white);
}
.modal-message{
  margin: 0 0 18px;
  color: rgba(231, 238, 250, 0.9);
  line-height: 1.55;
  font-size: 15px;
}
.modal-input-wrap{
  display: block;
  margin-bottom: 18px;
}
.modal-input-wrap span{
  display: block;
  color: var(--blue-pale);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.modal-input-wrap input{
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(168, 182, 214, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--white);
  font: 600 14px var(--font-body);
}
.modal-input-wrap input:focus{
  outline: 2px solid rgba(109, 180, 255, 0.5);
  outline-offset: 1px;
}
.modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.modal-actions .btn{
  min-width: 120px;
}
.modal-actions .btn-ghost{
  background: transparent;
  color: var(--white);
  border-color: rgba(168, 182, 214, 0.2);
}
.modal-actions .btn-ghost:hover{
  background: rgba(255,255,255,0.04);
}

/* ---------------- Admin panel (side drawer) ---------------- */

.drawer-overlay{
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
}
.drawer-overlay[hidden]{ display: none; }

.drawer-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 38, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.32s ease;
}
.drawer-overlay.open .drawer-backdrop{ opacity: 1; }

.admin-panel{
  width: min(94vw, 560px);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow-deep);
}

.admin-drawer{
  position: relative;
  z-index: 2;
  width: min(430px, 92vw);
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: -30px 0 60px -20px rgba(14, 42, 94, 0.5);
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.drawer-overlay.open .admin-drawer{ transform: translateX(0); }

.admin-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.admin-head h2{
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
  color: var(--ink);
}

.admin-form{
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(14,42,94,0.1);
  margin-bottom: 16px;
}

.admin-tools{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.admin-tools .btn-ghost{ flex: 1; min-width: 100px; font-size: 12.5px; padding: 10px 8px; }

.csv-hint{
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}
.csv-hint code{
  background: rgba(14,42,94,0.08);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11.5px;
}
.csv-template-link{
  background: none;
  border: none;
  padding: 0;
  color: var(--blue);
  font-weight: 700;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  flex: 1;
}
.field textarea, .field input, .field select{
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1.5px solid rgba(14,42,94,0.15);
  background: var(--white);
  color: var(--ink);
  resize: vertical;
}
.field textarea:focus, .field input:focus, .field select:focus{
  outline: 2px solid var(--blue-light);
  outline-offset: 1px;
}

.field-row{ display: flex; gap: 14px; }
.field-small{ max-width: 110px; }

.admin-list-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.admin-list-head h3{
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  color: var(--ink);
}

.question-search-input{
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1.5px solid rgba(14,42,94,0.15);
  background: var(--white);
  color: var(--ink);
  margin-bottom: 10px;
}
.question-search-input:focus{
  outline: 2px solid var(--blue-light);
  outline-offset: 1px;
}

.question-tabs{
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.q-tab{
  background: var(--white);
  border: 1.5px solid rgba(14,42,94,0.15);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12.5px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.q-tab:hover{ background: var(--blue-pale); }
.q-tab.active{
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

.admin-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-row{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--white);
  border: 1px solid rgba(14,42,94,0.08);
  border-radius: 12px;
  padding: 12px 14px;
}
.q-row.used{ opacity: 0.5; }

.q-row-body{ flex: 1; }
.q-row-tag{
  font-size: 11px;
  font-weight: 800;
  color: var(--blue);
  text-transform: none;
  margin-bottom: 4px;
  display: block;
}
.q-row-text{ font-size: 14px; color: var(--ink); margin: 0; line-height: 1.4; }
.q-row-meta{ font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.q-row-actions{
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.q-row-del, .q-row-edit{
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.q-row-del{ color: #C24444; }
.q-row-del:hover{ background: #FBE7E7; }
.q-row-edit{ color: var(--blue); }
.q-row-edit:hover{ background: var(--blue-pale); }
.q-row.editing{ outline: 2px solid var(--blue-light); outline-offset: 1px; }

.empty-note{
  color: var(--ink-soft);
  font-size: 13.5px;
  text-align: center;
  padding: 14px;
}

/* ---------------- Motion polish ---------------- */

@keyframes soft-rise{
  from{ opacity: 0; transform: translateY(16px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes soft-scale{
  from{ opacity: 0; transform: scale(.96); }
  to{ opacity: 1; transform: scale(1); }
}

body:not(.gameplay-active) .topbar > *{
  animation: soft-rise .65s cubic-bezier(.22,.8,.25,1) both;
}
body:not(.gameplay-active) .topbar > :nth-child(2){ animation-delay: .08s; }
body:not(.gameplay-active) .topbar > :nth-child(3){ animation-delay: .14s; }
body:not(.gameplay-active) .topbar > :nth-child(4){ animation-delay: .2s; }
body:not(.gameplay-active) .topbar > :nth-child(5){ animation-delay: .26s; }

.home-intro{ animation: soft-rise .7s cubic-bezier(.22,.8,.25,1) both; }
.topic-search-input{ animation: soft-scale .6s .12s cubic-bezier(.22,.8,.25,1) both; }
.topic-tabs{ animation: soft-rise .6s .18s cubic-bezier(.22,.8,.25,1) both; }
.topic-card{
  animation: soft-rise .65s cubic-bezier(.22,.8,.25,1) both;
  transition: transform .35s cubic-bezier(.22,.8,.25,1), box-shadow .35s ease;
}
.topic-card:nth-child(2){ animation-delay: .06s; }
.topic-card:nth-child(3){ animation-delay: .12s; }
.topic-card:nth-child(4){ animation-delay: .18s; }
.topic-card:nth-child(5){ animation-delay: .24s; }
.topic-card:nth-child(6){ animation-delay: .3s; }
.topic-card:nth-child(7){ animation-delay: .36s; }
.topic-card:nth-child(8){ animation-delay: .42s; }
.topic-card:hover{
  transform: translateY(-6px);
  box-shadow: 0 28px 48px -18px rgba(0,0,0,.5);
}

.topic-tab, .team-chip, .icon-btn, .btn, .ambient-toggle{
  transition: transform .25s cubic-bezier(.22,.8,.25,1), background .25s ease, color .25s ease, box-shadow .25s ease;
}
.topic-tab:active, .team-chip:active, .icon-btn:active, .btn:active, .ambient-toggle:active{
  transform: scale(.96);
}
.team-chip:hover{ transform: translateY(-2px); }
.btn:hover{ box-shadow: 0 14px 24px rgba(27,79,160,.28); }

.gameplay-active .wheel-zone{ animation: soft-scale .75s cubic-bezier(.22,.8,.25,1) both; }
.gameplay-active .ambient-controls{ animation: soft-rise .65s .15s cubic-bezier(.22,.8,.25,1) both; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}