@font-face {
  font-family: 'Montserrat';
  src: url('/fonts/montserrat-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --yellow: #ffd00f;
  --red: #e53b2f;
  --ink: #f4f6fa;
  --muted: rgba(244, 246, 250, 0.62);
  --glass: rgba(11, 16, 24, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c121b; color: var(--ink);
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

/* ---------- header ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 22px; letter-spacing: 0.02em;
  text-transform: uppercase; font-style: italic; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); }
.brand svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)); }
.tools { display: flex; align-items: center; gap: 8px; }
.seg, .vol, .icon-btn { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 14px; height: 46px; }
.seg { display: flex; align-items: center; padding: 4px; gap: 2px; }
.seg-label { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: 0 8px 0 6px; letter-spacing: 0.06em; }
.seg button { height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--yellow); color: #1a1400; }
.vol { display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); }
.vol svg { width: 22px; height: 22px; }
.vol input { width: 110px; accent-color: var(--yellow); }
.icon-btn { width: 46px; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- warning banner ---------- */
.banner { position: fixed; left: 50%; bottom: 260px; transform: translate(-50%, 12px); width: min(900px, calc(100vw - 24px)); display: flex; align-items: stretch;
  border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.5s, transform 0.5s;
  pointer-events: none; z-index: 4; }
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner-title { flex: 0 0 auto; background: var(--red); color: #fff; font-weight: 900; font-size: 17px; letter-spacing: 0.06em; padding: 9px 14px; white-space: nowrap; }
.banner.show .warn { animation: blink 1s steps(2, start) infinite; }
.crawl { flex: 1 1 auto; background: rgba(10, 10, 14, 0.88); overflow: hidden; white-space: nowrap; font-weight: 700; font-size: 16px; display: flex; align-items: center; }
.crawl-track { display: inline-block; padding-left: 100%; animation: crawl 22s linear infinite; }
@keyframes crawl { to { transform: translateX(-100%); } }
@keyframes blink { to { visibility: hidden; } }

/* ---------- control deck ---------- */
.deck { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px;
  padding: 16px 18px calc(16px + var(--safe-b)); background: linear-gradient(180deg, rgba(11, 16, 24, 0.72), rgba(8, 11, 17, 0.92));
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); border-radius: 24px 24px 0 0; }

.power-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.power { position: relative; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #ff8a7a, #c4241a 55%, #7d120c); box-shadow: 0 8px 0 #5a0d08, 0 14px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s, box-shadow 0.08s; }
.power:active { transform: translateY(6px); box-shadow: 0 2px 0 #5a0d08, 0 6px 16px rgba(0, 0, 0, 0.5); }
.power-ring { position: absolute; inset: 9px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.35); }
.power-label { font-weight: 900; font-size: 26px; letter-spacing: 0.06em; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35); }
.power.on { animation: pulse 1.1s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #ffb3a6, #ff3b2a 55%, #a5160d); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 0 #5a0d08, 0 0 0 0 rgba(255, 70, 50, 0.6), 0 14px 30px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 8px 0 #5a0d08, 0 0 0 18px rgba(255, 70, 50, 0), 0 14px 30px rgba(0, 0, 0, 0.5); }
}
.gauge { width: 132px; text-align: center; }
.gauge svg { width: 100%; display: block; }
#needle { transition: transform 0.05s linear; }
.gauge-read { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; margin-top: -2px; }
.gauge-read b { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0; }

.rows { display: flex; flex-direction: column; gap: 10px; min-width: 0; justify-content: center; }
.row h2 { margin: 0 0 6px 2px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.row h2 small { text-transform: none; letter-spacing: 0; font-weight: 600; opacity: 0.75; margin-left: 6px; }
.chips { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-width: 124px; max-width: 170px; height: 70px; border-radius: 16px; padding: 8px 14px 8px 10px; display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.07); border: 2px solid transparent; text-align: left; scroll-snap-align: start; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.chip:active { transform: scale(0.96); }
.chip.on { border-color: var(--yellow); background: rgba(255, 208, 15, 0.16); }
.chip-ico { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); font-size: 26px; }
.chip.on .chip-ico { background: var(--yellow); color: #1a1400; }
.chip-ico svg { width: 26px; height: 26px; }
.chip-name { font-weight: 800; font-size: 14.5px; line-height: 1.15; }
.chip-sub { display: block; font-weight: 600; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.chip.playing .chip-ico { animation: wob 0.5s ease-in-out infinite alternate; }
@keyframes wob { to { transform: rotate(-12deg) scale(1.08); } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(250px + var(--safe-b)); transform: translate(-50%, 10px); background: rgba(10, 14, 20, 0.9);
  border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 16px; opacity: 0; transition: opacity 0.25s, transform 0.25s;
  pointer-events: none; z-index: 6; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- QR modal ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(4, 7, 12, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-card { width: min(420px, calc(100vw - 32px)); background: #121a26; border: 1px solid var(--line); border-radius: 22px; padding: 24px; text-align: center; }
.modal-card h3 { margin: 0 0 4px; font-size: 22px; font-weight: 900; }
.modal-card p { margin: 0 0 14px; color: var(--muted); font-weight: 600; font-size: 14px; }
.qr-box { background: #fff; border-radius: 16px; padding: 10px; display: inline-block; }
.qr-box canvas { display: block; width: 260px; height: 260px; image-rendering: pixelated; }
.qr-url { margin: 10px 0 14px; font-weight: 700; font-size: 14px; word-break: break-all; color: var(--yellow); }
.modal-card .hint { font-size: 13px; }
.close { margin-top: 4px; background: var(--yellow); color: #1a1400; font-weight: 800; padding: 12px 28px; border-radius: 12px; font-size: 16px; }

/* ---------- smaller screens ---------- */
@media (max-width: 720px) {
  .brand span { display: none; }
  .vol input { width: 70px; }
  .seg-label { display: none; }
  .deck { gap: 12px; padding: 12px 12px calc(12px + var(--safe-b)); }
  .power, .gauge { width: 104px; }
  .power { height: 104px; }
  .power-label { font-size: 21px; }
  .chip { min-width: 112px; height: 62px; }
  .banner-title { font-size: 13px; padding: 8px 10px; }
  .crawl { font-size: 13px; }
}
@media (max-height: 560px) {
  .gauge { display: none; }
  .power { width: 92px; height: 92px; }
  .chip { height: 54px; }
  .chip-ico { width: 34px; height: 34px; flex-basis: 34px; font-size: 22px; }
  .row h2 { margin-bottom: 4px; }
}
