/* Reading Maze's own parts (EdGames docs/family/READINGMAZE-DESIGN.md §4): the play screen and its HUD with the letter
   slots, the paper maze, the door card with its passage block, the logo, the Change sheet. The family's parts are in
   css/game.css. Comfort first: nothing shakes or flashes; Calm motion (html.calm) and reduced motion keep everything still. */
:root{ --door:#c98b4a; --door-edge:#8a5a2b; }
:root[data-theme="dark"]{ --door:#b57a3e; --door-edge:#e3b27a; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){ --door:#b57a3e; --door-edge:#e3b27a; } }

/* ----- play ----- */
.topbar{flex:none; display:flex; flex-direction:column; gap:6px; min-width:0; position:relative; z-index:6}
.hud{display:flex; align-items:center; gap:6px; flex-wrap:nowrap; min-height:36px}
/* the family HUD, Word Cube's pills (REVIEW-1 RM1): "Level 1", "0:42", "Doors 2/5", ≡ */
.lvl{font-family:var(--font-display); font-weight:600; border-radius:999px; background:var(--ink); color:var(--paper); white-space:nowrap; flex:0 1 auto; min-width:0; margin-right:auto; font-size:15px; padding:0 12px; min-height:36px; display:inline-flex; align-items:center; box-sizing:border-box; overflow:hidden; text-overflow:ellipsis}
.pill{flex:none; display:inline-flex; align-items:center; justify-content:center; min-height:36px; padding:0 12px; border-radius:999px; background:var(--panel); box-shadow:inset 0 0 0 1px var(--panel-line);
  font:600 16px/1 var(--font-display); font-variant-numeric:tabular-nums; color:var(--ink); white-space:nowrap; box-sizing:border-box}
.pill b{font-weight:600}
.iconbtn{flex:none; width:44px; height:44px; padding:0; border-radius:50%; border:1px solid var(--panel-line); background:var(--tile); font:700 20px/1 var(--font-display); color:var(--ink); touch-action:manipulation}
.team{display:flex; gap:3px; align-items:center}
.team .dot{width:24px; height:24px; border-radius:50%; display:grid; place-items:center; background:var(--c); overflow:hidden; font-size:13px}
.team .dot .cface{width:22px; height:22px; border-radius:50%; background:var(--tile); display:grid; place-items:center}
.team .dot.off{opacity:.4}
.slots{display:flex; justify-content:center; gap:6px; min-height:40px}
.slot{width:34px; height:40px; border-radius:9px; box-sizing:border-box; display:grid; place-items:center; border:2px dashed var(--slot-line); background:var(--slot);
  font:600 24px/1 var(--font-display); color:var(--ink)}
.slot.got{border:2px solid var(--ink); background:var(--tile); box-shadow:0 2px 0 var(--tile-edge)}
.slot.pop{animation:slotIn .32s cubic-bezier(.3,1.4,.5,1)}
@keyframes slotIn{0%{transform:scale(.6); opacity:.2}}
.slots.done .slot{border-color:var(--good)}
@media (max-width:380px){ .slot{width:28px; height:34px; font-size:20px} .slots{gap:4px} }
.stage{position:relative; flex:1; min-height:0}
.mazewrap{position:absolute; inset:0}
#maze{display:block; width:100%; height:100%; touch-action:none}

/* ----- the door card ----- */
.overlay.doorov{background:color-mix(in srgb, var(--paper) 35%, transparent); backdrop-filter:none; display:block; overflow:hidden;
  padding-top:max(16px, var(--hud, 0px), env(safe-area-inset-top, 0px))}
/* centred in the room below the HUD (src/door/card.js clearHud) */
.doorov .dcard{position:absolute; left:50%; top:calc((100% + max(16px, var(--hud, 0px), env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px))) / 2); translate:-50% -50%; width:calc(100% - max(32px, env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px) + 24px))}
/* a phone on its side: a passage door in two columns (the passage, then the question and its chips), so the card fits
   below the HUD at its own size and its chips stay at least 44 px tall (RM2) */
@media (min-aspect-ratio:5/4) and (max-height:520px){
  .dcard.haspass{max-width:820px; display:grid; grid-template-columns:minmax(0, 1.3fr) minmax(0, 1fr); column-gap:18px; row-gap:10px; align-items:center}
  .dcard.haspass .dpass{font-size:17px; line-height:1.4}
  .dcard.haspass .dq{font-size:19px}
  .dcard.haspass .dchip{font-size:16.5px; padding-top:8px; padding-bottom:8px}
  .dcard.haspass > .drule, .dcard.haspass > .dpass{grid-column:1}
  .dcard.haspass > .dpass{grid-row:1 / span 2; align-self:center}
  .dcard.haspass > .drule + .dpass{grid-row:2 / span 2}
  .dcard.haspass > .dq, .dcard.haspass > .dchips{grid-column:2}
  .dcard.haspass > .dq{align-self:end; text-align:left}
  .dcard.haspass > .dchips{align-self:start}
  .dcard:not(.haspass){max-width:600px}
  .dchip{min-height:48px}
}
.dcard{width:100%; max-width:520px; box-sizing:border-box; padding:16px 16px 14px; border-radius:22px; background:var(--tile); box-shadow:var(--lift);
  display:flex; flex-direction:column; gap:12px; transform-origin:50% 50%; outline:none}
.dpass{margin:0; font:600 19px/1.45 var(--font-body); text-align:left; color:var(--ink); text-wrap:pretty}
.dcard[data-skill="gap"] .dpass, .dcard[data-skill="sent-pic"] .dpass{font-size:22px; text-align:center}
.dpass .gap{display:inline-block; width:3.2em; height:.9em; border-bottom:3px solid var(--ink); vertical-align:baseline; margin:0 .15em}
.dpass .ev.under{text-decoration:underline; text-decoration-thickness:3px; text-underline-offset:4px; text-decoration-color:var(--ink)}
.drule{margin:0; text-align:center; font:600 16px/1.3 var(--font-display); color:var(--muted)}
.dshowrow{display:flex; align-items:center; justify-content:center; gap:12px}
.dshow{text-align:center; font:600 72px/1 var(--font-display); color:var(--ink); letter-spacing:.04em}
.dshow.word{font-size:56px; letter-spacing:.06em}
.dsay{width:52px; height:52px; border-radius:50%; border:0; background:var(--given); font-size:26px; touch-action:manipulation}
.dq{margin:0; text-align:center; font:600 21px/1.25 var(--font-display); color:var(--ink); text-wrap:balance}
.dcard.maths .dq{font-size:34px}
.dchips{display:flex; flex-direction:column; gap:10px}
.dchips.row{flex-direction:row}
.dchips.row .dchip{flex:1 1 0; min-width:0; justify-content:center; min-height:64px}
.dchip{position:relative; display:flex; align-items:center; gap:10px; min-height:52px; padding:10px 40px 10px 16px; border:0; border-radius:16px; background:var(--given);
  color:var(--ink); box-shadow:0 4px 0 var(--tile-edge); text-align:left; font:700 18px/1.25 var(--font-body); touch-action:manipulation; cursor:pointer}
.dchips.row .dchip{padding:10px 12px; font:600 24px/1 var(--font-display); text-align:center}
.dchips.row .dchip .dt{white-space:nowrap}
.dcard.pics .dchip{font-size:44px; min-height:84px}
.dchip .dt{flex:1; min-width:0}
.dchip .dk{position:absolute; right:10px; top:50%; transform:translateY(-50%); font:700 12px/1 var(--font-body); color:var(--muted); opacity:.8}
.dchips.row .dchip .dk{top:8px; right:8px; transform:none}
.dchip:active{transform:translateY(3px); box-shadow:0 1px 0 var(--tile-edge)}
.dchip.out{opacity:.4; box-shadow:none; transform:none; cursor:default}
.dchip.out .dt{text-decoration:line-through; text-decoration-thickness:3px}
.dcard.pics .dchip.out::after{content:''; position:absolute; left:18%; right:18%; top:50%; border-top:4px solid var(--ink); transform:rotate(-20deg)}
.dchip.right::before{content:'✓'; position:absolute; left:10px; top:6px; font:700 16px/1 var(--font-display); color:var(--ink)}
.dchip:focus-visible{outline:3px solid var(--you); outline-offset:2px}
.frac{display:inline-flex; flex-direction:column; align-items:center; vertical-align:middle; font-size:.72em; line-height:1.05; margin:0 .08em}
.frac .fn{border-bottom:2px solid currentColor; padding:0 .12em}
.frac .fd{padding:0 .12em}
.frac.mx{font-size:.56em}
.dcard.tight{gap:8px; padding:12px}
.dcard.tight .dpass{font-size:17px; line-height:1.38}
.dcard.tight .dchip{min-height:46px; padding-top:7px; padding-bottom:7px; font-size:16.5px}
.dcard.tight .dshow{font-size:56px}

/* ----- the start card ----- */
.logo{display:flex; justify-content:center; align-items:flex-end; gap:6px; color:var(--ink); margin-top:2px}
.logo .lt{width:40px; height:44px; border-radius:10px; border:3px solid var(--ink); display:grid; place-items:center; background:var(--tile); font:700 28px/1 var(--font-display); box-sizing:border-box}
.logo .lline{width:58px; height:44px}
.card.start h1{text-align:center; font-size:34px}
.startmain{display:flex; flex-direction:column; gap:10px}
.startlinks{display:flex; justify-content:center; align-items:center; gap:2px; flex-wrap:wrap}
.startlinks .dot{color:var(--muted); font-weight:800}
/* How to play · Calm motion: the family's quiet links (Math Racing's), never a disclosure arrow (RM6) */
.linkbtn.small{min-height:44px; padding:6px 10px; font:800 15px/1.2 var(--font-body); color:var(--muted)}
.calmbtn[aria-checked="true"]{color:var(--you)}
/* first open: How old are you? (Quiz Race's grid) */
.ageask{display:flex; flex-direction:column; gap:12px}
.ageask h2{font-size:24px}
.agebig{display:grid; grid-template-columns:repeat(5, 1fr); gap:8px}
.ab{height:56px; border:0; border-radius:16px; background:var(--given); color:var(--ink); font:700 24px/1 var(--font-display); box-shadow:0 3px 0 var(--tile-edge); touch-action:manipulation}
.ab:active{transform:translateY(2px); box-shadow:0 1px 0 var(--tile-edge)}
.ab.wide{grid-column:span 2; font-size:20px}
.ab:focus-visible{outline:3px solid var(--you); outline-offset:2px}
/* the name chip: at least 44 px tall */
.mebtn{align-self:flex-end; display:inline-flex; align-items:center; gap:6px; margin:-10px -6px -6px 0; font-size:14px; padding:4px 12px 4px 4px; min-height:44px; border:0; background:var(--given); color:var(--ink); max-width:60%; overflow:hidden; white-space:nowrap}
.mebtn .cface{width:28px; height:28px; border-radius:50%; background:var(--tile); overflow:hidden; display:grid; place-items:center; flex:none}
.mebtn .cface canvas{width:100%!important; height:100%!important}
.cface{display:inline-grid; place-items:center; vertical-align:middle}
.frow .fav .cface, .rank .cface{width:24px; height:24px; border-radius:50%; overflow:hidden; background:var(--tile)}

/* ----- the Change sheet ----- */
.changesheet{max-width:520px}
.ages{display:grid; grid-template-columns:repeat(3, 1fr); gap:8px}
.age{min-height:48px; border:0; border-radius:14px; background:var(--given); font:600 17px/1.1 var(--font-display); color:var(--ink); touch-action:manipulation}
.age[aria-checked="true"]{background:var(--you); color:var(--on-you)}
.mswitch{display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:52px; padding:8px 16px; border:0; border-radius:16px; background:var(--given); color:var(--ink); font:600 17px/1.2 var(--font-display)}
.mswitch i{width:48px; height:28px; border-radius:999px; background:var(--slot-line); position:relative; flex:none}
.mswitch i::after{content:''; position:absolute; left:3px; top:3px; width:22px; height:22px; border-radius:50%; background:#fff; transition:transform .18s ease-out}
.mswitch[aria-checked="true"] i{background:var(--you)}
.mswitch[aria-checked="true"] i::after{transform:translateX(20px)}
.topics{max-height:min(40vh, 340px); overflow:auto; overscroll-behavior:contain}
.topic .gl{font-size:11px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--muted)}

/* ----- the end card ----- */
.endcard{max-width:440px}
.tally b.word{font-size:20px; letter-spacing:.04em}
.chnote{margin:0; text-align:center; font-size:14px; font-weight:700; color:var(--muted)}
.chnote:empty{display:none}
.joinbig{display:flex; justify-content:center; align-items:center; gap:14px}
.room .qr{width:132px; height:132px; border-radius:12px; background:#fff}

/* praise: short, calm, no flashing */
.praise{position:fixed; left:50%; top:var(--y); transform:translateX(-50%); z-index:35; padding:8px 18px; border-radius:999px; background:var(--tile); box-shadow:var(--lift); font:600 20px/1.1 var(--font-display); color:var(--ink); pointer-events:none; animation:praiseIn 1.6s ease-out forwards}
@keyframes praiseIn{0%{opacity:0; transform:translate(-50%,8px)} 15%{opacity:1; transform:translate(-50%,0)} 80%{opacity:1} 100%{opacity:0}}

html.calm :is(.slot.pop, .praise, .mswitch i::after){animation:none!important; transition:none!important}
@media (prefers-reduced-motion: reduce){ .slot.pop, .praise{animation:none!important} .mswitch i::after{transition:none} }
@media (max-height:520px){ .card.start{gap:8px; padding-top:14px; padding-bottom:12px} .logo .lt{width:32px; height:36px; font-size:22px} .card.start h1{font-size:28px} }
/* a phone on its side: the start card in two columns, so it all fits with no scrolling */
@media (max-height:520px) and (min-aspect-ratio:5/4){
  .card.start{max-width:min(780px, 100%)}
  /* (the rows line up: the strip and Change beside the two buttons, Recent plays beside the links; RM6) */
  .startmain{display:grid; grid-template-columns:1fr 1fr; gap:8px 14px; align-items:start}
  .startmain > #plRow{grid-column:1; grid-row:1}
  .startmain > #choiceBtn{grid-column:1; grid-row:2}
  .startmain > .btns{grid-column:2; grid-row:1 / span 2}
  .startmain > .startlinks{grid-column:1; grid-row:3}
  .startmain > #plStrip{grid-column:2; grid-row:3}
  .startmain > #together{grid-column:1 / -1; grid-row:4}
  .startmain:has(> #plRow > .pl-tgt[hidden]) > #choiceBtn{grid-row:1 / span 2; align-self:center}
  .card.start .btn{min-height:48px; padding-top:8px; padding-bottom:8px}
  .card.start .ageask{max-width:640px; width:100%; align-self:center}
  .agebig{grid-template-columns:repeat(7, 1fr)}
  .agebig .ab{height:52px}
  .agebig .ab.wide{grid-column:span 1}
}
/* Recent plays: the face, the name, then which maze (RM5) */
.frow{min-height:48px}
.frow .fl2{font-size:13px; font-weight:700; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.frow .fav .cface{width:32px; height:32px}
/* the Trace door (src/door/trace-door.js): the letter's square, sized by the script to the room under the HUD */
.dtrace{align-self:center; display:grid}
.dcard.tracecard{max-width:440px}
