/* BEAT CUBE — dark neon rhythm theme */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0b0e1a; color: #eef1ff;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
#hud.hidden { display: none; }
.hud-left { min-width: 120px; }
.hud-score { font-size: 28px; font-weight: 800; letter-spacing: 1px; text-shadow: 0 0 18px rgba(120,160,255,.65); font-variant-numeric: tabular-nums; }
.hud-combo { font-size: 15px; font-weight: 700; color: #ffd76a; text-shadow: 0 0 12px rgba(255,200,80,.6); min-height: 20px; }
.hud-combo.flow { color: #7dffd4; }
.hud-mid { flex: 1; padding-top: 10px; }
.prog { height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0%; border-radius: 3px; background: linear-gradient(90deg, #6a8dff, #b56aff); box-shadow: 0 0 10px rgba(140,120,255,.8); transition: width .15s linear; }
.hud-right { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.hud-diff { font-size: 12px; font-weight: 700; opacity: .75; letter-spacing: 1px; }
.hud-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(20,25,48,.7); color: #eef1ff; font-size: 15px; cursor: pointer; backdrop-filter: blur(6px);
}
.hud-btn:active { transform: scale(.94); }

#judge-pop {
  position: absolute; left: 50%; top: 32%; transform: translateX(-50%); z-index: 4;
  font-size: 30px; font-weight: 900; letter-spacing: 2px; pointer-events: none;
  opacity: 0; transition: opacity .1s;
}
#judge-pop.show { animation: jpop .5s ease-out; }
@keyframes jpop { 0% { opacity: 0; transform: translateX(-50%) scale(.6); } 18% { opacity: 1; transform: translateX(-50%) scale(1.15); } 60% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-18px); } }

/* ---------- Overlays & panels ---------- */
.ov {
  position: absolute; inset: 0; z-index: 10; display: none;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(6,8,18,.72); backdrop-filter: blur(8px);
}
.ov.show { display: flex; }
.pnl {
  position: relative; width: min(480px, 100%); max-height: calc(100% - 20px); overflow-y: auto;
  background: linear-gradient(160deg, rgba(26,30,58,.96), rgba(14,17,36,.96));
  border: 1px solid rgba(140,150,255,.22); border-radius: 22px;
  padding: 26px 22px; box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 40px rgba(90,100,255,.08) inset;
  scrollbar-width: thin;
}
.pnl.wide { width: min(720px, 100%); }
.pnl.center { text-align: center; }
.x {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.08); color: #cfd4ff; font-size: 20px; cursor: pointer; z-index: 2;
}
.logo { font-size: 44px; font-weight: 900; letter-spacing: 4px; background: linear-gradient(90deg, #6a8dff, #b56aff, #ff6ad5); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(140,120,255,.45)); }
.logo span { -webkit-text-fill-color: #ffd76a; font-size: 30px; vertical-align: middle; }
.tagline { margin: 6px 0 20px; color: #9aa3d8; font-size: 15px; }
.pnl-title { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.soft { color: #9aa3d8; font-size: 13px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.menu-row { margin-top: 18px; }

.b-pri, .b-sec {
  border: none; border-radius: 14px; padding: 12px 22px; font-size: 15px; font-weight: 700;
  cursor: pointer; color: #fff; transition: transform .08s, filter .15s;
}
.b-pri { background: linear-gradient(135deg, #5f7cff, #a75fff); box-shadow: 0 6px 24px rgba(110,100,255,.4); }
.b-pri.hero { font-size: 20px; padding: 15px 54px; letter-spacing: 3px; }
.b-sec { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.16); }
.b-sec.small { padding: 7px 14px; font-size: 13px; }
.b-pri:active, .b-sec:active { transform: scale(.96); }
.b-pri[disabled], .b-sec[disabled] { opacity: .45; cursor: default; }

.howto { list-style: none; text-align: left; margin: 4px auto 0; max-width: 340px; }
.howto li { display: flex; gap: 10px; align-items: flex-start; margin: 9px 0; color: #c6cdf5; font-size: 14px; line-height: 1.45; }
.howto i { font-style: normal; font-size: 17px; }
.meta-row { margin-top: 18px; font-size: 13px; }
.text-link { color: #8fa2ff; text-decoration: none; }
.meta-dot { margin: 0 8px; color: #4a5182; }

/* ---------- Track select ---------- */
.sel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.diff-seg { display: inline-flex; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,.16); }
.diff-seg button { border: none; padding: 9px 16px; background: rgba(255,255,255,.05); color: #b9c1ee; font-size: 13px; font-weight: 700; cursor: pointer; }
.diff-seg button.on { background: linear-gradient(135deg, #5f7cff, #a75fff); color: #fff; }
.sel-stats { display: flex; gap: 14px; font-weight: 800; font-size: 15px; }
#daily-card { margin-bottom: 12px; }
.daily {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; cursor: pointer;
  background: linear-gradient(120deg, rgba(255,150,80,.18), rgba(255,80,160,.14));
  border: 1px solid rgba(255,170,90,.35);
}
.daily .d-ico { font-size: 26px; }
.daily .d-name { font-weight: 800; font-size: 15px; }
.daily .d-sub { font-size: 12px; color: #d9b8a8; }
.daily .d-go { margin-left: auto; font-weight: 800; color: #ffd76a; white-space: nowrap; }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tcard {
  position: relative; border-radius: 16px; padding: 12px 14px; cursor: pointer; overflow: hidden;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.045);
  transition: transform .1s;
}
.tcard:not(.locked):hover { transform: translateY(-2px); }
.tcard .t-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.tcard .t-num { font-size: 11px; color: #8b93c9; font-weight: 700; }
.tcard .t-name { font-weight: 800; font-size: 15px; margin: 1px 0 2px; }
.tcard .t-comp { font-size: 11.5px; color: #9aa3d8; }
.tcard .t-meta { display: flex; justify-content: space-between; margin-top: 7px; font-size: 12.5px; }
.tcard .t-stars { color: #ffd76a; letter-spacing: 1px; }
.tcard .t-best { color: #8b93c9; font-variant-numeric: tabular-nums; }
.tcard .t-medal { position: absolute; top: 9px; right: 10px; font-size: 15px; }
.tcard .t-practice { margin-top: 8px; width: 100%; padding: 6px; font-size: 12px; border-radius: 9px; border: 1px dashed rgba(255,255,255,.25); background: none; color: #9aa3d8; cursor: pointer; }
.tcard.locked { opacity: .55; cursor: default; }
.tcard.locked .t-lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; background: rgba(8,10,22,.55); font-size: 14px; }

/* ---------- Result ---------- */
.res-track { color: #9aa3d8; font-size: 14px; margin-top: -6px; }
.final-score { font-size: 46px; font-weight: 900; margin: 10px 0 2px; text-shadow: 0 0 26px rgba(130,150,255,.7); font-variant-numeric: tabular-nums; }
.res-stars { font-size: 30px; letter-spacing: 6px; min-height: 38px; }
.res-stars .dim { opacity: .25; }
.res-judges { display: flex; justify-content: center; gap: 14px; margin: 6px 0 4px; font-size: 13.5px; font-weight: 700; flex-wrap: wrap; }
.res-judges b { font-variant-numeric: tabular-nums; }
.rj-p { color: #ffd76a; } .rj-g { color: #7db2ff; } .rj-m { color: #ff7d9c; }
.submit-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.text-input {
  flex: 1; max-width: 200px; padding: 11px 14px; border-radius: 12px; font-size: 14px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: #fff; outline: none;
}
.board-card { margin-top: 14px; border-radius: 16px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.1); padding: 12px 14px; text-align: left; }
.card-title { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: #8b93c9; margin-bottom: 8px; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(255,255,255,.06); }
.board-row:first-child { border-top: none; }
.board-rank { width: 34px; font-weight: 800; color: #8fa2ff; }
.board-name { font-weight: 700; font-size: 14px; }
.board-meta { font-size: 11.5px; color: #8b93c9; }
.board-score { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-empty { color: #8b93c9; font-size: 13px; padding: 8px 0; }

/* ---------- Shop ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.05); color: #b9c1ee; border-radius: 11px; padding: 8px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.tab.on { background: linear-gradient(135deg, #5f7cff, #a75fff); color: #fff; border-color: transparent; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.sitem { border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); padding: 10px; text-align: center; cursor: pointer; }
.sitem canvas { width: 64px; height: 64px; display: block; margin: 2px auto 6px; }
.sitem .s-name { font-size: 12.5px; font-weight: 700; }
.sitem .s-price { font-size: 12px; color: #ffd76a; margin-top: 3px; font-weight: 700; }
.sitem.owned .s-price { color: #7dffd4; }
.sitem.equipped { border-color: #7dffd4; box-shadow: 0 0 14px rgba(125,255,212,.25); }
.sitem.hidden-item { opacity: .6; }

/* ---------- Settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 13px 0; font-size: 14.5px; flex-wrap: wrap; }
input[type=range] { accent-color: #8f7bff; }

/* ---------- Toasts ---------- */
#toasts { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(24,28,55,.92); border: 1px solid rgba(140,150,255,.3); color: #eef1ff;
  padding: 10px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: tin 2.6s forwards;
}
@keyframes tin { 0% { opacity: 0; transform: translateY(14px); } 10%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 560px) {
  .logo { font-size: 34px; }
  .hud-score { font-size: 22px; }
  .pnl { padding: 20px 14px; }
  .track-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) { .track-grid { grid-template-columns: 1fr; } }
