:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text: #f7f9ff;
  --muted: #aebbd8;
  --pink: #ff42df;
  --purple: #855bff;
  --cyan: #24caff;
  --gold: #ffd32f;
  --border: rgba(117, 151, 255, .52);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #041027; }
body { margin: 0; min-height: 100vh; color: var(--text); background: transparent; overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: #041027 url('/background.png?v=3') center center / cover no-repeat;
}
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(2,8,25,.10), rgba(2,8,25,.22) 55%, rgba(2,8,25,.44));
}

.page-shell { position: relative; z-index: 1; width: min(1360px, calc(100% - 36px)); margin: 0 auto; padding: 12px 0 28px; }
.brand { display: flex; justify-content: center; align-items: center; min-height: 70px; }
.brand-logo { display: block; width: min(340px, 58vw); height: auto; filter: drop-shadow(0 0 16px rgba(97,76,255,.14)); }

.glass-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(140deg, rgba(3,15,43,.22), rgba(2,9,28,.27));
  backdrop-filter: blur(5px) saturate(112%);
  -webkit-backdrop-filter: blur(5px) saturate(112%);
  box-shadow: 0 18px 54px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.045);
}

.now-panel { padding: 26px 32px 22px; overflow: hidden; }
.now-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 24px; }
.live-pill { color: #ff60e5; font-weight: 820; font-size: 14px; letter-spacing: .2px; }
.live-pill i { display: inline-block; width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 14px var(--pink); }
.listener-pill { color: rgba(221,230,250,.78); font-size: 13px; }

h1 { margin: 6px 0 0; font-size: clamp(35px, 4.2vw, 61px); line-height: 1.02; letter-spacing: -2.3px; text-shadow: 0 3px 26px rgba(0,0,0,.22); }
h2 { margin: 0; font-size: clamp(25px, 2.3vw, 32px); line-height: 1.05; letter-spacing: -1px; }

#visualizer { display: block; width: 100%; height: 122px; margin: 3px 0 2px; }

.now-bottom { display: grid; grid-template-columns: minmax(330px, .85fr) minmax(420px, 1.15fr); gap: 30px; align-items: center; }
.audio-controls { display: flex; align-items: center; justify-content: center; gap: 24px; min-width: 0; }
.play-button {
  width: 70px; height: 70px; flex: 0 0 70px; border-radius: 50%; border: 1.5px solid rgba(105,183,255,.88);
  color: #fff; background: radial-gradient(circle at 50% 35%, rgba(63,132,255,.29), rgba(71,22,112,.33));
  box-shadow: 0 0 24px rgba(33,181,255,.17), 0 0 20px rgba(255,55,225,.16), inset 0 0 22px rgba(102,74,255,.14);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.play-button:hover { transform: translateY(-1px); }
.play-button:focus-visible, .save-rating:focus-visible, .star:focus-visible, .game-cell:focus-visible, .new-game:focus-visible { outline: 2px solid rgba(96,210,255,.85); outline-offset: 3px; }
.play-icon { width: 33px; height: 33px; display: flex; align-items: center; justify-content: center; }
.play-icon svg { width: 100%; height: 100%; display: block; overflow: visible; }
.icon-play { margin-left: 3px; }
.icon-play polygon, .icon-pause rect { fill: #fff; }
.volume-wrap { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.volume-icon { font-size: 18px; }
input[type="range"] { width: min(190px, 18vw); accent-color: #68d4ff; }

.rating-inline { display: flex; align-items: center; justify-content: flex-end; gap: 18px; min-width: 0; }
.stars { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.star { appearance: none; border: 0; background: transparent; color: rgba(156,192,255,.82); padding: 0; font-size: clamp(30px, 2.8vw, 42px); line-height: 1; cursor: pointer; transition: color .12s ease, transform .12s ease, text-shadow .12s ease; }
.star:hover, .star.preview, .star.active { color: var(--pink); text-shadow: 0 0 18px rgba(255,66,223,.45); transform: translateY(-1px); }
.rating-info { display: grid; gap: 7px; justify-items: start; min-width: 140px; color: #d9e1f4; font-size: 14px; }
.save-rating { height: 34px; padding: 0 13px; border: 1px solid rgba(126,160,255,.38); border-radius: 8px; color: #e8efff; background: rgba(7,21,54,.24); cursor: pointer; }
.save-rating:hover:not(:disabled) { background: rgba(19,41,88,.42); border-color: rgba(105,181,255,.55); }
.save-rating:disabled { opacity: .35; cursor: default; }

.lower-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, .65fr); gap: 14px; margin-top: 14px; align-items: stretch; }
.leaderboard-panel, .game-panel { height: 430px; min-height: 430px; padding: 25px 28px; overflow: hidden; }
.section-head, .game-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-note, .game-online { color: var(--muted); font-size: 13px; }

.leaderboard { height: 345px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(99,132,230,.5) transparent; list-style: none; padding: 0 8px 10px 0; margin: 18px 0 0; }
.leaderboard::-webkit-scrollbar { width: 7px; }
.leaderboard::-webkit-scrollbar-thumb { background: rgba(99,132,230,.48); border-radius: 99px; }
.leaderboard li { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 12px; min-height: 54px; align-items: center; border-bottom: 1px solid rgba(144,174,255,.12); }
.leaderboard li:first-child { background: rgba(31,59,122,.11); border: 1px solid rgba(83,123,244,.24); border-radius: 10px; padding-inline: 7px; }
.rank { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(41,98,181,.35); color: #e8efff; font-weight: 800; }
.rank-first { position: relative; width: 40px; height: 40px; border-radius: 0; background: var(--gold); color: #0a1430; clip-path: polygon(50% 0%,61% 34%,98% 35%,68% 56%,79% 92%,50% 70%,21% 92%,32% 56%,2% 35%,39% 34%); font-size: 14px; filter: drop-shadow(0 0 8px rgba(255,211,47,.28)); }
.track-mini { min-width: 0; }
.track-mini strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.score { color: #ffcc3c; font-weight: 800; white-space: nowrap; }

.game-help { margin: 9px 0 15px; color: var(--muted); font-size: 14px; }
.game-board { width: 230px; height: 230px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(3, 72px); gap: 7px; }
.game-cell { width: 72px; height: 72px; padding: 0; border: 1px solid rgba(99,137,255,.78); border-radius: 8px; background: rgba(7,20,52,.22); box-shadow: inset 0 0 16px rgba(40,80,180,.07); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.game-cell[aria-disabled="true"] { cursor: default; }
.game-cell[aria-disabled="false"]:hover { background: rgba(25,50,107,.28); }
.game-cell.x { border-color: rgba(53,201,255,.74); }
.game-cell.o { border-color: rgba(255,82,223,.74); }
.game-mark { width: 70%; height: 70%; pointer-events: none; display: flex; }
.game-mark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.game-mark-cross line { stroke: #35c9ff; stroke-width: 12; stroke-linecap: round; filter: drop-shadow(0 0 9px rgba(53,201,255,.8)); }
.game-mark-ring circle { fill: none; stroke: #ff52df; stroke-width: 12; filter: drop-shadow(0 0 9px rgba(255,82,223,.8)); }
.game-state { height: 21px; margin-top: 10px; text-align: center; color: #d0dbef; font-size: 14px; }
.new-game { display: block; margin: 8px auto 0; padding: 8px 17px; border: 1px solid rgba(95,135,255,.38); border-radius: 9px; color: #e3ebff; background: rgba(14,34,77,.26); cursor: pointer; }
.new-game[hidden] { display: block !important; visibility: hidden; pointer-events: none; }
.new-game:disabled { opacity: .42; }

.status { min-height: 20px; margin-top: 8px; text-align: center; color: #d3dcf0; font-size: 13px; }
#radioAudio { display: none; }

@media (max-width: 900px) {
  .page-shell { width: min(100% - 20px, 1360px); }
  .now-panel { padding: 22px 20px 18px; }
  .now-bottom { grid-template-columns: 1fr; gap: 16px; }
  .rating-inline { justify-content: center; }
  .audio-controls { justify-content: center; }
  input[type="range"] { width: 160px; }
  .lower-grid { grid-template-columns: 1fr; }
  .leaderboard-panel, .game-panel { height: 390px; min-height: 390px; }
  .leaderboard { height: 305px; }
}

@media (max-width: 560px) {
  .page-shell { width: calc(100% - 12px); padding-top: 6px; }
  .brand { min-height: 58px; }
  .brand-logo { width: min(300px, 76vw); }
  .now-panel { padding: 16px 15px 16px; border-radius: 15px; }
  .now-head { font-size: 12px; }
  h1 { font-size: clamp(31px, 10vw, 45px); letter-spacing: -1.7px; margin-top: 7px; }
  #visualizer { height: 94px; margin-top: 0; }
  .now-bottom { gap: 14px; }
  .play-button { width: 62px; height: 62px; flex-basis: 62px; }
  .play-icon { width: 29px; height: 29px; }
  .volume-wrap { min-width: 0; }
  input[type="range"] { width: 122px; }
  .rating-inline { flex-direction: column; gap: 8px; }
  .star { font-size: 38px; }
  .rating-info { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; font-size: 13px; }
  .lower-grid { margin-top: 8px; gap: 8px; }
  .leaderboard-panel, .game-panel { height: 380px; min-height: 380px; padding: 20px 17px; border-radius: 15px; }
  .leaderboard { height: 300px; }
  .game-board { width: 212px; height: 212px; grid-template-columns: repeat(3,66px); grid-template-rows: repeat(3,66px); }
  .game-cell { width: 66px; height: 66px; }
}
