:root {
  --bg: #0b0a0c;
  --panel: #16130f;
  --gold: #e6c37a;
  --gold-dark: #9a7432;
  --red: #a8281d;
  --text: #f4ecdc;
  --muted: rgba(244, 236, 220, 0.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #2a0d0a 0%, var(--bg) 60%) fixed;
  color: var(--text);
  font: 500 18px/1.45 "Barlow Semi Condensed", system-ui, sans-serif;
}
.wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 40px; }
.lang { font-size: 14px; color: var(--muted); }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1 { font: 700 34px Cinzel, serif; color: var(--gold); letter-spacing: 3px; margin: 0; }
#user { display: flex; align-items: center; gap: 10px; }
#user img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--gold-dark); }
a { color: var(--gold); }
.lead { font-size: 24px; }
.hint { color: var(--muted); font-size: 15px; }
section { margin-top: 28px; }
button, select, input, .steam-btn {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid rgba(230, 195, 122, 0.3); border-radius: 6px; padding: 9px 14px;
}
button { cursor: pointer; }
button:hover, .card:hover { border-color: var(--gold); }
.steam-btn {
  display: inline-block; text-decoration: none; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(180deg, #b8342a, #7a1a12); border-color: #d9564b; padding: 12px 22px;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.row input { flex: 1; min-width: 200px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card {
  display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; column-gap: 12px;
  text-align: left; padding: 10px; align-items: center;
}
.card img { grid-row: span 2; width: 52px; height: 52px; border-radius: 6px; }
.card .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { color: var(--muted); font-size: 14px; }
.card.solo { display: block; width: 100%; margin-bottom: 8px; background: linear-gradient(90deg, #2b220f, var(--panel)); }
.card.solo .meta { margin-left: 10px; }
.live { color: #6fd38a; font-style: normal; font-size: 12px; }
#job { text-align: center; padding: 60px 0; }
.spinner {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid rgba(230, 195, 122, 0.2); border-top-color: var(--gold); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
#summary { background: var(--panel); border: 1px solid rgba(230, 195, 122, 0.2); border-radius: 8px; padding: 18px 18px 18px 40px; }
#summary li { margin: 4px 0; }
pre { max-height: 400px; overflow: auto; font-size: 12px; background: #000; padding: 12px; }
.disclaimer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 16px 16px; margin: 0; }

/* reel page */
.reel-page { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #000; overflow: hidden; height: 100vh; height: 100dvh; }
#stage { position: relative; background: #000; overflow: hidden; }
#stage:fullscreen { width: 100vw !important; height: 100vh !important; display: flex; align-items: center; justify-content: center; }
#reel { width: 100%; height: 100%; display: block; object-fit: contain; }
#progress { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 4px; z-index: 3; pointer-events: none; }
#progress span { flex: 1; height: 3px; background: rgba(255, 255, 255, 0.25); border-radius: 2px; overflow: hidden; }
#progress i { display: block; height: 100%; width: 0; background: #fff; }
.tap { position: absolute; background: transparent; border: 0; padding: 0; border-radius: 0; -webkit-tap-highlight-color: transparent; }
.tap:hover { border: 0; }
#tap-top { top: 0; left: 0; right: 0; height: 18%; z-index: 2; }
#tap-prev { left: 0; top: 18%; bottom: 0; width: 28%; }
#tap-next { right: 0; top: 18%; bottom: 0; width: 28%; }
#tap-mid { left: 28%; right: 28%; top: 18%; bottom: 0; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--gold); min-width: 300px; min-height: 200px; }

/* icon buttons */
.icon {
  width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.12); color: #fff;
  -webkit-tap-highlight-color: transparent; backdrop-filter: blur(4px);
}
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover { border-color: var(--gold); color: var(--gold); }
#controls { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 12px; }
#controls select { font-size: 14px; padding: 8px 10px; border-radius: 22px; height: 44px; }

#volume { position: absolute; top: calc(24px + env(safe-area-inset-top)); right: 12px; z-index: 6; display: flex; align-items: center; gap: 6px; }
#vol-slider { width: 0; opacity: 0; transition: width .2s, opacity .2s; accent-color: var(--gold); }
#volume:hover #vol-slider, #volume:focus-within #vol-slider { width: 90px; opacity: 1; }
#side-actions { display: none; }

#speed-badge { position: absolute; top: calc(28px + env(safe-area-inset-top)); left: 16px; z-index: 6; padding: 4px 10px; border-radius: 12px; background: rgba(0,0,0,0.55); color: var(--gold); font: 700 18px "Barlow Semi Condensed", sans-serif; pointer-events: none; }
#speed-badge[hidden], #flash[hidden], #toast[hidden], #big-play[hidden], #volume[hidden] { display: none; }
#flash { position: absolute; inset: 0; margin: auto; width: 110px; height: 110px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; display: grid; place-items: center; pointer-events: none; opacity: 0; z-index: 4; }
#flash.show { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: 1; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.25); } }
#toast {
  position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 8;
  max-width: 86%; padding: 10px 16px; border-radius: 22px; background: rgba(0,0,0,0.75); color: #fff; text-align: center;
  font: 600 15px "Barlow Semi Condensed", sans-serif; pointer-events: none;
}

#big-play {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.7) 70%); border: 0; border-radius: 0;
  color: #fff; cursor: pointer; font: 700 20px "Barlow Semi Condensed", sans-serif; letter-spacing: 1px;
}
#big-play svg { width: 110px; height: 110px; padding: 22px 18px 22px 26px; border-radius: 50%; background: rgba(0,0,0,0.45); border: 2px solid var(--gold); color: var(--gold); box-shadow: 0 0 40px rgba(230,195,122,0.35); transition: transform .15s; }
#big-play:hover svg { transform: scale(1.08); }
#big-play:hover { border: 0; }
#big-play span { text-shadow: 0 2px 8px #000; font-size: 22px; }

/* phone: full-screen reel, only volume + download + share */
body.mobile #stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; }
body.mobile #controls, body.mobile .disclaimer { display: none; }
body.mobile #side-actions {
  display: flex; flex-direction: column; gap: 14px; position: absolute; z-index: 6;
  right: 12px; bottom: calc(70px + env(safe-area-inset-bottom));
}
body.mobile .icon { width: 50px; height: 50px; }
body.mobile .icon svg { width: 26px; height: 26px; }
body.mobile #vol-slider { display: none; }
body.recording .tap { pointer-events: none; }
body.recording .act-download { animation: pulse 1.2s ease-in-out infinite; color: var(--gold); border-color: var(--gold); }
@keyframes pulse { 50% { box-shadow: 0 0 14px rgba(230,195,122,0.7); } }

/* no text selection / callout on long press */
#stage, #stage * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
body.holding #progress, body.holding #side-actions, body.holding #volume, body.holding #speed-badge { opacity: 0; transition: opacity .15s; }
#debug { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 9; margin: 0; padding: 8px; background: rgba(0,0,0,0.8); color: #9f9; font: 11px/1.4 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }
.lang-code { font: 700 15px "Barlow Semi Condensed", sans-serif; letter-spacing: 1px; }
body.mobile .lang-code { font-size: 17px; }
