/* ─── Base ───────────────────────────────────────────────────────────── */
:root {
  --hl: #ffd23f;              /* sung-part highlight */
  --panel: rgba(12, 12, 16, 0.82);
  --border: rgba(255, 255, 255, 0.1);
}
*, *::before, *::after { box-sizing: border-box; }
.hidden { display: none !important; }

body { background: #0d0d12; color: #fff; font-family: 'Segoe UI', system-ui, sans-serif; }
body.page-player { margin: 0; height: 100vh; overflow: hidden; }
body.page-app { min-height: 100vh; padding-top: 64px; background: #101018; }

/* ─── Navbar ─────────────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: opacity .4s ease;
}
body.idle .navbar, body.idle #controls { opacity: 0; pointer-events: none; }
body.idle { cursor: none; }

/* ─── Background video ───────────────────────────────────────────────── */
#player-container { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: #000; }
#player { width: 100%; height: 100%; }
#player-container iframe {
  position: absolute; top: 50%; left: 50%;
  width: 100vw; height: 56.25vw;            /* 16:9, cover the screen */
  min-height: 100vh; min-width: 177.78vh;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#gradient-overlay {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.65) 100%),
    linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 45%);
}

/* ─── Start screen ───────────────────────────────────────────────────── */
#start-screen {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto;
  padding: 96px 16px 48px;
  background: radial-gradient(ellipse at top, #2a1846 0%, #0d0d12 65%);
}
.start-inner { max-width: 680px; margin: 0 auto; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 10px; background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: #fff; text-decoration: none; min-width: 0;
}
.recent-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.recent-item img, .recent-item .ak-art-placeholder { width: 44px; height: 44px; border-radius: 6px; flex-shrink: 0; object-fit: cover; }
.ak-art-placeholder {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5); font-size: 1.2rem;
}
.ak-picker-results { max-height: 55vh; overflow-y: auto; }

/* ─── Status card / intro ────────────────────────────────────────────── */
#status-card {
  position: fixed; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
}
.status-inner {
  display: flex; gap: 18px; align-items: flex-start;
  background: var(--panel); backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 16px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
#status-art { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }

#intro-card {
  position: fixed; z-index: 15; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; pointer-events: none; animation: fade-in .6s ease;
}
#intro-singer {
  display: inline-block; margin-bottom: .4em; padding: .15em .7em; border-radius: 999px;
  font-size: clamp(1.6rem, 5vw, 3.8rem); font-weight: 800; color: #111; background: var(--hl);
  box-shadow: 0 6px 30px rgba(0,0,0,.6); animation: pop-in .5s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.status-singer { font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 800; color: var(--hl); line-height: 1.2; margin-bottom: .2em; }
#intro-title { font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 800; text-shadow: 0 4px 30px #000; }
#intro-artist { font-size: clamp(1.1rem, 3vw, 2rem); opacity: .8; text-shadow: 0 2px 16px #000; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─── Lyrics ─────────────────────────────────────────────────────────── */
#lyrics {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 16vh;
  display: flex; flex-direction: column; align-items: center; gap: .35em;
  padding: 0 6%; pointer-events: none; text-align: center;
}
.line {
  width: 100%; line-height: 1.25; font-weight: 800; letter-spacing: .01em;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.95)) drop-shadow(0 0 2px rgba(0,0,0,1));
  min-height: 1.25em;
}
.line.prev, .line.next { font-size: clamp(1.1rem, 2.8vw, 2rem); color: rgba(255,255,255,.55); }
.line.prev { opacity: .6; }
.line.cur { font-size: clamp(1.7rem, 5vw, 3.6rem); color: #fff; }
/* Each word fills on its own, so wrapped lines fill top row first, then the next. */
.line.cur .w {
  --p: 0%;
  background: linear-gradient(90deg, var(--hl) var(--p), #fff var(--p));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.line.cur.waiting { color: rgba(255,255,255,.9); }
.line.cur.waiting .w { background: none; color: inherit; }
.line.cur.enter { animation: line-in .22s ease-out; }
@keyframes line-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.countdown { font-size: 1.6rem; letter-spacing: .4em; color: var(--hl); min-height: 1.6rem; filter: drop-shadow(0 2px 6px #000); }

/* ─── Toast ──────────────────────────────────────────────────────────── */
#toast {
  position: fixed; z-index: 60; top: 72px; left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 16px; font-size: .95rem; backdrop-filter: blur(10px);
}

/* ─── Tap-sync panel ─────────────────────────────────────────────────── */
#tap-panel {
  position: fixed; z-index: 45; top: 72px; right: 16px; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  font-size: .9rem;
}
body.tapping .line.cur { color: var(--hl); }

/* ─── Controls ───────────────────────────────────────────────────────── */
#controls {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: .6rem;
  padding: .6rem 1rem;
  background: rgba(0,0,0,.78); backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,.07);
  transition: opacity .4s ease;
}
.ctrl-btn {
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.18); border-radius: 7px;
  padding: .3rem .8rem; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.ctrl-btn:hover { background: rgba(255,255,255,.2); }
.ctrl-group { display: flex; align-items: center; gap: .3rem; }
.offset-label { font-size: .8rem; color: rgba(255,255,255,.7); min-width: 84px; text-align: center; font-variant-numeric: tabular-nums; }
.time { font-size: .8rem; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
#seek { flex: 1; min-width: 120px; accent-color: var(--hl); cursor: pointer; }

@media (max-width: 640px) {
  #lyrics { bottom: 22vh; }
  #controls { gap: .4rem; padding: .5rem; }
  #seek { order: -1; flex-basis: 100%; }
}

/* ─── App pages (library / rooms) ────────────────────────────────────── */
.song-card { background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.song-card img.art, .song-card .ak-art-placeholder { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.song-card .detail { font-size: .8rem; color: rgba(255,255,255,.6); }
.cand-row.current { background: rgba(255, 210, 63, .08); }
.lrc-editor { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.queue-item .handle { color: rgba(255,255,255,.4); font-variant-numeric: tabular-nums; width: 1.5rem; }

/* ─── No-instrumental notice + instrumental picker ───────────────────── */
#no-inst {
  position: fixed; z-index: 55; top: 64px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid rgba(255, 210, 63, .45); border-radius: 12px;
  padding: 8px 12px; font-size: .95rem; backdrop-filter: blur(10px);
}
body.idle #no-inst { opacity: .35; }
#picker-drawer {
  position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(440px, 100vw);
  overflow-y: auto; padding: 16px;
  background: rgba(14, 14, 20, .96); border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .5);
}

/* ─── Party corner (room join QR) ────────────────────────────────────── */
#party {
  position: fixed; z-index: 35; top: 72px; right: 16px; width: min(380px, calc(100vw - 32px));
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px;
  backdrop-filter: blur(10px); font-size: .9rem;
}
.party-qr { width: 112px; height: 112px; flex-shrink: 0; background: #fff; border-radius: 8px; overflow: hidden; }
.party-qr svg, .wait-qr svg { width: 100%; height: 100%; display: block; }
.party-info { flex: 1; min-width: 0; }
.party-title { font-weight: 600; }
.party-title b { color: var(--hl); letter-spacing: .12em; }
.party-url { font-size: .75rem; color: rgba(255,255,255,.6); word-break: break-all; margin: 2px 0 6px; }
.party-next { color: rgba(255,255,255,.85); }
#party .btn-close { flex-shrink: 0; font-size: .7rem; }
#party-pill { position: fixed; z-index: 35; top: 72px; right: 16px; }
body.idle #party-pill { opacity: .5; }
.wait-qr { width: 200px; margin: 4px 0 12px; }
.wait-qr svg { width: 200px; height: 200px; background: #fff; border-radius: 10px; }
@media (max-width: 640px) { #party { display: none !important; } }

/* ─── Phone pages (join / host) ──────────────────────────────────────── */
body.page-join { min-height: 100vh; background: radial-gradient(ellipse at top, #2a1846 0%, #101018 60%); }
.join { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
.join-head { margin-bottom: 16px; }
.join-card { background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.join-now { margin-top: 6px; }
.join-mine { border-left: 3px solid var(--hl); }
.join .ak-picker-results { max-height: none; }
.join .ak-picker-input { font-size: 1rem; }
body.page-join #toast { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }
.join-box { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.join-code { color: var(--hl); letter-spacing: .15em; font-size: 1.2rem; }
.join-turn { border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; text-align: center; }
.join-turn-big { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.join-turn-now { background: var(--hl); color: #111; animation: turn-pulse 1.2s ease-in-out infinite; }
.join-turn-next { background: rgba(255, 210, 63, .14); border: 1px solid rgba(255, 210, 63, .6); color: var(--hl); }
@keyframes turn-pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 210, 63, .25); } }
