:root {
  --bg: #000;
  --panel: #141414;
  --panel-2: #1f1f1f;
  --ink: #f2f2f2;
  --quiet: #9a9a9a;
  --dim: #5c5c5c;
  --accent: #e0302a;
  --amber: #8a5a1c;
  --amber-bright: #b87a2a;
  --radius: 16px;
  --tap: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app { min-height: 100%; }

button {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 0;
  border-radius: var(--radius);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 20px;
  cursor: pointer;
}
button:active { filter: brightness(1.4); }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; color: var(--quiet); }

/* ---------- Home ---------- */
.home {
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  max-width: 980px;
  margin: 0 auto;
}
.home header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.home h1 { font-size: 26px; margin: 0; font-weight: 700; }
.home h2 { font-size: 15px; color: var(--quiet); font-weight: 600; margin: 24px 0 10px; text-transform: uppercase; letter-spacing: .06em; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 84px; padding: 14px 18px; text-align: left; background: var(--panel);
}
.mode strong { font-size: 20px; }
.mode span { color: var(--quiet); font-size: 14px; margin-top: 4px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  background: var(--panel); text-align: left;
}
.tile canvas { width: 100%; aspect-ratio: 4 / 3; display: block; background: #000; }
.tile .label { padding: 10px 12px 12px; font-size: 15px; font-weight: 600; line-height: 1.25; }
.tile .label small { display: block; color: var(--quiet); font-weight: 400; font-size: 12px; margin-top: 2px; }

/* ---------- Stage (Sing / Look) ---------- */
.stage {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: #000;
}
.stage canvas.scene { flex: 1 1 auto; width: 100%; min-height: 0; display: block; }
.stage .topbar {
  position: absolute; top: calc(8px + var(--safe-top)); left: 8px; right: 8px;
  display: flex; justify-content: space-between; gap: 8px; z-index: 2;
}
.stage .topbar button {
  background: rgba(30, 30, 30, .75);
  color: var(--quiet);
  font-size: 15px;
  padding: 0 12px;
  white-space: nowrap;
}
.stage .topbar .group { display: flex; gap: 6px; }

.lyrics {
  flex: 0 0 auto;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: #000;
  border-top: 1px solid #1a1a1a;
  text-align: center;
}
.lyrics .line { margin: 2px 0; line-height: 1.3; transition: color .4s; }
.lyrics .prev, .lyrics .next { color: var(--dim); font-size: 15px; min-height: 20px; }
.lyrics .now { color: #c8c8c8; font-size: 22px; font-weight: 600; min-height: 30px; }
.lyrics .cue { color: var(--accent); opacity: .8; font-size: 13px; margin-top: 6px; min-height: 17px; }
.lyrics .controls { display: flex; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.lyrics .controls button { min-height: 44px; font-size: 14px; color: var(--quiet); background: var(--panel); }

.stage.big-lyrics .lyrics { flex: 0 0 55%; display: flex; flex-direction: column; justify-content: center; }
.stage.big-lyrics .lyrics .now { font-size: 34px; }
.stage.big-lyrics .lyrics .prev, .stage.big-lyrics .lyrics .next { font-size: 20px; }
.stage.no-lyrics .lyrics .prev,
.stage.no-lyrics .lyrics .now,
.stage.no-lyrics .lyrics .next,
.stage.no-lyrics .lyrics .cue { display: none; }

.pause-note { color: var(--dim); font-size: 14px; font-style: italic; min-height: 18px; }

/* ---------- Lullaby ---------- */
.lullaby {
  position: fixed; inset: 0;
  background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  color: var(--amber);
}
.lullaby .title { font-size: 14px; color: #4a3210; margin-bottom: 18px; }
.lullaby .now { font-size: 26px; line-height: 1.35; color: var(--amber-bright); min-height: 70px; transition: opacity 1s; }
.lullaby .next { font-size: 17px; color: #4a3210; margin-top: 10px; min-height: 24px; }
.lullaby .bar {
  position: absolute; left: 0; right: 0; bottom: calc(12px + var(--safe-bottom));
  display: flex; justify-content: center; gap: 10px;
}
.lullaby .bar button { background: #0d0905; color: #5a3d14; min-height: 48px; }
.lullaby .remaining { position: absolute; top: calc(14px + var(--safe-top)); right: 18px; font-size: 13px; color: #3a2709; }

.picker { max-width: 520px; width: 100%; color: var(--ink); }
.picker h1 { font-size: 22px; margin: 0 0 6px; }
.picker p { color: var(--quiet); margin: 0 0 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 18px; }
.chips button[aria-pressed="true"] { background: var(--amber); color: #000; font-weight: 600; }

/* ---------- Overlay (session end, song end) ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(0, 0, 0, 0);
  opacity: 0; pointer-events: none;
  transition: opacity 4s ease, background 4s ease;
  text-align: center; padding: 24px;
}
.overlay.show { opacity: 1; pointer-events: auto; background: rgba(0, 0, 0, .92); }
.overlay h2 { margin: 0; font-size: 24px; }
.overlay p { margin: 0; color: var(--quiet); }
.overlay .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- Settings / editor ---------- */
.sheet {
  padding: calc(16px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
  max-width: 640px; margin: 0 auto;
  -webkit-user-select: text; user-select: text;
}
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet h1 { font-size: 24px; margin: 0; }
.field { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { color: var(--quiet); font-size: 13px; margin-bottom: 10px; }
.field input[type="text"], .field textarea, .field select {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: #000; border: 1px solid #333; border-radius: 10px; padding: 12px;
}
.field textarea { min-height: 220px; line-height: 1.4; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field .value { color: var(--quiet); font-size: 14px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { width: 28px; height: 28px; accent-color: var(--accent); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #262626; }
.list-row:first-of-type { border-top: 0; }
.danger { color: var(--accent); }

/* Tummy time (F11): the scene fills only the lower third, where she can see it with her head up. */
.stage.tummy::before { content: ''; flex: 2 1 0; background: #000; }
.stage.tummy canvas.scene { flex: 1 1 0; }
