:root {
  --bg: #05080f;
  --bg-2: #0b1626;
  --ink: #f4f8ff;
  --muted: #9eb0c6;
  --line: rgba(120, 190, 255, 0.28);
  --accent: #79dfff;
  --accent-2: #36b8ff;
  --gold: #e7c27a;
  --danger: #ff8d8d;
  --ok: #7dffa8;
  --card: rgba(6, 14, 26, 0.72);
  --glow: rgba(54, 184, 255, 0.35);
  --font-display: "DIN Alternate", "Avenir Next Condensed", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #02040a; color: var(--ink); overflow: hidden; }
html.is-preview body { width: 1280px; height: 720px; transform-origin: 0 0; }
body { font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }

.control-card {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  width: 104px;
  padding: 6px 6px 8px;
  background: rgba(7, 16, 28, 0.88);
  border: 1px solid rgba(120, 190, 255, 0.28);
  border-radius: 10px;
  color: #f4f8ff;
  text-align: center;
}
.control-card img { width: 92px; height: 92px; background: #fff; border-radius: 4px; }
.control-title { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.08em; }
.control-hint { margin: 4px 0 0; font-size: 10px; line-height: 1.3; color: #9eb0c6; }

.apk-root {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: clamp(16px, 2.2vh, 36px) clamp(20px, 3vw, 64px) clamp(12px, 2vh, 28px);
  background:
    radial-gradient(ellipse at 50% 0%, var(--glow), transparent 42%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 42%, #02040a);
}
.scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% 20%, transparent 0 18%, rgba(255,255,255,0.03) 19% 20%, transparent 21%),
    linear-gradient(115deg, transparent 40%, rgba(120, 200, 255, 0.05) 48%, transparent 56%);
  opacity: 0.9;
}
.apk-root[data-motion="off"] .scene { display: none; }

.apk-top, .apk-main, .apk-foot, .extras { position: relative; z-index: 1; }
.apk-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.brand-block { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 14px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  color: var(--accent);
  letter-spacing: 0.08em;
  font-weight: 700;
  background: rgba(0,0,0,0.25);
}
#themeLogo { max-height: 64px; max-width: 180px; object-fit: contain; }
.brand-name { font-size: clamp(18px, 1.6vw, 28px); font-weight: 700; letter-spacing: 0.08em; }
.event-name { margin-top: 4px; color: var(--muted); font-size: clamp(14px, 1.2vw, 20px); }
.clock { font-size: clamp(22px, 2vw, 36px); letter-spacing: 0.08em; text-align: right; }
.status-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.lifecycle, .conn {
  font-size: 12px; letter-spacing: 0.16em;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.lifecycle.running, .conn.online { color: var(--ok); }
.lifecycle.paused, .lifecycle.break { color: var(--gold); }
.lifecycle.finished, .lifecycle.offline, .conn.offline { color: var(--danger); }
#enableSound {
  margin-top: 8px; float: right;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  min-height: 32px; padding: 0 12px; cursor: pointer;
}

.apk-main { display: grid; grid-template-rows: 1fr auto; min-height: 0; }
.hero { display: grid; justify-items: center; align-content: center; text-align: center; }
.hero-kicker { margin: 0 0 8px; letter-spacing: 0.28em; color: var(--accent); font-size: clamp(12px, 1vw, 16px); }
.timer-wrap { position: relative; display: grid; place-items: center; width: min(72vw, 920px); }
.ring { position: absolute; width: min(46vw, 520px); height: auto; opacity: 0.9; }
.ring-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 2; }
.ring-value {
  fill: none; stroke: var(--accent); stroke-width: 2.4;
  stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 60px 60px;
  stroke-dasharray: 326.7; stroke-dashoffset: 0;
}
.timer {
  font-family: var(--font-display);
  font-size: clamp(92px, 16vw, 280px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-shadow: 0 0 28px var(--glow);
}
.banner {
  margin-top: 8px; letter-spacing: 0.42em; font-size: clamp(18px, 2vw, 32px); font-weight: 700;
}
.banner.paused { color: var(--gold); }
.banner.break { color: var(--accent); }
.banner.finished, .banner.offline { color: var(--danger); }
.status-text { margin: 8px 0 0; color: var(--muted); letter-spacing: 0.12em; }
.apk-root.level-flash .timer { animation: flash .7s ease; }
@keyframes flash { 50% { filter: brightness(1.6); } }

.blind-row { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 28px); }
.blind-card {
  padding: clamp(12px, 1.6vh, 22px) clamp(16px, 2vw, 28px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  backdrop-filter: blur(8px);
}
.blind-card.next { opacity: 0.86; }
.label { margin: 0; color: var(--accent); letter-spacing: 0.2em; font-size: 12px; }
.level-name { margin: 6px 0 10px; font-size: clamp(16px, 1.4vw, 22px); }
.blind-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.blind-grid span { display: block; color: var(--muted); font-size: 13px; }
.blind-grid strong { display: block; margin-top: 4px; font-size: clamp(22px, 2.6vw, 48px); line-height: 1; overflow-wrap: anywhere; }
.next-duration { margin: 8px 0 0; color: var(--muted); }

.apk-foot {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.metric {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.metric span { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.metric strong { display: block; margin-top: 4px; font-size: clamp(20px, 2vw, 34px); }
.extras { display: flex; justify-content: space-between; gap: 16px; align-items: center; min-height: 28px; color: var(--muted); font-size: 14px; }
#prizeCopy, #chipRow { margin: 0; }
.terminal-name { margin-left: auto; }

.apk-root[data-style="bar"] .ring { display: none; }
.apk-root[data-style="bar"] .timer-wrap::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%; bottom: -6px; height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.apk-root[data-theme="gold"] {
  --bg: #090806; --bg-2: #16110c; --accent: #e7c27a; --accent-2: #f3ddb0;
  --line: rgba(231, 194, 122, 0.35); --glow: rgba(231, 194, 122, 0.28); --card: rgba(18, 14, 8, 0.78);
}
.apk-root[data-theme="gold"] .scene {
  background: linear-gradient(90deg, transparent, rgba(231, 194, 122, 0.08), transparent);
}
.apk-root[data-theme="crimson"] {
  --bg: #100608; --bg-2: #2a0c12; --accent: #ff6b6b; --accent-2: #ffb4a2;
  --line: rgba(255, 90, 90, 0.35); --glow: rgba(180, 20, 40, 0.4); --card: rgba(28, 8, 12, 0.78);
}
.apk-root[data-theme="crimson"] .timer { font-style: italic; letter-spacing: -0.06em; }
.apk-root[data-theme="paper"] {
  --bg: #f4f1ea; --bg-2: #fffdf8; --ink: #16181d; --muted: #5c6570;
  --accent: #0b63ce; --accent-2: #083e86; --line: rgba(12, 20, 32, 0.16);
  --glow: transparent; --card: rgba(255,255,255,0.72); --ok: #0b7a45; --gold: #8a5a00; --danger: #a32020;
}
.apk-root[data-theme="paper"] .scene { opacity: 0.25; background: none; }
.apk-root[data-theme="paper"] .timer { text-shadow: none; font-weight: 760; }
.apk-root[data-theme="neon"] {
  --bg: #070414; --bg-2: #160828; --accent: #d7a6ff; --accent-2: #7aa2ff;
  --line: rgba(180, 120, 255, 0.4); --glow: rgba(120, 70, 255, 0.45); --card: rgba(16, 8, 32, 0.76);
}
.apk-root[data-theme="neon"] .scene {
  background:
    radial-gradient(circle at 15% 80%, rgba(80, 40, 180, 0.35), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(40, 80, 200, 0.28), transparent 26%);
}

.pair-overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(2, 4, 10, 0.72);
}
.pair-card {
  width: min(440px, calc(100% - 32px));
  padding: 28px;
  border-radius: 18px;
  background: #0c121c;
  color: #f4f8ff;
  border: 1px solid rgba(120, 190, 255, 0.3);
  text-align: center;
}
.pair-card h1 { margin: 0 0 8px; font-size: 22px; }
.pair-card img { width: 220px; height: 220px; object-fit: contain; background: #fff; border-radius: 12px; }
.pair-code { margin: 12px 0; letter-spacing: 0.4em; font-size: 28px; }
.pair-card button, .pair-card input {
  width: 100%; min-height: 40px; margin-top: 8px;
  border-radius: 10px; border: 1px solid #314056; background: #121a26; color: #fff;
}
.legacy-pair { margin-top: 16px; text-align: left; color: #9eb0c6; }

@media (max-width: 1366px) {
  .apk-foot { grid-template-columns: repeat(3, 1fr); }
  .timer { font-size: clamp(84px, 14vw, 180px); }
}
@media (max-width: 900px) {
  .blind-row, .apk-foot { grid-template-columns: 1fr 1fr; }
  .apk-root { overflow: auto; }
}
@media (min-width: 2500px) {
  .timer { font-size: 420px; }
  .blind-grid strong { font-size: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .apk-root.level-flash .timer { animation: none; }
  .scene { display: none; }
}
