:root {
  --bg: #0d0f16;
  --fg: #e9ecf3;
  --muted: #9aa3b5;
  --card: rgba(18, 21, 31, 0.78);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #8fb8ff;
  --accent-2: #b59cff;
  --danger: #ff8a8a;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; }
button, .btn, select, input { font: inherit; color: inherit; }
button, .btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; transition: background .15s, border-color .15s;
}
button:hover, .btn:hover { background: rgba(255,255,255,0.12); }
button:focus-visible, .btn:focus-within, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: linear-gradient(135deg, rgba(143,184,255,.25), rgba(181,156,255,.22)); border-color: rgba(143,184,255,.4); }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: default; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; font: 12px/1.5 ui-monospace, monospace; text-align: center; background: rgba(255,255,255,.05); }

/* HUD */
#hud .label, #stats { position: fixed; pointer-events: none; color: var(--muted); }
#hud .label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
#stats { display: grid; gap: 10px; padding: 10px 12px; margin: -10px 0 0 -12px; border-radius: 12px;
  background: rgba(8, 10, 16, .42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#stats div { display: flex; flex-direction: column; }
#stats span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
#stats b { color: var(--fg); font-size: 20px; font-variant-numeric: tabular-nums; font-weight: 600; }
#stats .best b { color: var(--muted); font-size: 15px; }
.icon-btn { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 12px; padding: 6px 10px; font-size: 12px; opacity: .55; }
.icon-btn:hover { opacity: 1; }
#toast, #caption { position: fixed; left: 50%; transform: translateX(-50%); pointer-events: none; text-align: center;
  opacity: 0; transition: opacity .5s; white-space: nowrap; text-shadow: 0 1px 6px rgba(0,0,0,.7); }
#toast { font-weight: 600; letter-spacing: .06em; font-size: 15px; }
#toast.show { opacity: .92; }
#caption { color: var(--muted); font-size: 12px; letter-spacing: .08em; transition: opacity 1.2s, color 1.2s;
  padding: 2px 10px; border-radius: 999px; background: rgba(8, 10, 16, .45); }
#caption.show { opacity: .7; }
#caption.bright { opacity: .95; color: var(--fg); }
#hud { transition: opacity .4s; }
body.celebrate #hud { opacity: .12; }
.album figure { margin: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.album figure img { width: 100%; height: min(62dvh, 640px); object-fit: contain; border-radius: 10px; background: rgba(0,0,0,.35); }
.album figure button { font-size: 22px; padding: 10px 12px; }
.album figure img { cursor: zoom-in; }
.card.over-card { width: min(600px, 100%); text-align: center; max-height: calc(100dvh - 32px); overflow: auto; }
.over-photos { display: flex; flex-direction: column; gap: 8px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px; }
.over-photos .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.over-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; max-height: 42dvh; overflow: auto; padding: 2px; }
.over-grid button { padding: 0; border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; background: rgba(255,255,255,.04); }
.over-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.over-grid span { font-size: 11px; color: var(--muted); padding: 4px 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.over-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 4px; }
.over-actions button.play { min-width: 0; }
.over-actions kbd { margin-left: 6px; font-size: 11px; opacity: .75; }
@media (hover: none) { .over-actions kbd { display: none; } }
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000; color: var(--fg); overflow: hidden; }
dialog.viewer::backdrop { background: #000; }
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-out; }
.viewer .vnav, .viewer .vclose { position: absolute; background: rgba(0,0,0,.45); border-color: rgba(255,255,255,.18); }
.viewer .vnav { top: 50%; transform: translateY(-50%); font-size: 26px; padding: 12px 16px; }
.viewer .prev { left: max(12px, env(safe-area-inset-left)); }
.viewer .next { right: max(12px, env(safe-area-inset-right)); }
.viewer .vclose { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); padding: 6px 12px; }
.viewer .vcap { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0;
  padding: 4px 12px; border-radius: 999px; background: rgba(0,0,0,.5); color: var(--muted); font-size: 13px; letter-spacing: .06em; white-space: nowrap; }
.album-cap { text-align: center; color: var(--muted); font-size: 13px; letter-spacing: .06em; margin: 8px 0; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; justify-content: safe center; }
.strip button { padding: 0; border-radius: 8px; overflow: hidden; flex: 0 0 auto; opacity: .55; border-width: 2px; }
.strip button[aria-current=true] { opacity: 1; border-color: var(--accent); }
.strip img { display: block; width: 56px; height: 56px; object-fit: cover; }

/* overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(5,6,10,.25), rgba(5,6,10,.65)); }
.overlay[hidden] { display: none; }
.card { background: var(--card); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 20px; padding: 28px; width: min(440px, 100%);
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.card.small { width: min(320px, 100%); text-align: center; }
h1 { margin: 0; font-size: 44px; letter-spacing: .02em; font-weight: 700;
  background: linear-gradient(120deg, #cfe0ff, #b59cff 60%, #ffc6a8); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 18px 0 6px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sub { margin: -6px 0 4px; color: var(--muted); }
.block { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.pick-label { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
/* Choice cards: the selected one is filled, outlined in the accent colour and shows a checked radio dot. */
.modes button, .exp button { position: relative; color: var(--muted); }
.modes button .opt-name, .exp button .opt-name { color: var(--fg); padding-right: 22px; }
.modes button::after, .exp button::after { content: ''; position: absolute; top: 10px; right: 10px; width: 14px; height: 14px;
  border-radius: 50%; border: 1.5px solid rgba(255,255,255,.35); box-sizing: border-box; }
.modes button[aria-checked=true], .exp button[aria-checked=true] { background: rgba(143,184,255,.22); border: 1.5px solid #8fb8ff;
  box-shadow: 0 0 0 3px rgba(143,184,255,.15); }
.modes button[aria-checked=true]::after, .exp button[aria-checked=true]::after { border: 4px solid #8fb8ff; background: #0d0f16; }
.modes button[aria-checked=false], .exp button[aria-checked=false] { opacity: .78; }
.resume { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px; text-align: left;
  background: linear-gradient(135deg, rgba(143,184,255,.55), rgba(181,156,255,.5)); border-color: rgba(190,205,255,.7);
  box-shadow: 0 6px 24px rgba(143,184,255,.22); }
.resume:hover { background: linear-gradient(135deg, rgba(143,184,255,.7), rgba(181,156,255,.65)); }
.resume-main { font-size: 19px; font-weight: 700; }
.resume-main kbd { margin-left: 6px; font-size: 11px; opacity: .75; vertical-align: 2px; }
.resume-sub { font-size: 13px; color: rgba(233,236,243,.85); }
button.play.secondary { background: rgba(255,255,255,.08); border-color: var(--line); box-shadow: none; font-size: 16px; padding: 11px 18px; }
@media (hover: none) { .resume-main kbd { display: none; } }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.modes button { display: flex; flex-direction: column; align-items: flex-start; padding: 11px 13px; font-size: 16px; font-weight: 600; text-align: left; }
.modes small { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.modes button[aria-checked=true] { border-color: rgba(143,184,255,.65); background: rgba(143,184,255,.16); }
.play-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
button.play { flex: 0 0 auto; min-width: 46%; padding: 14px 22px; font-size: 19px; font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(135deg, rgba(143,184,255,.55), rgba(181,156,255,.5)); border-color: rgba(190,205,255,.7);
  box-shadow: 0 6px 24px rgba(143,184,255,.22); }
button.play:hover { background: linear-gradient(135deg, rgba(143,184,255,.7), rgba(181,156,255,.65)); }
button.play kbd { margin-left: 6px; font-size: 11px; opacity: .75; vertical-align: 2px; }
@media (hover: none) { button.play kbd { display: none; } }
.exp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.exp button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 9px 11px; font-weight: 600; }
.exp small { font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.exp button::after { top: 9px; right: 8px; }
.exp button[aria-checked=true] { border-color: rgba(143,184,255,.65); background: rgba(143,184,255,.16); }
@media (max-width: 420px) { .exp small { display: none; } .exp button { align-items: flex-start; } }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > button { flex: 1; }
.pill { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: rgba(143,184,255,.2); font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.bests { color: var(--muted); font-size: 13px; margin: 0; }
.big { font-size: 40px; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
label.inline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
select, input[type=text], input[type=number], input[type=date] {
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

/* dialogs */
dialog.panel { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); padding: 20px 22px 24px;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 20px 70px rgba(0,0,0,.55); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(4,5,8,.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dlg-head button { padding: 4px 10px; }
.settings { display: flex; flex-direction: column; gap: 10px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.settings label.check { justify-content: flex-start; }
.settings input[type=range] { width: 46%; accent-color: var(--accent); }
.settings input[type=number] { width: 80px; }
label.stack { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.drop { border: 1.5px dashed rgba(255,255,255,.2); border-radius: 14px; padding: 18px; margin: 14px 0;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; text-align: center; }
.drop p { margin: 0; color: var(--muted); }
.albumlink .row { margin-top: 8px; }
.albumlink input[type=url], .albumlink input[type=text], #gClientId { flex: 3; min-width: 0; width: 100%; }
.albumlink .row > button { flex: 0 0 auto; }
#shareUrl { margin-top: 8px; font-size: 12px; color: var(--muted); }
details.adv { margin-top: 8px; font-size: 13px; color: var(--muted); }
details.adv summary { cursor: pointer; }
a { color: var(--accent); }
.note { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.tile.remote .del { display: none; }
.drop.over { border-color: var(--accent); background: rgba(143,184,255,.08); }
details.gp { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
details.gp summary { cursor: pointer; font-weight: 600; }
details.gp[open] summary { margin-bottom: 8px; }
.status { min-height: 1.4em; font-size: 13px; color: var(--accent); margin: 10px 0 0; white-space: pre-line; }
.lib-head { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 8px; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tile { position: relative; border-radius: 10px; overflow: hidden; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.tile .meta { display: flex; align-items: center; gap: 4px; padding: 4px 6px; font-size: 11px; color: var(--muted); }
.tile input[type=date] { width: 100%; padding: 2px 4px; font-size: 11px; border: 0; background: transparent; color: var(--muted); }
.tile .era { position: absolute; top: 6px; left: 6px; font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(0,0,0,.6); }
.tile .del { position: absolute; top: 4px; right: 4px; padding: 1px 7px; font-size: 12px; background: rgba(0,0,0,.6); opacity: 0; }
.tile:hover .del, .tile .del:focus-visible { opacity: 1; }
@media (hover: none) { .tile .del { opacity: .8; } }
table.keys { width: 100%; border-collapse: collapse; }
table.keys td { padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.keys td:first-child { white-space: nowrap; width: 45%; }
.nojs { padding: 20px; }
#stats.row { grid-template-columns: repeat(4, 1fr); align-items: end; }
#stats.row .best { display: none; }
body.portrait #caption { left: auto; transform: none; }
body.portrait .icon-btn { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); }
body.portrait #hud .label { font-size: 10px; }
@media (max-width: 520px) {
  .card { padding: 20px; }
  h1 { font-size: 36px; }
  #stats b { font-size: 16px; }
  #stats { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { #toast, #caption { transition: none; } }
#menuShareStatus:empty { display: none; }
