:root {
  /* the day look: a pale studio; the evening look is chosen with the switch beside Home, or by the device */
  --bg: #f6f1ea;
  --bg2: #e9e1d6;
  --ink: #241f2a;
  --inkDim: #5f5662;
  --line: #c7bcae;
  /* the house amber (game-ui-colour §2): filled on the next thing to do only */
  --accent: #a26a00;
  --accentBorder: #a26a00;
  --accentInk: #ffffff;
  --sel: #ddd3c4;
  --selRing: #241f2a;
  --stageBg: #d9d2c8;
  --shade: rgba(246, 241, 234, 0.94);
  --toastBg: #241f2a;
  --toastInk: #ffffff;
  --star: #9a6400;
  --good: #1f7a3a;
  --bad: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17151c;
    --bg2: #252230;
    --ink: #f1ecf4;
    --inkDim: #b3aabb;
    --line: #433d50;
    --accent: #ffb338;
    --accentBorder: #ffd27a;
    --accentInk: #3a2204;
    --sel: #3a3448;
    --selRing: #f1ecf4;
    --stageBg: #0b0a0f;
    --shade: rgba(23, 21, 28, 0.92);
    --toastBg: #f6f1ea;
    --toastInk: #17151c;
    --star: #ffd166;
    --good: #5fd07a;
    --bad: #ff8a80;
  }
}
:root[data-theme="dark"] {
  --bg: #17151c;
  --bg2: #252230;
  --ink: #f1ecf4;
  --inkDim: #b3aabb;
  --line: #433d50;
  --accent: #ffb338;
  --accentBorder: #ffd27a;
  --accentInk: #3a2204;
  --sel: #3a3448;
  --selRing: #f1ecf4;
  --stageBg: #0b0a0f;
  --shade: rgba(23, 21, 28, 0.92);
  --toastBg: #f6f1ea;
  --toastInk: #17151c;
  --star: #ffd166;
  --good: #5fd07a;
  --bad: #ff8a80;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink); user-select: none; -webkit-user-select: none; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 1100px); margin: 0 auto; }

#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#hdrHome { font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--inkDim); }

.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 14px; gap: 10px; min-height: 0; }
.scr.on { display: flex; }
.scrTitle { color: var(--ink); font-size: 22px; text-align: center; }

#scr-menu { align-items: center; text-align: center; justify-content: safe center; }
#scr-menu > * { flex-shrink: 0; }
#scr-menu h1 { font-size: clamp(28px, 8.5vw, 44px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; max-width: 36ch; }
.menuGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
button.big { width: 100%; border-radius: 16px; min-height: 52px; font-size: 18px; font-weight: 800; background: var(--bg2); color: var(--ink); border: 3px solid var(--line); cursor: pointer; font-family: inherit; padding: 6px 10px; }
button.big:active { transform: translateY(2px); }
button.big.danger { border-color: var(--bad); color: var(--bad); }
button.big.primary { background: var(--accent); border-color: var(--accentBorder); color: var(--accentInk); }
button.big:disabled { opacity: 0.5; cursor: default; }
button.big[hidden] { display: none; }
#statsLine { color: var(--inkDim); font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg button { flex: 1; min-height: 44px; min-width: 56px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 800; font-size: 15px; font-family: inherit; cursor: pointer; }
.seg button.sel { border-color: var(--selRing); background: var(--sel); }

/* the brief card */
.card2 { background: var(--bg2); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; line-height: 1.45; display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
.card2 h2 { font-size: 19px; }
#briefRules { padding-left: 22px; font-weight: 700; }
#briefDress { font-weight: 700; }
.tipBox { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.setRow { display: flex; flex-direction: column; gap: 6px; }
.setNote { color: var(--inkDim); font-weight: 600; font-size: 14px; text-align: center; }

/* designing: the brief's rules, the picture, the tabs under it and the choices of the tab picked */
#scr-design { padding: 4px 8px 8px; gap: 6px; overflow: hidden; }
#briefBar { flex: none; font-size: 14px; font-weight: 700; line-height: 1.3; display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--inkDim); }
#briefBar .barHead { width: 100%; color: var(--ink); }
#briefBar .rule.ok { color: var(--good); }
.stageSlot { flex: 3 1 0; min-height: 150px; display: flex; }
#stageWrap { position: relative; flex: 1; border-radius: 14px; overflow: hidden; background: var(--stageBg); touch-action: none; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 30px; pointer-events: none; }
#glFail { position: absolute; inset: 12px; display: flex; align-items: center; justify-content: center; text-align: center; background: var(--shade); color: var(--ink); border-radius: 14px; padding: 16px; font-weight: 700; }
#glFail[hidden] { display: none; }
/* R7.10 over the picture from a tap until her first frame on that screen is drawn (painted only when that frame builds her
   or the hall again; otherwise it comes off before the screen is painted) */
#stageWait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--stageBg); color: var(--ink); font-weight: 700; font-size: 18px; pointer-events: none; visibility: hidden; }
#stageWait.on { visibility: visible; }
#fpsNow { position: absolute; top: 6px; left: 8px; font: 700 12px ui-monospace, monospace; color: var(--ink); background: var(--shade); border-radius: 6px; padding: 2px 6px; pointer-events: none; }
#fpsNow[hidden] { display: none; }
#tabs { flex: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.tab { min-height: 44px; min-width: 0; border-radius: 12px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-weight: 800; font-size: 13px; font-family: inherit; cursor: pointer; padding: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.sel { border-color: var(--selRing); background: var(--sel); }
/* the picture and the panel share what the screen has left, three to two; the panel scrolls, so 🎬 Walk the runway is
   always on the screen */
#panel { flex: 2 1 0; min-height: 92px; max-height: 36vh; max-height: 36dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.prow { display: flex; flex-direction: column; gap: 4px; }
.phead { font-weight: 800; font-size: 14px; color: var(--inkDim); }
.pnote { font-weight: 600; font-size: 14px; color: var(--inkDim); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 44px; min-width: 44px; padding: 4px 12px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }
.chip.sel { border-color: var(--selRing); background: var(--sel); }
.chip:disabled { opacity: 0.5; cursor: default; }
/* a swatch is the colour itself (content, not chrome); picked, it wears a ring */
.swatches { gap: 6px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; font-size: 16px; padding: 0; }
.sw.sel { outline: 3px solid var(--selRing); outline-offset: 2px; }
.sw:disabled { cursor: default; opacity: 0.55; }
.acts { flex: none; display: flex; gap: 8px; padding-bottom: env(safe-area-inset-bottom); }

#scr-show { padding: 4px 8px 8px; gap: 6px; overflow: hidden; }

/* the judges */
#scr-result { align-items: stretch; }
#resultBig { font-size: 40px; text-align: center; color: var(--star); letter-spacing: 2px; }
.judge .jstars { font-size: 22px; letter-spacing: 1px; }

/* the design-off: the pass screen hides both designs; the results show both looks */
#scr-pass, #scr-vote, #scr-duelres { align-items: stretch; }
#passBig, #duelBig { font-size: 52px; text-align: center; }
#passBrief .rules { padding-left: 22px; font-weight: 700; }
#passBrief .dress { font-weight: 700; }
#passBrief[hidden] { display: none; }
#briefBar .barClock { color: var(--ink); white-space: nowrap; }
#showWho { flex: none; color: var(--ink); font-size: 16px; }
#showWho[hidden] { display: none; }
#duelCards { display: flex; flex-direction: column; gap: 10px; }
#hdr .pill[hidden] { display: none; }
#voteLook h2 { font-size: 17px; }

/* a look to share, or one from a link (R15): her picture, what she wears, and the link to copy by hand */
#scr-look { align-items: stretch; }
#slotLook { flex: none; height: 40vh; height: 40dvh; min-height: 200px; max-height: 440px; }
#slotLook[hidden], #lookCard[hidden] { display: none; }
#lookHome[hidden] { display: none; }
#bookPaste { width: 100%; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: 600 15px ui-monospace, monospace; padding: 6px 10px; user-select: text; -webkit-user-select: text; }
#lookLink { width: 100%; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: 600 15px ui-monospace, monospace; padding: 6px 10px; user-select: text; -webkit-user-select: text; }
/* the link box appears while the screen is open (a copy refused), so its height is kept (R-C19) */
#lookLink[hidden] { display: block; visibility: hidden; }

/* the lookbook */
.bookCard h2 { font-size: 17px; }
.bookSw { display: flex; gap: 6px; flex-wrap: wrap; }
.bookSw span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: inline-block; }

/* help */
#glossary dt { font-weight: 800; margin-top: 6px; }
#glossary dd { margin: 0; }
#glossary .src { color: var(--inkDim); font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--toastBg); color: var(--toastInk); padding: 10px 16px; border-radius: 14px; font-weight: 800; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 90%; text-align: center; z-index: 10; font-size: 18px; }
#toast.on { opacity: 1; }
#footer { display: flex; justify-content: center; padding: 2px 0 calc(2px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { button.big:active { transform: none; } }
/* on a phone the six tabs go in two rows of three, so each name reads whole */
@media (max-width: 560px) { #tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
