:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #f5e9d6;
  background: #211c31;
  --night: #211c31; --ink: #352a3d; --gold: #e2be85;
  --parchment: #f3e4c7; --muted: #d5c5c6;
  --border: #9c805b; --violet: #73578e;
  --display: Georgia, "Times New Roman", serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #e2bb79; outline-offset: 4px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 42px; padding: .2rem clamp(.65rem,2vw,1.4rem); background: #251e32; border-bottom: 1px solid #745b50; }
.brand { display: flex; align-items: center; gap: .45rem; color: #f2d8a9; font: 700 1.08rem var(--display); text-decoration: none; }
.brand img { flex: none; }
.stage-label { color: #d5c5c6; font-size: .72rem; }
.app-main { display: flex; flex: 1; min-width: 0; padding: clamp(.25rem,.65vw,.65rem); }
.game-viewport { position: relative; isolation: isolate; overflow: hidden; flex: 1; min-width: 0; display: grid; align-items: stretch; min-height: min(80vh, 28rem); border: 1px solid #8c725e; border-radius: .45rem; background: #30293c; }
#world,.title-art,.scene-composition,.scene-shade { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#world { z-index: -3; }
.title-art { z-index: -2; overflow: hidden; }
.scene-composition { display: block; }
.scene-shade { background: linear-gradient(90deg,rgba(24,20,38,.92) 0%,rgba(31,25,44,.88) 26%,rgba(32,26,44,.57) 48%,transparent 75%),linear-gradient(0deg,rgba(27,22,41,.48),transparent 30%); }
.fireflies { position: absolute; inset: 0; }
.fireflies i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #ffe9ad; box-shadow: 0 0 8px 2px #f7cf7b; animation: drift 5s ease-in-out infinite alternate; }
.fireflies i:nth-child(1) { left: 69%; top: 42%; }
.fireflies i:nth-child(2) { left: 83%; top: 33%; animation-delay: -1s; }
.fireflies i:nth-child(3) { left: 74%; top: 54%; animation-delay: -2s; }
.fireflies i:nth-child(4) { left: 90%; top: 51%; animation-delay: -3s; }
.fireflies i:nth-child(5) { left: 60%; top: 30%; animation-delay: -4s; }
@keyframes drift { from { transform: translateY(0); opacity: .35; } to { transform: translateY(-14px); opacity: 1; } }
.title-view { position: relative; min-width: 0; display: flex; align-items: center; padding: clamp(1.1rem,4.2vw,4.6rem); }
.title-content { width: min(100%, 37rem); position: relative; z-index: 1; }
.title-crest { display: block; width: clamp(65px, 10vh, 120px); height: auto; margin-bottom: .35rem; }
.eyebrow { color: #e4c393; font-size: clamp(.65rem,1.1vw,.82rem); font-weight: 650; text-transform: uppercase; letter-spacing: .16em; margin: 0 0 .5rem; }
h1,h2,h3 { font-family: var(--display); }
.title-content h1 { font-size: clamp(2.55rem, 6.3vw, 6.5rem); line-height: .97; letter-spacing: -.055em; color: #f7dfac; text-shadow: 0 4px 0 #302336, 0 0 24px #211b2b; margin: 0 0 .7rem; overflow-wrap: normal; }
.tagline { font: italic clamp(1rem,2vw,1.45rem) var(--display); color: #ead8cb; margin: 0; }
.ornament { display: flex; align-items: center; gap: .55rem; width: min(82%, 26rem); margin: 1.1rem 0; color: var(--gold); }
.ornament span { height: 1px; flex: 1; background: linear-gradient(90deg,transparent,#bd9665); }
.ornament span:last-child { transform: rotate(180deg); }
.ornament b { font-size: .6rem; }
.intro { max-width: 24rem; line-height: 1.5; color: #f0ded1; margin: 0 0 1.25rem; font-size: clamp(.9rem,1.6vw,1.08rem); }
.gold-button { border: 1px solid #f6d9a2; background: linear-gradient(#f3d6a1,#d4a46c); color: #302438; border-radius: .22rem; padding: .75rem 1.2rem; min-height: 44px; min-width: min(100%, 15.5rem); display: inline-flex; justify-content: space-between; align-items: center; gap: .8rem; font-weight: 750; box-shadow: inset 0 0 0 3px #74544128,0 5px 18px #19142390; }
.gold-button:hover { background: #ffe5b7; }
.gold-button span { font-size: 1.35rem; line-height: 1; }
.preview-note { font-size: .75rem; line-height: 1.45; max-width: 25rem; color: #d6c6c6; margin: .75rem 0 0; }
.chapter-marker { position: absolute; right: clamp(.8rem,2vw,2rem); bottom: clamp(.8rem,2vw,2rem); text-align: right; display: grid; gap: .15rem; text-shadow: 0 2px 4px #231e31; }
.chapter-marker span { font-size: .65rem; text-transform: uppercase; letter-spacing: .17em; color: #eed0a5; }
.chapter-marker strong { font: 700 clamp(1rem,2.1vw,1.6rem) var(--display); }
.spellbook-view { display: grid; place-items: center; padding: clamp(.65rem,3vw,2rem); background: #211c3178; }
.spellbook { width: min(100%, 48rem); background: radial-gradient(ellipse at top,#fff0d3,#e6caa1); color: var(--ink); border: 1px solid #a57b50; outline: 1px solid #e1ba87; outline-offset: 4px; box-shadow: inset 0 0 2.2rem #95643c45,0 15px 50px #1c1426a0; border-radius: .35rem; padding: clamp(.8rem,2.7vw,2rem); }
.book-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .7rem; border-bottom: 1px solid #ac906c; padding-bottom: .65rem; }
.book-header .eyebrow { color: #70513f; font-size: .64rem; margin-bottom: .2rem; }
.book-header h2 { margin: 0; font-size: clamp(1.4rem,3.5vw,2.35rem); line-height: 1.1; }
.quiet-button { border: 1px solid #957452; border-radius: .25rem; color: #4a3443; background: #fff0d580; min-height: 40px; padding: .4rem .65rem; white-space: nowrap; }
.quiet-button:hover { background: #fff5de; }
.spellbook :focus-visible { outline-color: #4e3a75; }
.book-intro { font-size: .9rem; margin: .65rem 0; line-height: 1.4; }
.spell-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .45rem; }
.spell-tab { min-width: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: .2rem; min-height: 73px; padding: .4rem .15rem; border: 2px solid #56445e; border-radius: .25rem; background: #31263e; color: #f5e9d6; font-size: clamp(.65rem,1.3vw,.84rem); }
.spell-tab[aria-pressed="true"] { border-color: var(--spell-colour); box-shadow: inset 0 0 0 1px var(--spell-colour); }
.spell-tab:hover { background: #493750; }
.spell-tab img { display: block; width: clamp(28px,5vw,42px); height: auto; }
.spell-detail { display: flex; align-items: center; gap: clamp(.7rem,2vw,1.3rem); min-height: 110px; margin-top: .7rem; padding: .75rem; border: 1px solid #a78b6b; border-left: 4px solid var(--spell-colour,#4eadc3); background: #fff3db88; border-radius: .2rem; }
.spell-sigil { width: clamp(52px,9vw,86px); aspect-ratio: 1; flex: none; display: grid; place-items: center; background: #31263e; border-radius: 50%; border: 1px solid var(--spell-colour); }
.spell-sigil img { width: 78%; }
.spell-text h3 { margin: 0 0 .3rem; font-size: 1.35rem; }
.spell-text p { margin: 0; line-height: 1.4; font-size: .9rem; }
.spell-text .spell-example { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; margin-top: .35rem; font-weight: 650; font-size: .9rem; line-height: 1.4; }
.column-vector { display: inline-grid; grid-template-rows: repeat(2, 1fr); min-width: 2.1rem; border-inline: 1.5px solid currentColor; border-radius: 40%; padding: .05rem .35rem; text-align: center; font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 500; }
.book-footer { color: #614c45; font-size: .74rem; margin: .7rem 0 0; }
@media (max-width: 650px) and (orientation: portrait) {
  .game-viewport { min-height: max(32rem,calc(100dvh - 55px)); }
  .scene-shade { background: linear-gradient(0deg,#211b2e 0%,#211b2ee8 32%,#211b2e40 68%,transparent 90%); }
    .title-view { align-items: flex-end; padding: 1rem 1rem 1.5rem; }
  .title-crest { width: 62px; }
  .title-content h1 { font-size: clamp(2.25rem,10vw,4rem); }
  .chapter-marker { bottom: auto; top: .8rem; }
  .ornament { margin: .65rem 0; }
  .intro { margin-bottom: .8rem; }
  .spell-tabs { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .app-header { min-height: 32px; padding-block: 0; }
  .brand img { width: 28px; height: 28px; }
  .title-view { padding: .7rem 1.25rem; }
  .title-crest { width: clamp(40px,12vh,65px); margin-bottom: .1rem; }
  .title-content h1 { font-size: clamp(2.1rem,8vh,3.6rem); margin-bottom: .3rem; }
  .tagline { font-size: 1rem; }
  .eyebrow { margin-bottom: .2rem; }
  .ornament { margin: .45rem 0; }
  .intro { margin-bottom: .45rem; font-size: .85rem; }
  .gold-button { min-height: 38px; padding: .35rem .8rem; }
  .preview-note { margin-top: .35rem; }
  .spellbook-view { padding: .5rem; }
  .spellbook { padding: .6rem .9rem; }
  .book-header { padding-bottom: .3rem; }
  .book-intro { margin: .35rem 0; }
  .spell-tab { min-height: 45px; flex-direction: row; }
  .spell-tab img { width: 28px; }
  .spell-detail { min-height: 75px; margin-top: .35rem; padding: .4rem; }
  .spell-sigil { width: 48px; }
  .book-footer { margin-top: .35rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

/* PR03: the world has its own large canvas and compact, non-overlapping toolbar. */
.title-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.55rem; }
.secondary-title-button { background:#31263eeb; color:#efd8ac; border:1px solid #b59a72; border-radius:.22rem; min-height:44px; padding:.6rem .9rem; font-weight:600; }
.secondary-title-button:hover { background:#51405f; }
.room-view { display:grid; grid-template-rows:auto minmax(0,1fr) auto; min-width:0; min-height:max(320px,calc(100dvh - 61px)); background:#211c31; }
.room-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem .7rem; padding:.45rem .75rem; background:#31263e; border-bottom:1px solid #9c805b; }
.room-heading { flex:1 1 auto; min-width:9rem; }
.room-heading p { margin:0; color:#dac3a4; font-size:.67rem; letter-spacing:.065em; }
.room-heading h2 { font-size:clamp(1.05rem,2vw,1.45rem); line-height:1.1; margin:.12rem 0 0; color:#f4dbaa; }
.camera-controls,.pan-controls { display:flex; flex-wrap:wrap; align-items:center; gap:.25rem; }
.camera-controls button,.room-back { font-size:.78rem; padding:.4rem .6rem; min-height:34px; background:#211c31; border:1px solid #8c725e; border-radius:.22rem; color:#f3e4c7; }
.camera-controls button[aria-pressed="true"] { background:#e6c18c; color:#302438; border-color:#f6d9a2; font-weight:700; }
.pan-controls button { min-width:34px; }
.camera-controls button:disabled { opacity:.45; cursor:default; }
.camera-controls button:not(:disabled):hover,.room-back:hover { border-color:#f6d9a2; }
.room-stage { position:relative; overflow:hidden; min-width:0; min-height:220px; background:#696177; }
#room-canvas { display:block; position:absolute; inset:0; width:100%; height:100%; }
.room-footer { display:flex; justify-content:space-between; gap:.3rem .8rem; flex-wrap:wrap; padding:.3rem .65rem; font-size:.72rem; line-height:1.35; color:#d5c5c6; background:#251e32; border-top:1px solid #745b50; }
@media(max-width:650px) and (orientation:portrait) {
  .room-view { min-height:max(490px,calc(100dvh - 55px)); }
  .room-toolbar { padding:.45rem; }
  .room-heading { flex-basis:calc(100% - 6rem); }
  .room-back { order:-1; }
  .camera-controls { width:100%; justify-content:center; }
  .room-footer { font-size:.68rem; }
}
@media(max-height:520px) and (orientation:landscape) {
  .room-view { min-height:max(240px,calc(100dvh - 44px)); }
  .room-stage { min-height:150px; }
  .room-toolbar { padding:.22rem .5rem; }
  .room-heading p { display:none; }
  .room-heading h2 { font-size:1rem; }
  .camera-controls button,.room-back { min-height:30px; padding:.28rem .45rem; }
  .room-footer { padding:.18rem .5rem; }
  .secondary-title-button { min-height:38px; padding:.35rem .7rem; }
}

/* PR04: tools are compact, coordinate input opens only in picking mode. */
.room-view { grid-template-rows:auto minmax(0,1fr) auto auto; }
.room-stage { grid-row:2; }
.coordinate-panel { grid-row:3; display:flex; flex-wrap:wrap; align-items:center; gap:.35rem .7rem; background:#2c2439; color:#f3e4c7; border-top:1px solid #9c805b; padding:.35rem .65rem; font-size:.77rem; }
.room-footer { grid-row:4; }
.zoom-controls,.coordinate-controls { display:flex; align-items:center; gap:.25rem; }
.zoom-controls button { min-width:32px; }
.coordinate-controls button,.coordinate-panel button,.coordinate-panel select,.coordinate-panel input { font:inherit; font-size:.76rem; min-height:34px; color:#f3e4c7; background:#211c31; border:1px solid #8c725e; border-radius:.22rem; padding:.32rem .48rem; }
.coordinate-controls button[aria-pressed="true"] { background:#e6c18c; color:#302438; border-color:#f6d9a2; font-weight:700; }
.coordinate-controls button:hover,.coordinate-panel button:hover { border-color:#f6d9a2; }
.coordinate-form,.snap-field,.coordinate-form label { display:flex; align-items:center; flex-wrap:wrap; gap:.3rem; }
.coordinate-panel input { width:4.6rem; font-variant-numeric:tabular-nums; }
.coordinate-panel input::placeholder { color:#c2b4c5; }
#coordinate-result { color:#eed9b8; font-variant-numeric:tabular-nums; flex:1 1 11rem; line-height:1.35; }
@media(max-width:650px) and (orientation:portrait) {
  .coordinate-controls { flex:1 1 auto; justify-content:center; flex-wrap:wrap; }
  .coordinate-panel { gap:.25rem .45rem; padding:.3rem .45rem; }
  .coordinate-panel input { width:4rem; }
  #coordinate-result { flex-basis:100%; }
}
@media(max-height:520px) and (orientation:landscape) {
  .room-toolbar { gap:.2rem .35rem; }
  .coordinate-controls button,.coordinate-panel button,.coordinate-panel select,.coordinate-panel input { min-height:29px; padding:.22rem .35rem; }
  .coordinate-panel { padding:.2rem .45rem; gap:.2rem .4rem; }
  .coordinate-panel input { width:4rem; }
}

/* PR05: compact, multi-pointer-safe movement controls below the world. */
.movement-controls { display:flex;align-items:center;gap:.28rem;flex-wrap:nowrap;touch-action:none;user-select:none; }
.movement-controls button { min-width:42px;min-height:42px;padding:.3rem .55rem;background:#392b48;color:#f5e4c7;border:1px solid #a58b68;border-radius:.25rem;font-weight:700;touch-action:none;user-select:none; }
.movement-controls button:active { background:#e2be85;color:#302438; }
.movement-controls .jump-control { min-width:66px; }
.play-info { display:flex;flex:1 1 13rem;flex-direction:column;justify-content:center;gap:.15rem; }
#play-status { color:#f3dfb8; }
#follow-toggle[aria-pressed="true"] { border-color:#e6c18c;color:#f1d5a6; }
#room-canvas:focus-visible { outline-offset:-3px; }
@media(max-height:520px) and (orientation:landscape){.movement-controls button{min-height:32px;min-width:36px;padding:.2rem .4rem}.room-footer{align-items:center}.play-info{font-size:.68rem}}
@media(max-width:650px) and (orientation:portrait){.room-footer{justify-content:center}.play-info{flex-basis:100%;text-align:center}.movement-controls button{min-height:44px;min-width:44px}}

/* PR06: compact context-sensitive inspector; coordinate and object tools share a row. */
.object-panel { grid-row:3; display:grid; gap:.3rem; min-width:0; padding:.4rem .65rem; background:#2c2439; border-top:1px solid #9c805b; color:#f3e4c7; font-size:.76rem; }
.object-top,.object-form,.object-fields,.object-panel label { display:flex; align-items:center; flex-wrap:wrap; gap:.3rem .5rem; }
.object-top { justify-content:flex-start; }
#object-permissions { flex:1 1 12rem; line-height:1.35; color:#e6cfa9; }
.object-panel button,.object-panel input,.object-panel select { font:inherit; color:#f3e4c7; background:#211c31; min-height:34px; padding:.3rem .45rem; border:1px solid #8c725e; border-radius:.22rem; }
.object-panel select { max-width:100%; }
.object-panel button:hover { border-color:#f6d9a2; }
.object-panel input { width:6rem; font-variant-numeric:tabular-nums; }
.object-panel input[name="line"] { width:8rem; }
.object-panel .preview-action { color:#302438;background:#e6c18c;border-color:#f6d9a2;font-weight:700; }
.object-references,#object-result { margin:0; line-height:1.35; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
#object-result[data-state="clear"] { color:#b7e5bc; }
#object-result[data-state="invalid"] { color:#ffb8af; }
.object-preview-note { color:#d4c1d0; }
@media(max-height:520px) and (orientation:landscape){.object-panel{gap:.2rem;padding:.25rem .45rem}.object-panel button,.object-panel input,.object-panel select{min-height:29px;padding:.2rem .35rem}.object-panel input{width:5rem}}
@media(max-width:650px) and (orientation:portrait){.object-top label{flex:1 1 9rem}.object-top select{width:100%}.object-panel{padding:.35rem .45rem}.object-preview-note{flex-basis:100%}}

/* PR07: actual tutorial controls and vertically stacked mathematical vector entry. */
.tutorial-tools { display:flex; gap:.35rem;align-items:center;white-space:nowrap;font-size:.76rem;color:#f3dfb8; }
#tutorial-guide { color:#f2dfb9; line-height:1.4; }
.vector-entry { display:grid;gap:.2rem;border-inline:2px solid #e4c393;border-radius:12px;padding:.2rem .5rem; }
.vector-entry label { display:grid;grid-template-columns:6.25rem 5rem;gap:.35rem; }
.vector-entry input { width:5rem;text-align:center; }
#object-apply:disabled { opacity:.45;cursor:default; }
@media(max-height:520px) and (orientation:landscape){.vector-entry{gap:.1rem;padding:.1rem .35rem}.vector-entry label{grid-template-columns:6rem 4.2rem}.vector-entry input{width:4.2rem}}

/* PR11: grouped recovery actions remain compact, without adding a persistent panel. */
.recovery-controls { display:flex;align-items:center;flex-wrap:wrap;gap:.25rem; }
.recovery-controls button { white-space:nowrap; }
.recovery-controls button:disabled { opacity:.45;cursor:default; }
#recovery-count { color:#d8c5e4;font-variant-numeric:tabular-nums; }
@media(max-height:520px) and (orientation:landscape){.recovery-controls{gap:.15rem}.recovery-controls button{padding:.2rem .35rem}}

/* PR12: completion is a dedicated view, not an overlay that consumes gameplay space. */
.results-view { display:grid;place-items:center;min-width:0;padding:clamp(.65rem,2.8vw,2rem);background:#211c3178; }
.results-sheet { display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.15fr);gap:.9rem 1.3rem;width:min(100%,58rem);min-width:0;padding:clamp(.9rem,2.4vw,1.9rem);border:1px solid #a78b6b;outline:1px solid #9c805b;outline-offset:3px;border-radius:.35rem;background:radial-gradient(ellipse at top,#40314e,#272033);box-shadow:0 12px 44px #171121b0;color:#f5e9d6; }
.results-header,.results-actions { grid-column:1/-1; }
.results-header { padding-bottom:.6rem;border-bottom:1px solid #886d58;text-align:center; }
.results-header .eyebrow { margin-bottom:.2rem; }
.results-header h2 { margin:0;font-size:clamp(1.5rem,3.5vw,2.4rem);color:#f5dca9; }
.results-summary,.results-solution { min-width:0; }
.results-stars { display:flex;align-items:center;justify-content:center;gap:.32em;font-size:clamp(2.5rem,5vw,4.1rem);line-height:1.15; }
.earned-star { color:#efc474;text-shadow:0 2px 1px #8b653b,0 0 16px #e7b95e40; }
.empty-star { color:#b5a4b6; }
#results-message { margin:.25rem 0 .7rem;font-weight:650;text-align:center;color:#f2deb6;line-height:1.4; }
.results-stats { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.35rem;margin:.5rem 0; }
.result-stat { border:1px solid #716078;background:#1e182b66;border-radius:.25rem;padding:.45rem .5rem;text-align:center; }
.result-stat dt { color:#dfcdbf;font-size:.78rem; }
.result-stat dd { margin:0;color:#f5dca9;font:700 1.45rem var(--display);font-variant-numeric:tabular-nums; }
.results-note { color:#d7c8cc;font-size:.79rem;line-height:1.45;margin:.4rem 0; }
.results-best { margin:.55rem 0 0;color:#f0cf94;font-size:.84rem;font-weight:650;line-height:1.4; }
.results-solution { border-left:1px solid #766078;padding-left:1rem; }
.results-solution h3 { margin:0;font-size:1.2rem;color:#f3dfb8; }
.results-history { margin:.6rem 0 0;padding:.25rem .25rem .25rem 1.65rem;max-height:clamp(8rem,43dvh,26rem);overflow:auto;overscroll-behavior:contain;scrollbar-width:thin; }
.result-history-item { margin-bottom:.4rem;padding:.45rem .5rem;background:#211b2d88;border:1px solid #74617c;border-radius:.25rem; }
.result-history-item::marker { color:#e4c393;font-variant-numeric:tabular-nums;font-weight:650; }
.result-history-item img { float:left;margin:.05rem .55rem .15rem 0; }
.result-history-detail { min-width:0;overflow-wrap:anywhere;font-size:.86rem; }
.result-math { display:flex;align-items:center;flex-wrap:wrap;gap:.45rem;color:#f0dfc3;margin:.2rem 0;line-height:1.45; }
.result-cast-state { display:block;margin-top:.18rem;color:#c6ddc9;font-size:.72rem; }
.result-undone { border-style:dashed;background:#211b2d44; }
.result-undone .result-cast-state { color:#e8c4a7; }
.result-undone .result-history-detail { color:#d9c8d8; }
.results-actions { display:flex;justify-content:flex-end;flex-wrap:wrap;gap:.5rem;border-top:1px solid #886d58;padding-top:.75rem; }
.results-actions .gold-button { min-width:0; }
@media(max-width:650px) and (orientation:portrait){.results-sheet{grid-template-columns:minmax(0,1fr);gap:.65rem}.results-solution{border-left:0;padding-left:0;border-top:1px solid #766078;padding-top:.7rem}.results-history{max-height:35dvh}.results-actions{justify-content:stretch}.results-actions button{flex:1 1 auto}.results-stats{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-height:520px) and (orientation:landscape){.results-view{padding:.45rem}.results-sheet{padding:.65rem .9rem;gap:.4rem .85rem}.results-header{padding-bottom:.3rem}.results-header h2{font-size:1.4rem}.results-stars{font-size:2.4rem}.results-stats{grid-template-columns:repeat(4,minmax(0,1fr));gap:.25rem}.result-stat{padding:.25rem}.result-stat dt{font-size:.68rem}.result-stat dd{font-size:1.15rem}.results-history{max-height:38dvh}.results-actions{padding-top:.35rem}.results-note{font-size:.73rem}}

/* PR13: optional, compact non-modal tutorial help in the existing footer. */
#tutorial-guide { color:#f0dbb5; font-size:.78rem; line-height:1.4; }
#tutorial-guidance-toggle[aria-pressed="true"],#tutorial-hint[aria-expanded="true"] { border-color:#d8b47d;color:#f9dda7; }
.tutorial-tools { flex-wrap:wrap; }
.tutorial-hint-panel { flex:1 0 100%;display:flex;align-items:center;gap:.5rem .8rem;flex-wrap:wrap;min-width:0;padding:.5rem .65rem;border:1px solid #9c805b;border-left:3px solid #d8b47d;border-radius:.25rem;background:#352940;color:#f2e4d1; }
.hint-content { flex:1 1 16rem;min-width:0; }
#tutorial-hint-title { color:#f2d6a3;font-size:.79rem; }
#tutorial-hint-text { margin:.15rem 0 0;line-height:1.45;overflow-wrap:anywhere;font-size:.8rem; }
.hint-actions { display:flex;align-items:center;flex-wrap:wrap;gap:.3rem; }
.hint-actions button:disabled { opacity:.45;cursor:default; }
@media(max-height:520px) and (orientation:landscape){#tutorial-guide{font-size:.7rem}.tutorial-hint-panel{padding:.25rem .45rem;gap:.25rem .5rem}#tutorial-hint-title,#tutorial-hint-text{font-size:.72rem}.hint-actions button{min-height:28px;padding:.18rem .35rem}}
@media(max-width:650px) and (orientation:portrait){.hint-content{flex-basis:100%}.hint-actions{justify-content:flex-end;width:100%}.hint-actions button{min-height:40px}}

/* PR14: gameplay owns the viewport. Secondary view controls are opt-in. */
body:has(#room-view:not([hidden])) .app-header{display:none}
body:has(#room-view:not([hidden])) .app-main{padding:0}
body:has(#room-view:not([hidden])) .game-viewport{border:0;border-radius:0;min-height:0}
.room-view{height:100dvh;min-height:360px;grid-template-rows:auto minmax(138px,1fr) auto auto;overflow:visible}
.room-toolbar{gap:.25rem .45rem;padding:.3rem .6rem}
.room-heading{flex:1 1 9rem;min-width:8rem}
.room-heading h2{font-size:clamp(1rem,1.8vw,1.35rem)}
.room-secondary-tools{flex:1 0 100%;display:flex;align-items:center;flex-wrap:wrap;gap:.25rem .5rem;padding:.25rem 0 0;border-top:1px solid #745b50}
#room-tools-toggle[aria-expanded="true"]{border-color:#e6c18c;color:#f1d5a6}
.primary-tools .object-primary{background:#e5bf88;color:#302438;border-color:#f6d9a2;font-weight:750}
.primary-tools .object-primary[aria-pressed="true"]{background:#6f527f;color:#fff0d5;border-color:#e7c391}
.room-stage{min-height:138px}
.room-footer{align-items:center;gap:.2rem .6rem;padding:.3rem .6rem}
.play-info{gap:.1rem;min-width:0}
#room-status{color:#c8b7ca}
.climb-controls{display:flex;gap:.28rem}
.object-panel,.coordinate-panel{max-height:40dvh;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.tutorial-hint-panel{max-height:25dvh;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.room-footer:has(#tutorial-hint-panel:not([hidden])) #tutorial-guide{display:none}
.object-top label{min-width:0}
.object-top select{max-width:min(100%,18rem)}
.object-panel input,.coordinate-panel input{font-size:16px}
.object-panel button,.object-panel select,.coordinate-panel button,.coordinate-panel select{min-height:36px}
@media(max-height:600px) and (orientation:landscape){
  .room-view{min-height:360px}
  .room-toolbar{gap:.18rem .3rem;padding:.2rem .4rem}
  .room-heading{min-width:7rem;flex:1 1 8rem}
  .room-heading p{display:none}
  .room-heading h2{margin:0;font-size:1rem}
  .room-back,.camera-controls button,.coordinate-controls button{min-height:32px;padding:.18rem .38rem;font-size:.74rem}
  .room-footer{padding:.18rem .45rem;gap:.15rem .5rem}
  .object-panel,.coordinate-panel{max-height:37dvh}
  .object-panel button,.object-panel select,.coordinate-panel button,.coordinate-panel select{min-height:32px}
  #tutorial-guide{font-size:.72rem}
  .tutorial-tools,.recovery-controls{gap:.18rem}
}
@media(max-width:650px) and (orientation:portrait){
  .room-view{min-height:530px}
  .room-toolbar{gap:.25rem;padding:.3rem .4rem}
  .room-toolbar>.room-heading{flex:1 0 100%}
  .room-toolbar .room-back{order:0}
  .room-toolbar>.coordinate-controls{flex:0 1 auto}
  .room-toolbar>.tutorial-tools{flex:1 1 auto;justify-content:flex-end}
  .room-toolbar .room-back,.coordinate-controls button,.camera-controls button{min-height:38px}
  .room-secondary-tools .camera-controls{width:auto;justify-content:flex-start}
  .room-footer{justify-content:space-between}
  .movement-controls{width:100%;justify-content:flex-start}
  .movement-controls .jump-control{margin-left:auto;min-width:84px}
  .play-info{text-align:left;flex:1 1 100%}
}

body:has(#room-view:not([hidden])) .game-viewport{overflow:visible}

.campaign-view{padding:clamp(.8rem,3vw,2rem);background:#211c31eF;min-width:0;color:#f3e4c7}
.campaign-header,.library-filters{display:flex;align-items:center;flex-wrap:wrap;gap:.6rem}
.campaign-header>div{flex:1 1 18rem}.campaign-header h2{margin:0;color:#f5dca9}
.campaign-map,.campaign-levels{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));gap:.65rem}
.chapter-card,.library-level{display:grid;gap:.35rem;text-align:left;border:1px solid #9c805b;border-radius:.4rem;padding:.85rem;background:#382b46;color:#f3e4c7}
.chapter-card:disabled{opacity:.65;cursor:default;border-style:dashed}.chapter-card:not(:disabled):hover,.library-level:hover{background:#514064}
.chapter-card small,.library-level small{color:#d5c5c6}.level-number,.library-score{color:#efc474;font-weight:700}
.library-filters{margin-bottom:.8rem}.library-filters label{display:grid;gap:.2rem;font-size:.8rem}.library-filters select{min-height:36px;background:#302438;color:#f3e4c7;border:1px solid #9c805b;padding:.3rem}

/* PR35: presentation controls, responsive focus mode and accessible feedback. */
.presentation-controls,.locate-controls{display:flex;align-items:center;flex-wrap:wrap;gap:.25rem}
.presentation-controls button[aria-pressed="true"],#quick-camera[aria-pressed="true"]{border-color:#f6d9a2;background:#e6c18c;color:#302438;font-weight:700}
.room-view[data-focus="true"] .room-heading p,.room-view[data-focus="true"] #room-status{display:none}
.room-view[data-focus="true"] .room-toolbar{padding:.18rem .45rem;gap:.18rem .3rem}
.room-view[data-focus="true"] .room-heading h2{font-size:1rem}
.room-view[data-focus="true"] .room-footer{padding:.18rem .45rem}
.room-view[data-focus="true"] #tutorial-guide{font-size:.72rem}
.room-view[data-focus="true"] .play-info{gap:.06rem}
.room-toolbar,.room-footer,.object-panel,.coordinate-panel{min-width:0}
.room-toolbar button,.room-footer button{white-space:nowrap}
.room-heading h2{overflow-wrap:anywhere}
.object-top{align-items:center}
.locate-controls button:disabled{opacity:.48;cursor:default}
#object-references,#object-result{color:#fff0d6}
#object-result[data-state="clear"]{color:#c8f4c8}
#object-result[data-state="invalid"]{color:#ffd1c9}
.movement-controls button[data-held="true"]{background:#e6c18c;color:#302438;border-color:#fff0c5;box-shadow:inset 0 0 0 2px #fff0c5}
.room-stage{isolation:isolate}
.room-stage:focus-within{box-shadow:inset 0 0 0 2px #e2bb79}
#room-canvas:focus-visible{outline:3px solid #ffe3a7;outline-offset:-3px}
@media(pointer:coarse){
 .room-toolbar button,.object-panel button,.object-panel select,.coordinate-panel button,.coordinate-panel select{min-height:40px}
 .movement-controls button{min-height:44px;min-width:44px}
}
@media(max-width:650px) and (orientation:portrait){
 .room-toolbar>.room-heading{flex:1 0 100%}
 .room-toolbar>.coordinate-controls{flex:1 1 100%}
 .room-toolbar>.coordinate-controls button{flex:1 1 auto}
 .room-view[data-focus="true"] .room-toolbar>.room-heading{flex:1 1 9rem}
 .room-view[data-focus="true"] .room-toolbar>.coordinate-controls{flex:0 1 auto}
 .locate-controls{flex:1 1 auto}
 .room-footer .play-info{overflow-wrap:anywhere}
}
@media(max-height:600px) and (orientation:landscape){
 .room-toolbar{column-gap:.24rem}
 .room-view[data-focus="true"] .room-heading{min-width:6rem}
 .room-view[data-focus="true"] .room-secondary-tools{padding-top:.1rem}
 .room-footer .play-info{font-size:.72rem;line-height:1.3}
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after{animation:none!important;transition:none!important}

.campaign-celebration{margin:.6rem 0 0;padding:.6rem .8rem;border:1px solid #c6a46f;border-radius:.3rem;color:#ffe8b8;background:#42344c;font-size:.9rem;line-height:1.45;font-weight:650}
.results-view[data-campaign-complete="true"] .results-sheet{border-color:#e5c187;background:radial-gradient(ellipse at top,#51405d,#272033 75%)}
.results-view[data-campaign-complete="true"] .results-header h2{color:#ffe6b0}
@keyframes earned-star-arrive{from{transform:scale(.76);opacity:.65}to{transform:scale(1);opacity:1}}
@media(prefers-reduced-motion:no-preference){.results-view:not([hidden]) .earned-star{animation:earned-star-arrive .3s ease-out both}.results-view:not([hidden]) .earned-star:nth-child(2){animation-delay:.08s}.results-view:not([hidden]) .earned-star:nth-child(3){animation-delay:.16s}}
