:root {
  --bg: #070b16;
  --bg-2: #10182c;
  --card: rgba(16, 24, 44, 0.82);
  --line: rgba(245, 215, 110, 0.18);
  --gold: #f5d76e;
  --gold-2: #d4af37;
  --text: #f6f3ea;
  --muted: #9aa6c2;
  --blue: #6ea8ff;
  --green: #5ee0a8;
  --red: #ff7a90;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(245, 215, 110, 0.16), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(110, 168, 255, 0.14), transparent 45%),
    linear-gradient(180deg, var(--bg), #04060d 80%);
  color: var(--text);
  font-family: Pretendard, "Noto Sans KR", sans-serif;
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

a {
  color: var(--gold);
}

.wrap {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold), #8a6b16);
  color: #1a1404;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.35);
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  word-break: keep-all;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 28px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -0.04em;
}

.lead {
  color: var(--muted);
  line-height: 1.7;
  margin-top: 10px;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 11, 22, 0.7);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}

input:focus {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.12);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-gold {
  background: linear-gradient(135deg, #ffe38a, var(--gold-2));
  color: #1a1404;
}

.btn-blue {
  background: linear-gradient(135deg, #8cbcff, #3b78e7);
  color: #06101f;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: rgba(255, 122, 144, 0.16);
  color: var(--red);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.error {
  color: var(--red);
  min-height: 20px;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 22px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.players {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.player {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.game-stage {
  position: relative;
  min-height: min(68vh, 620px);
  height: auto;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 20%, rgba(245, 215, 110, 0.12), transparent 32%),
    linear-gradient(180deg, #0d1426, #070b16);
  user-select: none;
  padding: 72px 20px 28px;
}

.hud {
  position: absolute;
  inset: 14px 14px auto;
  display: flex;
  justify-content: space-between;
  z-index: 2;
  pointer-events: none;
}

.hud span,
.overlay-card {
  background: rgba(7, 11, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 13, 0.55);
  z-index: 3;
}

.overlay-card {
  border-radius: 20px;
  padding: 28px 36px;
  text-align: center;
  font-size: 42px;
}

.overlay.countdown .overlay-card {
  min-width: 1.2em;
  padding: 22px 32px;
  font-size: clamp(72px, 16vw, 140px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
}

.overlay-card.pop {
  animation: overlayPop 0.45s cubic-bezier(0.2, 1.25, 0.3, 1);
}

@keyframes overlayPop {
  0% { transform: scale(0.55); opacity: 0.35; }
  55% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.overlay-card small {
  display: block;
  margin-top: 8px;
  font-size: 16px;
  color: var(--muted);
  font-weight: 600;
}

.gate-path {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.word-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
}

.word-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.word-head strong {
  color: var(--gold);
}

.word-head span,
.word-count {
  font-weight: 800;
  color: #fff8d6;
}

.word-tiles {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.word-tile {
  width: 48px;
  height: 56px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  border: 1px solid rgba(245, 215, 110, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

.word-tile.empty em {
  opacity: 0.28;
  font-style: normal;
  font-weight: 800;
}

.word-tile.got {
  background: linear-gradient(135deg, #ffe38a, var(--gold-2));
  color: #1a1404;
  animation: tilePop 0.4s ease;
}

.word-tile.miss {
  background: linear-gradient(135deg, #ff9eae, #c23954);
  color: #fff;
  animation: tilePop 0.4s ease;
}

.word-tiles.compact {
  gap: 5px;
  margin-top: 8px;
}

.word-tiles.compact .word-tile {
  width: 28px;
  height: 32px;
  font-size: 13px;
  border-radius: 8px;
}

@keyframes tilePop {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.gate-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(245, 215, 110, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

.gate-dot.done {
  background: linear-gradient(135deg, #ffe38a, var(--gold-2));
  border-color: var(--gold);
}

.gate-dot.current {
  box-shadow: 0 0 0 4px rgba(245, 215, 110, 0.2);
  border-color: var(--gold);
}

.gate-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}

.gate-sub {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 22px;
}

.chests {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 0 6px;
}

.chest {
  width: 132px;
  min-height: 168px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 6px 2px;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.chest:disabled {
  cursor: default;
}

.chest-art {
  position: relative;
  width: 108px;
  height: 96px;
  perspective: 280px;
  filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.42));
}

.chest-art::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -8px;
  height: 12px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.38);
  filter: blur(5px);
  z-index: 0;
}

.chest .lid {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 38px;
  z-index: 3;
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.2, 0.85, 0.2, 1);
}

.chest .lid i {
  position: relative;
  display: block;
  height: 100%;
  font-style: normal;
  border-radius: 46px 46px 8px 8px / 78% 78% 12% 12%;
  background:
    linear-gradient(90deg, transparent 8%, rgba(255, 255, 255, 0.28) 22%, transparent 40%),
    linear-gradient(180deg, #fff1b0 0%, #f5d76e 28%, #d4af37 62%, #8a6314 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -6px 8px rgba(90, 50, 0, 0.28),
    0 4px 0 #6d4a0c;
}

.chest .lid i::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 10px;
  height: 7px;
  border-radius: 6px;
  background: linear-gradient(180deg, #fff6c8, #b8860b);
  box-shadow: 0 1px 0 rgba(80, 50, 0, 0.35);
}

.chest .lid i::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 16px;
  height: 8px;
  margin-left: -8px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, #ffe38a, #c9a227);
}

.chest .box {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  height: 62px;
  z-index: 1;
  border-radius: 7px 7px 14px 14px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 214, 120, 0.08) 0 10px,
      rgba(80, 45, 0, 0.12) 10px 12px
    ),
    linear-gradient(180deg, #e0a83a 0%, #b47818 42%, #7a4e0d 78%, #4a2e08 100%);
  box-shadow:
    inset 0 10px 0 rgba(255, 255, 255, 0.1),
    inset 0 -10px 14px rgba(0, 0, 0, 0.28),
    0 2px 0 #3a2408;
}

.chest .band {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  height: 11px;
  background: linear-gradient(180deg, #ffe9a3, #d4af37 45%, #8a6314);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #5a3a0a;
}

.chest .lock {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 20px;
  height: 24px;
  margin-left: -10px;
  border-radius: 4px 4px 10px 10px;
  background: linear-gradient(180deg, #fff6c8, #e0b84a 40%, #a67c16);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #5a3a0a;
  z-index: 2;
}

.chest .lock::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  border: 2px solid #3a2408;
  box-sizing: border-box;
}

.chest .lock::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 3px;
  height: 7px;
  margin-left: -1.5px;
  border-radius: 1px;
  background: #3a2408;
}

.chest strong {
  font-size: 15px;
  letter-spacing: 0.14em;
  font-weight: 800;
  color: #ffe38a;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.chest:not(:disabled):not(.opening):not(.rattle) .chest-art {
  animation: chestIdle 2.8s ease-in-out 0.45s infinite;
}

.chest.safe .lid i {
  background:
    linear-gradient(90deg, transparent 8%, rgba(255, 255, 255, 0.28) 22%, transparent 40%),
    linear-gradient(180deg, #d9ffe8 0%, #7eecc0 32%, #2db37a 68%, #0f6b45 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    0 4px 0 #0b4a30;
}

.chest.safe .box {
  background:
    repeating-linear-gradient(90deg, rgba(180, 255, 220, 0.1) 0 10px, rgba(0, 40, 24, 0.14) 10px 12px),
    linear-gradient(180deg, #4fd89a 0%, #1f9d66 48%, #0e5c3a 100%);
}

.chest.safe .band,
.chest.safe .lock {
  background: linear-gradient(180deg, #e7ffe8, #7ed9a8 50%, #2a8f62);
}

.chest.trap .lid i {
  background:
    linear-gradient(90deg, transparent 8%, rgba(255, 255, 255, 0.25) 22%, transparent 40%),
    linear-gradient(180deg, #ffd5dc 0%, #ff8aa0 32%, #d64561 68%, #8a1f38 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #6a1428;
}

.chest.trap .box {
  background:
    repeating-linear-gradient(90deg, rgba(255, 180, 190, 0.1) 0 10px, rgba(60, 0, 16, 0.16) 10px 12px),
    linear-gradient(180deg, #ff7a90 0%, #c23954 48%, #7a1830 100%);
}

.chest.trap .band,
.chest.trap .lock {
  background: linear-gradient(180deg, #ffd0d8, #e07084 50%, #a33a50);
}

.chest.picked {
  transform: scale(1.08);
  z-index: 2;
}

.chest.opening .lid {
  transform: rotateX(-118deg) translateY(-2px);
}

.chest.opening .lock {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chest.opening .box::after {
  content: "";
  position: absolute;
  inset: 10px 12px 12px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 236, 170, 0.9), rgba(245, 215, 110, 0.15) 62%, transparent 75%);
  animation: chestInnerGlow 0.7s ease;
}

.chest.trap.opening .box::after {
  background: radial-gradient(circle at 50% 40%, rgba(255, 170, 180, 0.9), rgba(255, 90, 110, 0.18) 62%, transparent 75%);
}

.chest .glyph {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(18px) scale(0.55);
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 4;
}

.chest.opening .glyph {
  opacity: 1;
  transform: translateY(-6px) scale(1);
  transition: 0.4s 0.16s cubic-bezier(0.2, 1.1, 0.3, 1);
}

.chest.opening .box,
.chest.opening strong {
  opacity: 1;
}

.chest.opening strong {
  opacity: 0.35;
}

.chest.safe .glyph {
  color: #fff8d6;
}

.chest.trap .glyph {
  color: #fff;
}

.chest.rattle {
  animation: rattle 0.12s linear 6;
}

.chest.shuffle-in {
  animation: dropIn 0.45s ease both;
}

.game-stage.final-gate {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 90, 90, 0.18), transparent 36%),
    radial-gradient(circle at 50% 20%, rgba(245, 215, 110, 0.16), transparent 32%),
    linear-gradient(180deg, #1a0d16, #070b16);
  box-shadow: inset 0 0 80px rgba(255, 80, 80, 0.12);
}

.game-stage.final-wait {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 214, 90, 0.28), transparent 28%),
    radial-gradient(circle at 18% 80%, rgba(255, 70, 90, 0.22), transparent 34%),
    radial-gradient(circle at 86% 70%, rgba(245, 215, 110, 0.16), transparent 32%),
    linear-gradient(180deg, #2a1018, #07060d 72%);
  box-shadow:
    inset 0 0 120px rgba(255, 70, 90, 0.22),
    inset 0 0 40px rgba(245, 215, 110, 0.12);
  animation: finalBgPulse 2.2s ease-in-out infinite;
}

.game-stage.final-wait.final-strike {
  animation: shake 0.38s ease, finalBgPulse 2.2s ease-in-out infinite;
}

.final-wait .gate-title::before {
  content: "운명의 순간";
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.42em;
  color: #ff9eae;
  text-shadow: 0 0 18px rgba(255, 90, 110, 0.7);
  animation: finalKicker 1.2s ease-in-out infinite;
}

.final-wait .gate-title {
  font-size: clamp(22px, 4vw, 30px);
  color: #fff4c2;
  text-shadow:
    0 0 18px rgba(245, 215, 110, 0.75),
    0 0 42px rgba(255, 90, 90, 0.35);
  animation: finalTitlePulse 1.6s ease-in-out infinite;
}

.final-wait .gate-sub {
  color: #ffd0d8;
}

.final-wait .word-board {
  box-shadow: 0 0 28px rgba(245, 215, 110, 0.22);
  animation: finalBoardGlow 1.8s ease-in-out infinite;
}

.final-wait .chests {
  position: relative;
  z-index: 1;
}

.final-wait .chests::before,
.final-wait .chests::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, 92vw);
  height: min(220px, 42vw);
  transform: translate(-50%, -52%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.final-wait .chests::before {
  background: conic-gradient(
    from 0deg,
    transparent 0 8%,
    rgba(245, 215, 110, 0.55) 12%,
    transparent 22%,
    transparent 50%,
    rgba(255, 90, 110, 0.5) 58%,
    transparent 70%
  );
  filter: blur(10px);
  animation: finalHaloSpin 7s linear infinite;
}

.final-wait .chests::after {
  border: 2px solid rgba(245, 215, 110, 0.28);
  box-shadow: 0 0 30px rgba(255, 90, 90, 0.25), inset 0 0 24px rgba(245, 215, 110, 0.12);
  animation: finalRing 2.4s ease-in-out infinite;
}

.final-wait .chest {
  z-index: 1;
}

.game-stage.final-gate .chest:not(.opening):not(.rattle) .chest-art {
  animation: bossPulse 1.4s ease-in-out infinite;
}

.final-wait .chest:not(:disabled):not(.opening):not(.rattle) .chest-art {
  animation: finalChestGlow 2.4s ease-in-out infinite;
}

.final-wait .chest:nth-child(1) .chest-art { animation-delay: 0s; }
.final-wait .chest:nth-child(2) .chest-art { animation-delay: 0.6s; }
.final-wait .chest:nth-child(3) .chest-art { animation-delay: 1.2s; }
.final-wait .chest:nth-child(4) .chest-art { animation-delay: 1.8s; }

.game-stage.final-gate .chest.shuffle-in {
  animation: dropIn 0.45s ease both;
}

.final-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

.final-vignette {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(circle at 50% 42%, transparent 28%, rgba(0, 0, 0, 0.55) 78%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03) 0 2px,
      transparent 2px 5px
    );
  animation: finalVignette 2.6s ease-in-out infinite;
}

.final-rays {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 140%;
  height: 140%;
  transform: translate(-50%, -50%);
  background: conic-gradient(
    from 90deg,
    transparent 0 6%,
    rgba(245, 215, 110, 0.16) 8%,
    transparent 14%,
    transparent 28%,
    rgba(255, 90, 110, 0.14) 32%,
    transparent 40%
  );
  animation: finalSpin 14s linear infinite;
  mix-blend-mode: screen;
}

.final-ring {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(420px, 80%);
  height: 160px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 120, 0.35);
  box-shadow: 0 0 40px rgba(245, 215, 110, 0.2);
  animation: finalRing 2s ease-in-out infinite;
}

.final-scan {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 18%;
  background: linear-gradient(180deg, transparent, rgba(255, 90, 110, 0.16), transparent);
  animation: finalScan 2.8s linear infinite;
}

.final-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.55), rgba(255, 214, 120, 0.12) 36%, transparent 62%);
  opacity: 0;
}

.final-flash.on {
  animation: finalFlash 0.42s ease;
}

.final-ember {
  position: absolute;
  bottom: -8%;
  border-radius: 40% 40% 20% 20%;
  opacity: 0.85;
  filter: blur(0.2px);
  animation: finalEmber linear infinite;
  box-shadow: 0 0 8px currentColor;
}

.final-bolt {
  position: absolute;
  width: 4px;
  height: var(--bh, 56%);
  background: linear-gradient(180deg, #fff, #ffe38a 30%, #ff7a90 80%, transparent);
  clip-path: polygon(40% 0, 72% 18%, 48% 18%, 80% 46%, 42% 46%, 100% 100%, 0 58%, 38% 58%, 12% 32%, 36% 32%);
  box-shadow: 0 0 16px #fff, 0 0 28px #ff7a90;
  animation: finalBolt 0.38s ease-out forwards;
  transform: rotate(var(--br, -8deg));
}

.game-msg.final {
  color: #ffe38a;
  letter-spacing: 0.04em;
  text-shadow: 0 0 16px rgba(245, 215, 110, 0.55);
  animation: finalKicker 1.1s ease-in-out infinite;
}

.game-stage.flash-ok {
  animation: flashOk 0.45s ease;
}

.game-stage.flash-fail {
  animation: flashFail 0.55s ease;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.spark {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: spark 0.8s ease-out forwards;
}

.spark.fail {
  background: var(--red);
}

.spark.ok {
  background: #8ef0c0;
}

.slam {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 5;
  pointer-events: none;
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: slamIn 0.55s ease;
}

.slam.ok {
  color: var(--gold);
}

.slam.fail {
  color: var(--red);
}

.game-msg {
  min-height: 28px;
  text-align: center;
  margin-top: 18px;
  font-weight: 800;
}

.game-msg.fail {
  color: var(--red);
}

.game-msg.ok {
  color: var(--green);
}

.game-stage.shake {
  animation: shake 0.45s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes rattle {
  0% { transform: rotate(0) translateX(0); }
  25% { transform: rotate(-6deg) translateX(-3px); }
  75% { transform: rotate(6deg) translateX(3px); }
  100% { transform: rotate(0) translateX(0); }
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-28px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes bossPulse {
  0%, 100% { filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.42)) drop-shadow(0 0 0 rgba(255, 90, 90, 0)); }
  50% { filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.42)) drop-shadow(0 0 18px rgba(255, 90, 90, 0.55)); }
}

@keyframes chestIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes chestInnerGlow {
  0% { opacity: 0; }
  40% { opacity: 1; }
  100% { opacity: 0.85; }
}

@keyframes flashOk {
  0% { box-shadow: inset 0 0 0 0 rgba(245, 215, 110, 0); }
  40% { box-shadow: inset 0 0 80px rgba(245, 215, 110, 0.35); }
  100% { box-shadow: inset 0 0 0 0 rgba(245, 215, 110, 0); }
}

@keyframes flashFail {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 70, 90, 0); }
  35% { box-shadow: inset 0 0 90px rgba(255, 70, 90, 0.4); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 70, 90, 0); }
}

@keyframes spark {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.2);
    opacity: 0;
  }
}

@keyframes slamIn {
  0% { transform: scale(2.4); opacity: 0; }
  35% { transform: scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.9); }
}

@keyframes finalBgPulse {
  0%, 100% { filter: saturate(1); }
  50% { filter: saturate(1.25) brightness(1.08); }
}

@keyframes finalSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes finalHaloSpin {
  from { transform: translate(-50%, -52%) rotate(0deg); }
  to { transform: translate(-50%, -52%) rotate(360deg); }
}

@keyframes finalRing {
  0%, 100% { opacity: 0.45; transform: translate(-50%, -50%) scale(0.92); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes finalScan {
  0% { top: -12%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { top: 108%; opacity: 0; }
}

@keyframes finalVignette {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes finalFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes finalEmber {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  12% { opacity: 0.95; }
  100% { transform: translateY(-118vh) scale(0.4); opacity: 0; }
}

@keyframes finalBolt {
  0% { opacity: 0; transform: scaleY(0.2); }
  25% { opacity: 1; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1.05); }
}

@keyframes finalTitlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes finalKicker {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes finalBoardGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(245, 215, 110, 0.08); }
  50% { box-shadow: 0 0 32px rgba(245, 215, 110, 0.32); }
}

@keyframes finalChestGlow {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.42)) drop-shadow(0 0 0 rgba(245, 215, 110, 0));
  }
  50% {
    transform: translateY(-8px) scale(1.06);
    filter: drop-shadow(0 18px 20px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 22px rgba(245, 215, 110, 0.8));
  }
}

@media (prefers-reduced-motion: reduce) {
  .final-wait,
  .final-wait .gate-title,
  .final-wait .gate-title::before,
  .final-wait .gate-sub,
  .final-wait .chests::before,
  .final-wait .chests::after,
  .final-wait .word-board,
  .final-ember,
  .final-rays,
  .final-scan,
  .final-ring,
  .game-msg.final {
    animation: none !important;
  }
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  will-change: transform;
}

.rank-stage {
  text-align: right;
  white-space: nowrap;
}

.stage-pips {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.stage-pips span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(245, 215, 110, 0.25);
}

.stage-pips span.done {
  background: linear-gradient(135deg, #ffe38a, var(--gold-2));
  border-color: var(--gold);
}

.stage-pips span.now {
  background: var(--blue);
  border-color: #8cbcff;
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.25);
  animation: pipPulse 1s ease-in-out infinite;
}

.rank-row.rank-up {
  box-shadow: 0 0 0 1px rgba(94, 224, 168, 0.55), 0 8px 24px rgba(94, 224, 168, 0.2);
}

.rank-row.rank-down {
  box-shadow: 0 0 0 1px rgba(255, 122, 144, 0.5), 0 8px 24px rgba(255, 122, 144, 0.16);
}

.rank-row.rank-enter {
  animation: dropIn 0.4s ease;
}

.live-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding: 22px 26px;
  border-radius: 22px;
  border: 1px solid rgba(245, 215, 110, 0.35);
  background: linear-gradient(90deg, rgba(245, 215, 110, 0.16), rgba(16, 24, 44, 0.7));
}

.live-count {
  text-align: right;
  color: var(--muted);
}

.live-count b {
  display: block;
  font-size: 42px;
  color: var(--gold);
  line-height: 1;
}

.live-standings {
  margin-top: 14px;
  text-align: center;
  font-weight: 800;
  color: var(--gold);
}

.rank-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 14px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe38a, var(--gold-2));
  color: #1a1404;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.35s ease;
}

@keyframes pipPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.rank-row.first,
.rank-row.second,
.rank-row.third {
  position: relative;
  overflow: visible;
}

.rank-row.first {
  border-color: rgba(245, 215, 110, 0.75);
  background:
    linear-gradient(90deg, rgba(245, 215, 110, 0.22), rgba(255, 255, 255, 0.05) 55%, rgba(245, 215, 110, 0.08));
  box-shadow:
    0 0 0 1px rgba(245, 215, 110, 0.35),
    0 12px 36px rgba(245, 215, 110, 0.18);
  animation: podiumGlowGold 2.4s ease-in-out infinite;
}

.rank-row.second {
  border-color: rgba(210, 220, 235, 0.85);
  background:
    linear-gradient(90deg, rgba(210, 220, 235, 0.2), rgba(255, 255, 255, 0.05) 55%, rgba(192, 200, 220, 0.08));
  box-shadow:
    0 0 0 1px rgba(210, 220, 235, 0.3),
    0 10px 28px rgba(192, 200, 220, 0.14);
  animation: podiumGlowSilver 2.8s ease-in-out infinite;
}

.rank-row.third {
  border-color: rgba(205, 127, 50, 0.8);
  background:
    linear-gradient(90deg, rgba(205, 127, 50, 0.22), rgba(255, 255, 255, 0.05) 55%, rgba(180, 110, 50, 0.1));
  box-shadow:
    0 0 0 1px rgba(205, 127, 50, 0.32),
    0 10px 28px rgba(205, 127, 50, 0.16);
  animation: podiumGlowBronze 3s ease-in-out infinite;
}

.podium-sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.podium-sheen::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.38), transparent);
  animation: podiumShine 2.6s ease-in-out infinite;
}

.second .podium-sheen::after {
  animation-duration: 3.2s;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
}

.podium-glints {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.podium-glints i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px #ffe38a;
  animation: podiumTwinkle 1.4s ease-in-out infinite;
}

.second .podium-glints i {
  box-shadow: 0 0 10px #d7e3f5;
}

.podium-glints i:nth-child(1) { top: 12%; left: 18%; animation-delay: 0s; }
.podium-glints i:nth-child(2) { top: 28%; right: 16%; animation-delay: 0.25s; }
.podium-glints i:nth-child(3) { bottom: 18%; left: 32%; animation-delay: 0.5s; }
.podium-glints i:nth-child(4) { top: 14%; right: 38%; animation-delay: 0.75s; }
.podium-glints i:nth-child(5) { bottom: 22%; right: 10%; animation-delay: 1s; }
.podium-glints i:nth-child(6) { top: 48%; left: 8%; animation-delay: 1.15s; }

.medal {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
}

.first .medal {
  background: linear-gradient(135deg, #fff4c2, #f5d76e 40%, #b8860b);
  color: #1a1404;
  box-shadow: 0 0 18px rgba(245, 215, 110, 0.7);
  animation: medalPulse 1.8s ease-in-out infinite;
}

.second .medal {
  background: linear-gradient(135deg, #ffffff, #cfd8e6 42%, #7f8fa3);
  color: #1a1404;
  box-shadow: 0 0 14px rgba(207, 216, 230, 0.55);
  animation: medalPulse 2.2s ease-in-out infinite;
}

.third .medal {
  background: linear-gradient(135deg, #f3d1a4, #cd7f32 42%, #8a4b12);
  color: #1a1404;
  box-shadow: 0 0 14px rgba(205, 127, 50, 0.5);
  animation: medalPulse 2.4s ease-in-out infinite;
}

.first .medal::before,
.second .medal::before,
.third .medal::before {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  line-height: 1;
  animation: crownBob 1.6s ease-in-out infinite;
}

.first .medal::before { content: "👑"; }
.second .medal::before { content: "✦"; color: #eef3fb; text-shadow: 0 0 8px #fff; }
.third .medal::before { content: "◆"; color: #f3d1a4; text-shadow: 0 0 8px rgba(205, 127, 50, 0.8); }

.rank-row.podium-in {
  animation: podiumPop 0.7s cubic-bezier(0.2, 1.4, 0.3, 1);
}

@keyframes podiumGlowGold {
  0%, 100% { box-shadow: 0 0 0 1px rgba(245, 215, 110, 0.35), 0 12px 36px rgba(245, 215, 110, 0.16); }
  50% { box-shadow: 0 0 0 1px rgba(255, 236, 170, 0.8), 0 16px 48px rgba(245, 215, 110, 0.38); }
}

@keyframes podiumGlowSilver {
  0%, 100% { box-shadow: 0 0 0 1px rgba(210, 220, 235, 0.3), 0 10px 28px rgba(192, 200, 220, 0.12); }
  50% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55), 0 14px 36px rgba(192, 200, 220, 0.3); }
}

@keyframes podiumGlowBronze {
  0%, 100% { box-shadow: 0 0 0 1px rgba(205, 127, 50, 0.32), 0 10px 28px rgba(205, 127, 50, 0.14); }
  50% { box-shadow: 0 0 0 1px rgba(243, 209, 164, 0.7), 0 14px 36px rgba(205, 127, 50, 0.32); }
}

@keyframes podiumShine {
  0% { transform: translateX(0); opacity: 0; }
  18% { opacity: 1; }
  55% { transform: translateX(380%); opacity: 0.15; }
  100% { transform: translateX(380%); opacity: 0; }
}

@keyframes podiumTwinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.25); }
}

@keyframes medalPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes crownBob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -4px); }
}

@keyframes podiumPop {
  0% { transform: scale(0.92); filter: brightness(1.4); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); filter: none; }
}

.prize-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--gold);
}

.admin-page .wrap {
  width: min(1080px, calc(100% - 32px));
}

.admin-login {
  max-width: 460px;
  margin: 36px auto 0;
}

.admin-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.admin-status-bar h2 {
  font-size: 28px;
  letter-spacing: -0.03em;
  margin-top: 4px;
}

.admin-stats {
  margin: 0;
  min-width: 360px;
}

.admin-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 860px) {
  .admin-grid {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.admin-actions .btn {
  min-height: 48px;
  padding: 14px 18px;
}

.admin-actions .btn-gold {
  flex: 1;
  min-width: 140px;
}

.slot-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 16px;
}

.slot-picker button {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.slot-picker button.active {
  border-color: rgba(245, 215, 110, 0.8);
  background: linear-gradient(135deg, rgba(245, 215, 110, 0.28), rgba(212, 175, 55, 0.12));
  color: var(--gold);
  box-shadow: 0 0 0 1px rgba(245, 215, 110, 0.25);
}

.admin-danger {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-settings {
  margin-top: 8px;
}

.admin-prize-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-prize-row[data-slots="1"] {
  grid-template-columns: 1fr;
}

.admin-prize-row[data-slots="3"] {
  grid-template-columns: 1fr;
}

.admin-players-card {
  margin-top: 16px;
}

.admin-players-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-player-list {
  display: grid;
  margin-top: 8px;
}

.admin-player {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) auto minmax(120px, 0.8fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-player:last-child {
  border-bottom: 0;
}

.admin-player-who {
  display: grid;
  gap: 4px;
}

.admin-player-who span {
  color: var(--muted);
  font-size: 13px;
}

.admin-player-record {
  font-weight: 800;
  color: var(--gold);
  text-align: right;
}

.admin-player .btn {
  padding: 8px 12px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .admin-status-bar,
  .admin-prize-row,
  .admin-player {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .admin-stats {
    min-width: 0;
    width: 100%;
  }

  .admin-player-record {
    text-align: left;
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.board-page {
  font-size: 22px;
}

.board-page .wrap {
  width: min(1680px, calc(100% - 48px));
  padding: 18px 0 28px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
}

.board-page .logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  font-size: 28px;
}

.board-logo svg {
  width: 34px;
  height: 34px;
  color: #1a1404;
}

.board-page .brand strong {
  font-size: 34px;
  letter-spacing: -0.04em;
}

.board-page .brand small {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  color: var(--gold);
  font-weight: 700;
}

.board-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.board-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  padding: 12px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-size: 22px;
  font-weight: 800;
}

.board-chip-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9aa6c2;
  box-shadow: 0 0 0 4px rgba(154, 166, 194, 0.18);
}

.board-page[data-status="countdown"] .board-chip-dot,
.board-page[data-status="playing"] .board-chip-dot {
  background: #5ee0a8;
  box-shadow: 0 0 0 4px rgba(94, 224, 168, 0.22), 0 0 12px rgba(94, 224, 168, 0.7);
  animation: boardDotPulse 1.2s ease-in-out infinite;
}

.board-page[data-status="finished"] .board-chip-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(245, 215, 110, 0.22);
}

.board-chip-count {
  gap: 8px;
  padding: 8px 18px 8px 16px;
}

.board-chip-count b {
  font-size: 32px;
  line-height: 1;
  color: var(--gold);
}

.board-chip-count span {
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
}

@keyframes boardDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.board-list-card {
  padding: 16px;
}

.board-page .live-board {
  gap: 14px;
  padding-top: 12px;
}

.board-page .rank-row {
  grid-template-columns: 88px minmax(160px, 1.1fr) minmax(260px, 1.5fr) auto;
  gap: 18px;
  padding: 16px 22px;
}

.board-page .medal {
  width: 72px;
  height: 72px;
  font-size: 32px;
}

.board-page .rank-who strong {
  font-size: 34px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.board-page .rank-company {
  margin-top: 4px;
  font-size: 20px;
  color: var(--muted);
  font-weight: 600;
}

.board-page .rank-stage {
  font-size: 28px;
  font-weight: 800;
}

.board-page .word-tiles {
  justify-content: flex-end;
}

.board-page .word-tile {
  width: 56px;
  height: 64px;
  font-size: 28px;
  border-radius: 14px;
}

.board-page .prize-tag {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 800;
}

.board-empty {
  margin: 0;
  padding: 72px 24px;
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  color: var(--muted);
}

.board-page .first .medal::before,
.board-page .second .medal::before,
.board-page .third .medal::before {
  font-size: 28px;
  top: -22px;
}

.board-page.revealed .rank-row.first {
  animation: podiumGlowGold 1.4s ease-in-out infinite, podiumPop 0.8s ease;
}

.board-page.revealed .rank-row.second {
  animation: podiumGlowSilver 1.8s ease-in-out infinite;
}

.board-page.revealed .rank-row.third {
  animation: podiumGlowBronze 2s ease-in-out infinite;
}

.winner-fx {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 13, 0.72);
  overflow: hidden;
}

.winner-fx.hidden {
  display: none;
}

.winner-fx-card {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: winnerCardIn 0.7s cubic-bezier(0.2, 1.2, 0.3, 1);
}

.winner-kicker {
  margin: 0 0 18px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.winner-spots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: min(920px, calc(100vw - 48px));
}

.winner-spots[data-slots="1"] {
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
}

.winner-spots[data-slots="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(1180px, calc(100vw - 48px));
}

.winner-spots[data-slots="3"] .winner-spot {
  padding: 28px 18px 24px;
}

.winner-spots[data-slots="3"] .winner-spot b {
  font-size: clamp(32px, 4.2vw, 56px);
}

.winner-spot {
  position: relative;
  padding: 36px 28px 32px;
  border-radius: 28px;
  overflow: hidden;
}

.winner-spot.first {
  background: linear-gradient(180deg, rgba(245, 215, 110, 0.28), rgba(16, 24, 44, 0.85));
  border: 2px solid rgba(245, 215, 110, 0.8);
  box-shadow: 0 0 40px rgba(245, 215, 110, 0.35);
  animation: winnerSpotGold 1.6s ease-in-out infinite;
}

.winner-spot.second {
  background: linear-gradient(180deg, rgba(210, 220, 235, 0.22), rgba(16, 24, 44, 0.85));
  border: 2px solid rgba(210, 220, 235, 0.7);
  box-shadow: 0 0 28px rgba(192, 200, 220, 0.28);
  animation: winnerSpotSilver 1.8s ease-in-out infinite;
}

.winner-spot.third {
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.24), rgba(16, 24, 44, 0.85));
  border: 2px solid rgba(205, 127, 50, 0.75);
  box-shadow: 0 0 28px rgba(205, 127, 50, 0.28);
  animation: winnerSpotBronze 2s ease-in-out infinite;
}

.winner-spot > span {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
}

.winner-spot.first > span { color: var(--gold); }
.winner-spot.second > span { color: #d7e3f5; }
.winner-spot.third > span { color: #f3d1a4; }

.winner-spot b {
  display: block;
  font-size: clamp(42px, 6vw, 72px);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.winner-spot small {
  display: block;
  margin-top: 12px;
  font-size: 22px;
  color: var(--muted);
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
  animation: fireworkBurst 1.1s ease-out forwards;
}

@keyframes winnerCardIn {
  from { transform: scale(0.7) translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes winnerSpotGold {
  0%, 100% { box-shadow: 0 0 30px rgba(245, 215, 110, 0.28); }
  50% { box-shadow: 0 0 64px rgba(245, 215, 110, 0.55); }
}

@keyframes winnerSpotSilver {
  0%, 100% { box-shadow: 0 0 22px rgba(192, 200, 220, 0.22); }
  50% { box-shadow: 0 0 48px rgba(230, 236, 245, 0.42); }
}

@keyframes winnerSpotBronze {
  0%, 100% { box-shadow: 0 0 22px rgba(205, 127, 50, 0.22); }
  50% { box-shadow: 0 0 48px rgba(243, 209, 164, 0.42); }
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.85; }
}

@keyframes fireworkBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--fx), var(--fy)) scale(0.2); opacity: 0; }
}

.board-title {
  text-align: center;
  margin: 10px 0 28px;
}

.winners {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.winner-card {
  padding: 24px;
  border-radius: 22px;
  border: 1px solid var(--line);
  min-height: 160px;
}

.winner-card.first {
  background: linear-gradient(180deg, rgba(245, 215, 110, 0.18), rgba(16, 24, 44, 0.6));
}

.winner-card.second {
  background: linear-gradient(180deg, rgba(192, 200, 220, 0.18), rgba(16, 24, 44, 0.6));
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
  }

  .chest:hover:not(:disabled) {
    transform: translateY(-8px) scale(1.04);
  }

  .chest:hover:not(:disabled) .lid {
    transform: rotateX(-26deg);
  }
}

@media (max-width: 1100px) {
  .board-page .rank-row {
    grid-template-columns: 72px 1fr auto;
  }

  .board-page .word-tiles {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .wrap {
    width: calc(100% - 20px);
    padding: 14px 0 calc(24px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin-bottom: 14px;
    align-items: flex-start;
  }

  .logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .pill {
    margin-top: 2px;
  }

  .brand strong {
    font-size: 16px;
    line-height: 1.3;
  }

  .brand small {
    font-size: 12px;
    line-height: 1.45;
  }

  body:not(.board-page) .brand small {
    display: none;
  }

  .hud {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 12px;
    gap: 6px;
  }

  .hud span {
    min-width: 0;
    text-align: center;
    padding: 7px 8px;
    font-size: 13px;
  }

  #hudCombo,
  .hud span:last-child {
    display: none;
  }

  .word-tile {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: calc((100% - 24px) / 5);
    height: 48px;
    font-size: 18px;
  }

  .word-tiles {
    width: 100%;
    gap: 6px;
  }

  .gate-sub {
    font-size: 13px;
    margin: 6px 0 16px;
    padding: 0 4px;
    line-height: 1.5;
  }

  .card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .stats,
  .winners,
  .live-banner,
  .board-head,
  .admin-status-bar,
  .admin-prize-row,
  .admin-player {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .stats {
    gap: 8px;
  }

  .stat {
    padding: 10px 8px;
    font-size: 12px;
  }

  .stat b {
    font-size: 16px;
  }

  .btn {
    width: 100%;
    min-height: 48px;
  }

  .row .btn {
    width: auto;
    flex: 1;
  }

  input {
    font-size: 16px;
    padding: 14px;
  }

  .game-stage {
    min-height: 0;
    padding: 14px 12px 18px;
    border-radius: 18px;
  }

  .word-board {
    margin: 0 0 12px;
    gap: 8px;
  }

  .gate-title {
    font-size: 18px;
  }

  .chests {
    gap: 10px;
  }

  .chest {
    width: calc(50% - 8px);
    max-width: 168px;
    min-height: 148px;
  }

  .chest-art {
    width: 96px;
    height: 86px;
  }

  .final-ember:nth-child(n + 26) {
    display: none;
  }

  .final-rays {
    opacity: 0.4;
  }

  .overlay-card {
    font-size: 32px;
    padding: 20px 22px;
    margin: 0 16px;
  }

  .game-msg {
    font-size: 14px;
    min-height: 22px;
  }

  .rank-row {
    grid-template-columns: 44px 1fr;
    gap: 10px;
    padding: 12px;
  }

  .rank-stage {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }

  .medal {
    width: 40px;
    height: 40px;
  }

  .first .medal::before,
  .second .medal::before,
  .third .medal::before {
    font-size: 13px;
    top: -12px;
  }

  .admin-stats {
    min-width: 0;
    width: 100%;
  }

  .admin-player-record {
    text-align: left;
  }

  .admin-actions .btn,
  .admin-danger .btn {
    flex: 1 1 100%;
  }

  .board-page {
    font-size: 16px;
  }

  .board-page .wrap {
    width: calc(100% - 20px);
  }

  .board-page .logo {
    width: 44px;
    height: 44px;
  }

  .board-logo svg {
    width: 22px;
    height: 22px;
  }

  .board-page .brand strong {
    font-size: 18px;
  }

  .board-page .brand small {
    font-size: 13px;
  }

  .board-chip {
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 12px;
  }

  .board-chip-count b {
    font-size: 20px;
  }

  .board-chip-count span {
    font-size: 13px;
  }

  .board-page .rank-row {
    grid-template-columns: 52px 1fr;
    padding: 12px;
  }

  .board-page .medal {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .board-page .rank-who strong {
    font-size: 18px;
  }

  .board-page .rank-company {
    font-size: 13px;
  }

  .board-page .word-tile {
    width: 34px;
    height: 40px;
    font-size: 16px;
  }

  .board-page .rank-stage {
    font-size: 16px;
  }

  .winner-spots,
  .winner-spots[data-slots="1"],
  .winner-spots[data-slots="3"] {
    grid-template-columns: 1fr;
  }

  .winner-spot b {
    font-size: 36px;
  }
}
