:root {
  --bg: #0e0c2a;
  --panel: #1a1740;
  --panel2: #24205a;
  --line: #5560a8;
  --gold: #ffd678;
  --text: #f2f0ff;
  --muted: #9aa0d0;
  --accent: #6c7cff;
  /* Surfaces the themes (js/themes.js) replace; these are the plain look. */
  --list: #0b0a24;
  --play: #2e3aa8;
  --bar-line: #2c2870;
  --tex: none;
  --bar-bg: linear-gradient(#171446, #100e32);
  --foot-bg: linear-gradient(#100e32, #0b0a24);
  --pane-bg: var(--panel);
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* A long press (the item disc, a long tap anywhere) must not select the page or raise iOS's magnifier and callout. */
html, body {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea { -webkit-user-select: text; user-select: text; }html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--gold); }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(#7a5a1e, #5a3f10); border-color: var(--gold); }
button.plain { background: none; border: 0; padding: 4px 8px; }
button.on { background: #3a3480; border-color: var(--gold); color: var(--gold); }
input[type=search], input[type=text], input[type=url] { background: var(--list); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 0; }
input[type=range] { accent-color: var(--gold); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100%; padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
#topbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bar-bg); border-bottom: 1px solid var(--bar-line); flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.brand img { image-rendering: pixelated; border-radius: 4px; }
#tabs { display: flex; gap: 6px; margin-left: auto; }
#tabs button { padding: 6px 12px; white-space: nowrap; }
#menuBtn { font-size: 22px; line-height: 1; }

#main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#stage { flex: 1 1 auto; min-height: 0; position: relative; background: #000; }
.tip { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 5; pointer-events: none;
  background: rgba(14, 12, 42, 0.9); color: var(--text); border: 1px solid var(--gold); border-radius: 999px; padding: 9px 16px; font-size: 14px; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.35s; }
.tip.show { opacity: 1; }
#scene { width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: manipulation; }
body.view-list #stage { flex: 0 0 132px; }
.pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; gap: 8px; background: var(--pane-bg); }
.paneBar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.paneBar input[type=search] { flex: 1 1 180px; }
.paneBar input[type=url] { flex: 1 1 220px; font-size: max(16px, 1em); }   /* 16px+ so a phone doesn't zoom in on focus */
#linkMsg { flex: 1 1 100%; }
#linkMsg:empty { display: none; }

.vlist { flex: 1 1 auto; min-height: 120px; overflow: auto; background: var(--list); border: 1px solid var(--line); border-radius: 8px; position: relative; -webkit-overflow-scrolling: touch; }
.vlist .spacer { position: relative; }
.vlist .row { position: absolute; left: 0; right: 0; height: 44px; padding: 5px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer; overflow: hidden; }
.vlist .row:nth-child(odd) { background: rgba(255,255,255,0.025); }
.vlist .row:hover { background: rgba(108,124,255,0.18); }
.vlist .row.playing { background: rgba(255,214,120,0.12); }
.vlist .row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vlist .row.playing .t { color: var(--gold); }
.vlist .row .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vlist .row.disabled { opacity: 0.5; cursor: default; }
.vlist .row.hasSupport { padding-right: 104px; }
/* The pill: the text is centred by flex (the font shorthand below resets line-height, which had left it riding high in the pill),
   with the trailing letter-spacing given back on the left so the letters look centred. */
.vlist .row .support { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); box-sizing: border-box; height: 26px;
  display: flex; align-items: center; justify-content: center; padding: 0 12px 0 calc(12px + 0.06em); border-radius: 13px;
  border: 1.5px solid var(--gold); background: rgba(90,62,16,0.55); color: var(--gold);
  font: inherit; font-size: 11px; font-weight: 700; line-height: 1; letter-spacing: 0.06em; text-decoration: none;
  cursor: pointer; white-space: nowrap; }
.vlist .row .support:hover { background: rgba(120,86,24,0.85); color: #fff; }
.vlist .row.disabled .support { opacity: 1; }
/* A theme's glossy blue buttons, as in the Windows app (the plain look keeps the flat ones). */
html.themed button { background: linear-gradient(rgb(118,146,240), rgb(26,34,118)); border-color: rgb(196,214,255); text-shadow: 0 1px 0 rgba(20,16,40,0.8); }
html.themed button.plain, html.themed .menu button { background: none; border-color: transparent; text-shadow: none; }
html.themed .menu button:hover { background: rgba(255,255,255,0.12); }
html.themed button.primary, html.themed button.on { background: linear-gradient(rgb(206,132,66), rgb(88,48,22)); border-color: rgb(255,206,130); color: #fff; }
html.themed .icon.big { background: var(--play); }
html.themed .icon.active { border-color: var(--gold); }
html.themed .vlist .row .support { text-shadow: none; }
#sortSel { background: var(--list); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; max-width: 100%; }
#sortDir { padding: 6px 10px; min-width: 38px; }
#plBar select, #tunerPlBar select { max-width: 100%; min-width: 0; background: var(--list); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }
#plNote:empty { display: none; }
.vlist .row.hasMore { padding-right: 46px; }
.vlist .row .more { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; padding: 0; line-height: 1; font-size: 18px; }
#plPick h3, #plMissing h3 { margin: 0 0 10px; }
#plMissingNote { margin: 0 0 8px; }
#plMissingList { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: min(480px, 80vw); }
#plMissingList .mt { font-weight: 600; overflow-wrap: anywhere; }
#plMissingList .mp { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#plPickList { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
#plPickList label { display: flex; gap: 8px; align-items: baseline; }
#plPickList .muted { font-size: 12px; }
.plPickBtns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.plmenu { position: fixed; z-index: 100; min-width: 190px; max-width: min(320px, 92vw); max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.plmenu[hidden] { display: none; }
.plmenu button { text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plmenu button:hover:not(:disabled) { background: rgba(108,124,255,0.25); }
.plmenu button:disabled { opacity: 0.45; cursor: default; }
.plmenu .hdr { padding: 4px 10px; color: var(--muted); font-size: 12px; }
.plmenu .sep { height: 1px; background: var(--line); margin: 4px 0; }
#logDock { flex: 0 0 auto; padding: 4px 12px calc(6px + env(safe-area-inset-bottom)); background: var(--foot-bg); border-top: 1px solid var(--bar-line); }
#logDock .logHead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#logToggle { padding: 4px 10px; font-weight: 600; }
#logTools { display: flex; align-items: center; gap: 8px; }
#logTools[hidden] { display: none; }
#logTools select { background: var(--list); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font: inherit; max-width: 100%; }
#logTools button { padding: 4px 10px; }
.logbox { height: min(30vh, 220px); overflow: auto; background: var(--list); border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; margin-top: 6px; font-size: 13px; line-height: 1.45; -webkit-overflow-scrolling: touch; }
.logbox[hidden] { display: none; }
.logbox .logRow { padding: 1px 12px; overflow-wrap: anywhere; }
.logbox .logT { color: var(--muted); margin-right: 10px; font-variant-numeric: tabular-nums; }
.logbox .logDay { padding: 10px 12px 3px; color: var(--gold); font-weight: 600; }
.empty { color: #ffd6c4; background: rgba(120,40,40,0.35); border: 1px solid #f08266; border-radius: 10px; padding: 12px 14px; margin: 0; }

#transport { flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 14px; align-items: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--foot-bg); border-top: 1px solid var(--bar-line); }
#nowPlaying { display: flex; flex-direction: column; min-width: 0; }
#nowTitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nowSub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; gap: 6px; align-items: center; }
.icon { width: 40px; height: 40px; padding: 0; font-size: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.icon.big { width: 52px; height: 52px; font-size: 22px; background: var(--play); }
/* Material icons: the 960 grid carries each icon's own optical centring, so the svg is simply centred in the button. */
.icon .mi { width: 32px; height: 32px; fill: currentColor; display: block; }
.icon.big .mi { width: 42px; height: 42px; }
.icon.active { color: var(--gold); border-color: var(--gold); }
.seek { grid-column: 1 / -1; justify-self: center; width: min(640px, 100%); display: flex; align-items: center; gap: 8px; }
.seek input { flex: 1; }
.rightcol { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; }
/* The theme picker: a dropdown above the volume sliders. */
.themePick { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.themePick span { white-space: nowrap; }
.themePick select { appearance: none; -webkit-appearance: none; width: 168px; max-width: 100%; padding: 5px 30px 5px 10px; font: inherit; font-size: 13px; color: var(--text);
  background-color: var(--panel2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23ffd678' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
.themePick select:hover, .themePick select:focus-visible { border-color: var(--gold); outline: none; }
.themePick select option { background: #1a1740; color: #f2f0ff; }
.vols { display: flex; gap: 12px; justify-content: flex-end; }
.vols label span { white-space: nowrap; }
.vols label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.vols input { width: 90px; }

#dim { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 20; }
.popup { position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, calc(100vw - 20px)); max-height: calc(100dvh - 24px);
  background: var(--pane-bg); border: 3px solid var(--gold); border-radius: 10px; box-shadow: 0 0 0 2px #3a2a08, 0 12px 40px rgba(0,0,0,0.6); display: flex; flex-direction: column; overflow: hidden; }
.popTabs { display: flex; gap: 8px; padding: 10px; background: var(--bar-bg); }
.popTabs button[data-ttab] { flex: 1; }
.close { font-size: 26px; line-height: 1; }
.popBody { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 0; flex: 1 1 auto; }
.popBody .vlist { height: min(52dvh, 420px); flex: 0 0 auto; }
.notice { color: #ffd6c4; background: rgba(120,40,40,0.35); border: 1px solid #f08266; border-radius: 10px; padding: 12px 14px; margin: 0; }
.foot { font-size: 12px; }

.popup.pixel { font-family: Consolas, "SFMono-Regular", Menlo, monospace; background: #1a163c; border-color: #ffd678; border-radius: 0; box-shadow: 0 0 0 3px #0e0a22, 0 0 0 6px #6e82e0, 0 0 0 9px #0e0a22; image-rendering: pixelated; }
.pixel header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #362c70; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 2px, transparent 2px 4px); }
.pixel h2 { margin: 0; font-size: 18px; color: var(--gold); letter-spacing: 1px; flex: 1; }
.tome { width: 30px; height: 26px; background: #962840; border: 2px solid #0e0a22; box-shadow: inset 4px 0 0 #681830, inset 0 3px 0 #d25060; position: relative; }
.tome::after { content: ""; position: absolute; left: 12px; top: 6px; width: 5px; height: 11px; background: var(--gold); box-shadow: -3px 3px 0 var(--gold), 3px 3px 0 var(--gold); }
#compTabs { display: flex; gap: 6px; padding: 8px 12px 0; }
#compTabs button { font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #bec4f0; background: #26205a; border: 2px solid #6e78c8; padding: 5px 16px; border-radius: 0; cursor: pointer; }
#compTabs button.on { color: var(--gold); background: #50429f; border-color: var(--gold); }
.pixel header .eye { color: #b4bcec; background: #46388a; border: 2px solid var(--gold); border-radius: 0; padding: 4px 6px; display: flex; align-items: center; cursor: pointer; }
.pixel header .eye[aria-pressed=true] { color: #c4ff80; background: #5a6e28; border-color: #bef878; }
.card .st .hit { color: #ffb078; }
.card .st .iv { color: #96c8ff; }
.card .st .bm { color: #ff8080; }
.card .lbl { color: #969cd2; font-size: 10px; letter-spacing: 1px; margin-right: 6px; }
.card .row { font-size: 12px; color: #d6daf6; margin: 2px 0; }
.card .row.atk { color: #ffb078; }
.card .row.skl { color: #96c8ff; }
#compCards { overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: min(60dvh, 420px); }
.card { display: grid; grid-template-columns: 84px 1fr auto; gap: 12px; padding: 8px; background: #282260; border: 2px solid #7882e6; }
.card.unknown { border-color: #46467f; opacity: 0.85; }
.card canvas { width: 76px; height: 76px; image-rendering: pixelated; background: #5c84d6; border: 2px solid #0e0a22; }
.card.unknown canvas { background: #28284a; }
.card .nm { color: var(--gold); font-weight: 700; font-size: 16px; }
.card .st { font-size: 12px; color: #aab4f0; margin: 3px 0; }
.card .st b { color: #aae096; }
.card .nt { font-size: 12.5px; color: #d6daf6; }
.card .kills { text-align: right; }
.card .kills .n { font-size: 24px; font-weight: 700; }
.card .kills .l { font-size: 10px; color: #c88c78; }
#compFoot { padding: 8px 14px; font-size: 12px; color: var(--gold); border-top: 2px solid #0e0a22; }

.menu { position: fixed; z-index: 40; right: 10px; top: calc(52px + env(safe-area-inset-top)); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; min-width: 190px; }
.menu button { text-align: left; background: none; border: 0; }
.menu button:hover { background: rgba(255,255,255,0.08); }
.menu .hdr { margin-top: 6px; padding: 8px 12px 2px; font-size: 12px; color: var(--muted); border-top: 1px solid rgba(255,255,255,0.1); }
.menu button.cur::before { content: "\2713  "; color: var(--gold); }
dialog { background: var(--panel); color: var(--text); border: 2px solid var(--gold); border-radius: 12px; max-width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,0.65); }

/* Full screen (or the iPhone's stand-in for it): the scene alone. */
body.immersive #topbar, body.immersive #transport, body.immersive #logDock, body.immersive .pane { display: none; }
/* The scene fills the screen but stays clear of the status bar / Dynamic Island, the home indicator and any landscape notch. */
body.immersive #app { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.immersive #stage { flex: 1 1 auto; }
#stage:fullscreen { background: #000; }
#stage:fullscreen #scene { width: 100vw; height: 100vh; }

@media (max-width: 640px) {
  .brand span { display: none; }
  #transport { grid-template-columns: 1fr; }
  .seek { grid-column: auto; }
  .vols { justify-content: space-between; }
  .vols { gap: 8px; }
  .rightcol { align-items: stretch; }
  #tabs { gap: 4px; }
  #tabs button { padding: 6px 9px; font-size: 14px; }
  .themePick select { flex: 1; width: auto; }
  .vols input { width: 28vw; }
}
