:root {
  --cyan: #5ef2ff;
  --magenta: #ff3dbe;
  --violet: #8d6bff;
  --gold: #ffd56a;
  --ink: #090714;
  --glass: rgba(12, 8, 28, 0.62);
  --line: rgba(214, 232, 255, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05040c;
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  color: #f4f7ff;
}

body.transparent,
body.transparent #stage {
  background: transparent;
}

body.transparent .grid { opacity: 0.25; }

#fit {
  width: 1080px;
  height: 1920px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(var(--fit, 1));
  transform-origin: center center;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 1080px;
  height: 1920px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 42px 48px 36px;
  overflow: hidden;
  background:
    radial-gradient(880px 640px at 8% -8%, rgba(255, 61, 190, 0.28), transparent 62%),
    radial-gradient(760px 820px at 112% 18%, rgba(94, 242, 255, 0.16), transparent 56%),
    radial-gradient(680px 680px at 50% 112%, rgba(141, 107, 255, 0.24), transparent 52%),
    linear-gradient(180deg, #0b0818 0%, #140c28 46%, #07060f 100%);
}

#stage.urgent {
  box-shadow: inset 0 0 0 3px rgba(255, 77, 109, 0.35);
}

#stage.shake { animation: shake 0.45s ease; }

#waves, .grid, .vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#waves { z-index: 0; }

.grid {
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.11) 1.1px, transparent 1.2px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 78%);
}

.vignette {
  z-index: 0;
  background: radial-gradient(circle at 50% 42%, transparent 0 36%, rgba(0, 0, 0, 0.28) 100%);
}

.top, .crown, .hero, .chain, .board { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  letter-spacing: 0.28em;
  font-weight: 700;
  color: var(--cyan);
}

.kicker.gold { color: var(--gold); }

.on-air {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff4d6d;
  box-shadow: 0 0 14px #ff4d6d;
  animation: blink 1.4s steps(2, end) infinite;
}

.brand h1 {
  margin: 6px 0 0;
  font-family: Syne, Outfit, sans-serif;
  font-size: 78px;
  line-height: 0.86;
  letter-spacing: -0.045em;
}

.brand p {
  margin: 8px 0 0;
  letter-spacing: 0.46em;
  font-size: 20px;
  font-weight: 700;
  color: rgba(244, 247, 255, 0.72);
}

.stats { display: flex; gap: 12px; }

.stat {
  min-width: 148px;
  padding: 12px 16px 10px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
}

.stat span {
  display: block;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: rgba(244, 247, 255, 0.62);
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-family: Syne, Outfit, sans-serif;
  font-size: 42px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat.slim { min-width: 110px; }

.combo.hot strong {
  color: var(--magenta);
  text-shadow: 0 0 18px rgba(255, 61, 190, 0.8);
}

.crown {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 22px;
  border-radius: 32px;
  background: linear-gradient(90deg, rgba(255, 213, 106, 0.14), rgba(12, 8, 28, 0.4));
  border: 1px solid rgba(255, 213, 106, 0.4);
  box-shadow: 0 0 40px rgba(255, 213, 106, 0.16), inset 0 1px 0 rgba(255, 244, 200, 0.4);
}

.crown[hidden], #ice[hidden], #broken[hidden], #paused[hidden], #unlock[hidden] {
  display: none !important;
}

.vinyl-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  flex: none;
  animation: pop 0.55s ease;
}

.vinyl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 46px, #e7c56a 47px, #e7c56a 52px, transparent 53px),
    repeating-radial-gradient(circle at 50% 50%, #191924 0 6px, #07070d 7px 10px);
  box-shadow: 0 0 0 6px rgba(255, 213, 106, 0.28), 0 0 32px rgba(255, 213, 106, 0.45);
  animation: spin 3.4s linear infinite;
}

.vinyl-wrap img {
  position: absolute;
  width: 72px;
  height: 72px;
  left: 48px;
  top: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffe7a3;
  background: #1a1230;
}

.crown-svg {
  position: absolute;
  width: 86px;
  left: 41px;
  top: -16px;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
}

.crown-name {
  font-family: Syne, Outfit, sans-serif;
  font-size: 54px;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.crown-mult {
  margin-top: 8px;
  letter-spacing: 0.18em;
  font-size: 16px;
  color: var(--gold);
}

.hero, .chain, .board {
  border-radius: 32px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px);
}

.hero { padding: 26px 32px 22px; text-align: center; }

.hero-label, .section-title, .score-hint {
  letter-spacing: 0.22em;
  font-size: 15px;
  font-weight: 700;
  color: rgba(244, 247, 255, 0.58);
}

.word {
  min-height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0 4px;
  font-family: Syne, Outfit, sans-serif;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  text-shadow: 0 0 24px rgba(94, 242, 255, 0.25);
}

.word.pop { animation: pop 0.35s ease; }

.letter { display: inline-block; padding: 0 0.015em; }

.letter.target {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.18em;
  height: 1.18em;
  margin: 0 0.04em 0 0.08em;
  border-radius: 50%;
  color: white;
  background: rgba(8, 6, 22, 0.92);
  z-index: 0;
}

.letter.target::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--cyan), var(--magenta), var(--violet), var(--cyan));
  animation: spin 2.6s linear infinite;
  z-index: -2;
}

.letter.target::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: #140c22;
  box-shadow: 0 0 22px rgba(94, 242, 255, 0.85), inset 0 0 12px rgba(94, 242, 255, 0.35);
  z-index: -1;
}

.rule { margin: 0 0 16px; font-size: 24px; color: rgba(244, 247, 255, 0.82); }
.rule b { color: var(--cyan); font-size: 1.15em; }

.timer-row { display: flex; align-items: center; gap: 16px; }

.timer-track {
  flex: 1;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#timerFill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--violet) 55%, var(--magenta));
  box-shadow: 0 0 18px rgba(94, 242, 255, 0.55);
  transition: width 0.25s linear;
}

#timerFill.urgent {
  background: linear-gradient(90deg, #ffb020, #ff3d5a);
  box-shadow: 0 0 18px rgba(255, 61, 90, 0.7);
  animation: blink 0.6s steps(2, end) infinite;
}

.timer-label {
  width: 84px;
  font-family: Syne, Outfit, sans-serif;
  font-size: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.score-hint { margin-top: 12px; }

.chain, .board { padding: 18px 20px 16px; }

.chain { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.section-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.chain-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.chain-list::-webkit-scrollbar { width: 8px; }
.chain-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 99px; }

.chain-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chain-item.enter { animation: rise 0.45s ease; }

.chain-item.kind-save { border-color: rgba(94, 242, 255, 0.45); }

.avatar, .avatar.fallback {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #31406e, #8d6bff);
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-size: 26px;
  font-weight: 800;
}

.who { font-size: 18px; color: rgba(244, 247, 255, 0.66); }
.played {
  font-family: Syne, Outfit, sans-serif;
  font-size: 32px;
  letter-spacing: 0.04em;
  line-height: 1.05;
}
.played em { color: var(--cyan); font-style: normal; }
.meta { text-align: right; }
.badge {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(244, 247, 255, 0.5);
}
.points {
  font-family: Syne, Outfit, sans-serif;
  font-size: 28px;
  color: var(--gold);
}

.leaders { display: flex; flex-direction: column; gap: 8px; }

.leader, .empty {
  display: grid;
  grid-template-columns: 42px 52px 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 24px;
}

.leader .avatar, .leader .avatar.fallback { width: 52px; height: 52px; font-size: 22px; }
.rank { font-family: Syne, Outfit, sans-serif; color: rgba(244, 247, 255, 0.55); }
.rank.r1 { color: var(--gold); }
.rank.r2 { color: #d5e4ff; }
.rank.r3 { color: #e0a070; }
.leader b { font-weight: 700; }
.leader .score { font-variant-numeric: tabular-nums; color: white; }
.empty { display: block; color: rgba(244, 247, 255, 0.55); font-size: 22px; }

#ice {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border: 12px solid rgba(198, 236, 255, 0.55);
  box-shadow: inset 0 0 90px rgba(176, 226, 255, 0.38);
  background: linear-gradient(180deg, rgba(214, 242, 255, 0.2), transparent 24%, transparent 76%, rgba(214, 242, 255, 0.16));
}

.ice-banner {
  position: absolute;
  top: 210px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 520px;
  text-align: center;
  padding: 18px 28px;
  border-radius: 24px;
  background: rgba(8, 20, 36, 0.72);
  border: 1px solid rgba(198, 236, 255, 0.5);
}

.ice-name { font-family: Syne, Outfit, sans-serif; font-size: 48px; }
.ice-sub { letter-spacing: 0.12em; color: #d7f4ff; }

#broken {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(4, 2, 12, 0.72);
  backdrop-filter: blur(8px);
}

.broken-card { text-align: center; padding: 20px; }
.broken-card h2 {
  margin: 10px 0 8px;
  font-family: Syne, Outfit, sans-serif;
  font-size: 108px;
  line-height: 0.86;
  letter-spacing: -0.05em;
  background: linear-gradient(180deg, #fff 20%, #ff8ac8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 61, 190, 0.55));
}
.broken-card p { margin: 8px 0; font-size: 32px; }
#brokenRecord.new { color: var(--gold); font-family: Syne, Outfit, sans-serif; font-size: 42px; }
#breakEta { color: rgba(244, 247, 255, 0.7); font-size: 24px; letter-spacing: 0.12em; }

#toast, #caption {
  position: absolute;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(8, 6, 20, 0.82);
  border: 1px solid var(--line);
  letter-spacing: 0.08em;
  font-weight: 700;
}

#toast { top: 188px; color: var(--gold); }
#caption { bottom: 250px; max-width: 860px; text-align: center; font-size: 22px; }
#toast.show, #caption.show { opacity: 1; transform: translateX(-50%); }

.paused {
  position: absolute;
  top: 188px;
  right: 48px;
  z-index: 4;
  padding: 8px 14px;
  border-radius: 999px;
  letter-spacing: 0.2em;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
}

#unlock {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font: inherit;
  font-weight: 700;
  color: #071018;
  background: var(--cyan);
  cursor: pointer;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes pop {
  from { transform: scale(0.86); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@keyframes rise {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
