:root {
  color-scheme: dark;
  --bg: #070b14;
  --gold: #f0c14d;
  --red: #ff3b30;
  --ink: #f4f7fb;
  --muted: #b7c3d9;
  --line: rgba(255, 255, 255, 0.08);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(820px 420px at 50% -8%, rgba(255, 122, 0, 0.22), transparent 58%),
    radial-gradient(700px 380px at 100% 100%, rgba(29, 78, 216, 0.22), transparent 50%),
    radial-gradient(500px 280px at 0% 80%, rgba(225, 29, 46, 0.16), transparent 50%),
    var(--bg);
}
.backdrop::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(540px, 48vw);
  height: min(820px, 94vh);
  transform: translate(-50%, -50%);
  background: url("../logo.png") center / contain no-repeat;
  opacity: 0.55;
  pointer-events: none;
}

.hidden { display: none !important; }

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--gold);
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; line-height: 1.45; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  flex-wrap: wrap;
}

.brand {
  color: white;
  text-decoration: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  height: 58px;
  width: auto;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(255, 122, 0, 0.35));
}
.landing-logo {
  width: min(240px, 68vw);
  height: auto;
  display: block;
  margin: 0 auto 10px;
  filter: drop-shadow(0 16px 32px rgba(255, 122, 0, 0.32));
}
.gate-logo {
  width: 148px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
  filter: drop-shadow(0 10px 18px rgba(255, 122, 0, 0.35));
}
.offer-mark {
  width: 92px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
}

.brand strong {
  font-family: Oswald, Impact, sans-serif;
  font-size: 22px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.brand em { font-style: normal; color: var(--red); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.namebox {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.namebox input { width: 140px; }

input[type="text"],
input[type="password"],
#offerInput,
#playerName,
#password {
  background: #0c1018;
  border: 1px solid #2c3548;
  border-radius: 12px;
  padding: 12px 14px;
  color: white;
}

.conn { font-size: 12px; color: #ff8d8d; }
.conn::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
}
.conn.on { color: #3ddc97; }

.game {
  display: grid;
  grid-template-columns: minmax(168px, 220px) minmax(0, 1fr) minmax(168px, 220px);
  gap: 14px;
  padding: 0 14px 18px;
  align-items: start;
}

body.role-admin .game {
  grid-template-columns: minmax(150px, 200px) minmax(0, 1fr) minmax(150px, 200px) minmax(250px, 320px);
}

.panel {
  background: rgba(10, 14, 24, 0.55);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  min-width: 0;
}

.board-wrap,
.stage-wrap,
.offer-wrap {
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.board-wrap { container-type: inline-size; }

.panel h2,
.offer-wrap h3 {
  margin: 14px 0 8px;
  font-family: Oswald, Impact, sans-serif;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.panel h2 { margin-top: 0; font-size: 18px; }
.offer-wrap h3 { font-size: 14px; color: #d5dced; }
.decision {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(240, 193, 77, 0.5);
  background: rgba(240, 193, 77, 0.08);
}
.decision strong { font-size: 22px; }
.decision .choices .btn { min-height: 64px; }

.board { display: flex; flex-direction: column; gap: 4px; }
.lo-wrap h2 { color: #ff8d96; }
.hi-wrap h2 { color: #9ec4ff; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.prize {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.2;
}

.prize span { min-width: 0; }
.prize i { font-style: normal; flex: 0 0 auto; }
.prize.lo { background: rgba(225, 29, 46, 0.12); color: #ffd0d4; }
.prize.hi { background: rgba(59, 130, 246, 0.12); color: #d6e6ff; }
.prize.jackpot { color: #ffe08a; font-weight: 700; }
.prize.dead {
  background: rgba(255, 255, 255, 0.03);
  color: #7e8798;
  text-decoration: line-through;
  opacity: 0.7;
}
.prize.won {
  background: rgba(240, 193, 77, 0.18);
  color: #ffe7a8;
  text-decoration: none;
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(240, 193, 77, 0.45);
}
.prize.just-dead { animation: strike 0.7s ease; }

@keyframes strike {
  0% { background: rgba(255, 60, 60, 0.5); }
  100% { background: rgba(255, 255, 255, 0.03); }
}

.stage-wrap { display: flex; flex-direction: column; gap: 12px; }

#hud { text-align: center; }
#hud h2 {
  margin: 0;
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: 0.03em;
}
#hud p { margin: 6px 0 0; color: var(--muted); }

.mine-badge {
  display: inline-block;
  margin-top: 8px !important;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(240, 193, 77, 0.16);
  color: var(--gold) !important;
}

.pips { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a3348;
  display: inline-block;
}
.pip.on { background: var(--gold); }

.stage {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.box {
  position: relative;
  aspect-ratio: 1 / 0.86;
  border-radius: 16px;
  border: 1px solid rgba(190, 214, 255, 0.45);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.28), transparent 28%),
    linear-gradient(180deg, #3c7fe8 0%, #1a4eae 42%, #0e2f72 100%);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 18px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  overflow: hidden;
  touch-action: manipulation;
}

.box:not(.open)::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 48%;
  height: 2px;
  background: rgba(255, 255, 255, 0.28);
}

.box .num {
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(18px, 2vw, 30px);
  line-height: 1;
  position: relative;
}

.box .mini,
.box .secret {
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}
.box .secret { color: #ffe7a8; }

.box .tag {
  position: absolute;
  top: 5px;
  font-size: 9px;
  letter-spacing: 0.12em;
  background: var(--gold);
  color: #1a1203;
  border-radius: 999px;
  padding: 2px 6px;
  font-weight: 700;
}

.box:not(:disabled):hover { transform: translateY(-3px); }
.box:disabled { cursor: default; opacity: 1; }
.box.mine {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240, 193, 77, 0.35), 0 10px 18px rgba(0, 0, 0, 0.28);
}
.box.open {
  background: #141922;
  border-color: #2a3344;
  color: #d5dceb;
}
.box.open .num { font-size: 12px; opacity: 0.7; }
.box.won {
  background: linear-gradient(160deg, #f6d77a, #a97812);
  color: #1a1203;
  border-color: #fff1c2;
}
.box.pop { animation: pop 0.45s ease; }

@keyframes pop {
  0% { transform: scale(0.92); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.waitcard { grid-column: 1 / -1; text-align: center; padding: 28px 12px; }
.waitcard h3 {
  margin: 8px 0;
  font-family: Oswald, Impact, sans-serif;
  font-size: 32px;
  letter-spacing: 0.03em;
}

.history {
  display: flex;
  gap: 8px;
  overflow: auto;
  min-height: 24px;
}

.hist {
  flex: 0 0 auto;
  background: #121826;
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 120px;
}
.hist span, .hist em { display: block; color: var(--muted); font-size: 11px; font-style: normal; }
.hist b { display: block; margin: 2px 0; font-size: 14px; }
.hist.yes { box-shadow: inset 0 0 0 1px var(--gold); }
.hist.no { opacity: 0.72; }

.phase-note { margin: 0 0 8px; min-height: 2.6em; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stat { background: #10151f; border-radius: 12px; padding: 8px 10px; }
.stat span {
  display: block;
  color: #93a0b8;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat strong { display: block; margin-top: 2px; font-size: 14px; }

.schedule { display: flex; flex-wrap: wrap; gap: 6px; }
.schedule span {
  min-width: 28px;
  text-align: center;
  padding: 4px 6px;
  border-radius: 8px;
  background: #121826;
  font-size: 12px;
}
.schedule span.on { background: var(--gold); color: #1a1203; font-weight: 700; }

#offerForm { display: grid; gap: 8px; margin-top: 10px; }
#offerInput { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: auto; }
.bubble { display: inline-flex; align-items: center; gap: 2px; }
.chip.x { padding: 4px 7px; color: #ffb4b4; }
.bubble-add { display: flex; gap: 8px; margin: 8px 0 12px; }
.bubble-add input { flex: 1; min-width: 0; }
.bubble-add .btn { min-width: 46px; }
.setup.hidden { display: none; }
.hold {
  min-height: calc(100vh - 96px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px;
}
.hold-logo {
  width: min(280px, 62vw);
  height: auto;
  filter: drop-shadow(0 18px 36px rgba(255, 122, 0, 0.35));
}
.hold h1 {
  margin: 0;
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(36px, 6vw, 76px);
  letter-spacing: 0.03em;
}
.chip {
  border: 1px solid #314056;
  background: #121826;
  color: #e8eefc;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}
.chip:hover { border-color: var(--gold); }

#useHint, #revokeBtn, #sendOffer { width: 100%; margin-top: 8px; }
#useHint { white-space: normal; text-align: left; }

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
  color: #c5d0e2;
}
.log li { padding-bottom: 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }

.result-mini {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(240, 193, 77, 0.1);
}
.result-mini strong { display: block; font-size: 20px; margin: 4px 0; }
.result-mini p { margin: 4px 0; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  background: #1c2433;
  color: white;
}
.btn.gold { background: linear-gradient(180deg, #f6d77a, #d7a322); color: #1a1203; }
.btn.green { background: linear-gradient(180deg, #2fce86, #14915c); color: white; }
.btn.red { background: linear-gradient(180deg, #ff4d4d, #c41212); color: white; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.top-actions .btn { font-size: 14px; padding: 10px 14px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 6, 12, 0.86);
  display: grid;
  place-items: center;
  padding: 20px;
}

.sheet {
  width: min(640px, 100%);
  background: linear-gradient(180deg, #161b2b, #0e1320);
  border: 1px solid rgba(232, 184, 74, 0.35);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: slam 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.sheet.hot { border-color: rgba(240, 193, 77, 0.8); }
.sheet.miss {
  width: min(920px, 100%);
  border-color: #ff2a2a;
  background: radial-gradient(circle at 50% 28%, #5a1018, #12060a 72%);
  animation: slam 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), missShake 0.55s linear;
}
.miss-word {
  margin: 0;
  letter-spacing: 0.28em;
  color: #ffb4b4;
  font-size: 14px;
}
.miss-title {
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(72px, 14vw, 148px);
  line-height: 0.85;
  margin: 0;
  color: #ff2d2d;
  text-shadow: 0 0 28px rgba(255, 30, 30, 0.8);
}
.glass-break {
  position: fixed;
  inset: 0;
  z-index: 25;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}
@keyframes missShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-14px) rotate(-1deg); }
  40% { transform: translateX(14px) rotate(1deg); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}
.sheet h2, .sheet h3 { font-family: Oswald, Impact, sans-serif; letter-spacing: 0.03em; }
.mega {
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 1;
  margin: 8px 0;
}

.choices { display: flex; gap: 12px; margin-top: 18px; }
.choices .btn {
  flex: 1;
  min-height: 74px;
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(22px, 4vw, 32px);
  letter-spacing: 0.06em;
}

.facts { display: grid; gap: 8px; text-align: left; margin: 16px 0; }
.facts div { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px 12px; }
.facts span { display: block; color: #93a0b8; font-size: 12px; }
.facts strong { font-size: 18px; }

.final-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.final-box {
  background: linear-gradient(180deg, #3c7fe8, #123a86);
  border-radius: 16px;
  padding: 16px 8px;
}
.final-box span { display: block; font-size: 12px; letter-spacing: 0.08em; color: #d5e4ff; }
.final-box strong {
  display: block;
  font-family: Oswald, Impact, sans-serif;
  font-size: 48px;
  line-height: 1;
}

.stamp {
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(72px, 14vw, 150px);
  color: var(--red);
  letter-spacing: 0.06em;
  transform: rotate(-8deg);
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  animation: slam 0.3s ease;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 40;
  background: #111826;
  color: white;
  border: 1px solid rgba(240, 193, 77, 0.4);
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  animation: fall 1.7s linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(240deg); opacity: 0.2; }
}

@keyframes slam {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate .sheet { display: grid; gap: 10px; text-align: left; }
.gate h2 { margin: 0; font-size: 36px; }
.shake { animation: shake 0.35s linear; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.landing .hero {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  text-align: center;
}
.landing .lead,
.landing .steps { margin-left: auto; margin-right: auto; text-align: left; }
.landing .doors { text-align: left; }
.landing h1 {
  margin: 8px 0 12px;
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(64px, 12vw, 120px);
  line-height: 0.88;
  letter-spacing: 0.02em;
}
.landing h1 span { color: var(--red); }
.lead { font-size: 18px; color: #d5deee; max-width: 62ch; }
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.door {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: white;
  padding: 22px;
  border-radius: 22px;
  min-height: 160px;
  background: linear-gradient(180deg, rgba(28, 78, 180, 0.95), rgba(10, 24, 58, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.15s ease;
}
.door.alt { background: linear-gradient(180deg, rgba(176, 28, 42, 0.95), rgba(70, 10, 18, 0.96)); }
.door:hover { transform: translateY(-4px); }
.door small { letter-spacing: 0.16em; color: #ffe7a8; }
.door strong {
  font-family: Oswald, Impact, sans-serif;
  font-size: 40px;
  letter-spacing: 0.04em;
}
.door span { color: #e4ebf8; }
.steps {
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.steps li {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
  color: #d5deee;
}

.lobby {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.lobby .sheet { width: min(460px, 100%); display: grid; gap: 12px; text-align: left; }
.lobby h2 { margin: 0; font-family: Oswald, Impact, sans-serif; font-size: 40px; }
.wait-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.chat-box { display: grid; gap: 8px; margin-top: 14px; }
.chat-log {
  height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}
.msg { display: grid; gap: 2px; }
.msg b { font-size: 12px; letter-spacing: 0.04em; color: var(--gold); }
.msg.mine b { color: #9ec1ff; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; }
.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.queue-list .on { color: var(--gold); }

@media (max-width: 1180px) {
  body.role-admin .game { grid-template-columns: minmax(140px, 180px) minmax(0, 1fr) minmax(140px, 180px); }
  body.role-admin .offer-wrap { grid-column: 1 / -1; max-height: none; }
}

@media (max-width: 800px) {
  .game, body.role-admin .game { grid-template-columns: 1fr; }
  .stage-wrap { order: 1; }
  .lo-wrap { order: 2; }
  .hi-wrap { order: 3; }
  .offer-wrap { order: 4; }
  .board-wrap, .stage-wrap, .offer-wrap { max-height: none; }
  .stage { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .doors, .final-pair, .choices { grid-template-columns: 1fr; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
