:root { color-scheme: light; --paper: #f8f7f3; --ink: #303831; --muted: #71796e; --line: #e2e5db; --green: #35624e; --red: #df5c48; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--paper); }
body { margin: 0; color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overscroll-behavior: none; }
.app { height: 100vh; height: 100dvh; min-height: 480px; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); display: flex; flex-direction: column; }
.app-bar { display: flex; align-items: center; justify-content: space-between; flex: 0 0 76px; gap: 16px; padding: 10px 28px; border-bottom: 1px solid var(--line); }
.brand, .header-actions { display: flex; align-items: center; gap: 12px; }
h1 { margin: 0; font: 26px/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.7px; }
.brand p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.header-actions { gap: 26px; }
.legend { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend i { height: 7px; width: 7px; background: var(--red); transform: rotate(45deg); }
button { min-height: 48px; min-width: 48px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: #fffffb; font: inherit; font-weight: 550; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background .15s, transform .15s; }
button:active { transform: scale(.97); background: #e9ede3; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
.help-button { border-radius: 50%; background: transparent; min-width: 44px; min-height: 44px; font-size: 18px; font-weight: 500; }
.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0 20px 18px; background: radial-gradient(ellipse at 50% 40%, #fffefa, #f3f4ed); }
.scene { position: relative; flex: 1; min-height: 180px; }
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas.rotating { cursor: grabbing; }
canvas:focus-visible { outline: 2px solid #35624e55; outline-offset: -4px; border-radius: 16px; }
.scene-top, .scene-bottom { position: absolute; left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; pointer-events: none; z-index: 1; }
.scene-top { top: 22px; align-items: flex-start; }
.stats { display: flex; gap: 24px; }
.stats > div { display: flex; flex-direction: column; gap: 1px; min-width: 52px; }
.stats output { font-size: 22px; font-weight: 500; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 10px; color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid #e1e5d9; border-radius: 20px; background: #fffffae8; font-size: 11px; color: var(--muted); }
.state::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #69846d; }
.state.active { color: #a83e2f; border-color: #eab8ae; background: #fff6f0; }
.state.active::before { background: var(--red); }
.view-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.rotation-controls { display: flex; pointer-events: auto; border: 1px solid var(--line); border-radius: 14px; background: #fffffaed; overflow: hidden; }
.rotation-controls button { min-width: 44px; min-height: 44px; border: 0; border-radius: 0; background: transparent; font-size: 23px; }
.rotation-controls #view-home { min-width: 52px; font-size: 11px; font-variant-numeric: tabular-nums; }
.scene-bottom { bottom: 13px; justify-content: center; color: var(--muted); font-size: 11px; }
.scene-bottom p { margin: 0; }
#queue:empty { display: none; }
#queue:not(:empty) { color: var(--green); }
.toolbar { display: grid; grid-template-columns: minmax(440px, 1.8fr) minmax(130px, 1fr) auto; align-items: center; gap: 24px; width: min(100%, 1080px); align-self: center; padding: 17px 20px; border: 1px solid #dfe3d8; border-radius: 22px; background: #fffffbf2; box-shadow: 0 6px 24px #34432e08, 0 1px 3px #34432e05; }
.grain-control { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.selected-square { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.selection-icon { color: var(--green); font-size: 35px; line-height: 1; }
h2 { margin: 0; font-size: 13px; font-weight: 600; }
.selected-square p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.capacity { color: #838b7e; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 19px; border-color: var(--green); color: white; background: var(--green); white-space: nowrap; }
.primary > span:first-child { font-size: 22px; font-weight: 400; }
.primary:active { background: #294f3e; }
.speed-control { padding-left: 24px; border-left: 1px solid var(--line); }
.speed-control label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.speed-control output { color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; height: 44px; margin: -2px 0 -10px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; touch-action: manipulation; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: #dce3d6; border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border: 3px solid #fffffb; border-radius: 50%; background: var(--green); box-shadow: 0 1px 4px #34432e30; }
input[type="range"]::-moz-range-track { height: 4px; background: #dce3d6; border-radius: 3px; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 3px solid #fffffb; border-radius: 50%; background: var(--green); box-shadow: 0 1px 4px #34432e30; }
.reset-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.reset-controls button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 13px; font-size: 12px; background: transparent; }
.sandbox-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sandbox-fields label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
.sandbox-fields select { width: 100%; min-width: 0; min-height: 48px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fffffb; font: inherit; font-size: 14px; }
#sandbox-description { margin: 20px 0; color: var(--muted); font-size: 13px; }
.sandbox-actions { display: flex; justify-content: flex-end; gap: 10px; }
.sandbox-actions button { padding: 0 16px; }
#sandbox-close { min-height: 44px; min-width: 44px; font-size: 25px; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 28px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); background: #fffffb; box-shadow: 0 24px 100px #23302730; overflow: auto; }
dialog::backdrop { background: #303b3540; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.3px; }
.dialog-heading h2 { font: 27px/1.15 Georgia, serif; letter-spacing: -.6px; }
#help-close { flex: 0 0 44px; min-height: 44px; min-width: 44px; font-size: 25px; font-weight: 400; }
.rule { display: flex; gap: 15px; margin: 21px 0; }
.rule > span { font-size: 11px; color: #ae8a5e; padding-top: 2px; }
h3 { margin: 0; font-size: 13px; font-weight: 600; }
.rule p, .abelian-note p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.abelian-note { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }
.help-footnote { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 22px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (hover: hover) { button:hover { background: #edf0e7; } .primary:hover { background: #294f3e; } }
@media (max-width: 950px) {
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 16px 20px; }
  .grain-control { grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: 13px; }
  .primary { min-width: 180px; }
  .speed-control { border-left: 0; padding: 0; max-width: 320px; }
}
@media (max-width: 520px) {
  .app { min-height: 500px; }
  .app-bar { flex-basis: 66px; padding: 8px 16px; }
  .brand { gap: 8px; }
  .brand img { width: 33px; height: 33px; }
  h1 { font-size: 23px; }
  .brand p { font-size: 10px; }
  .header-actions { gap: 13px; }
  .legend { font-size: 10px; gap: 5px; }
  .workspace { padding: 0 10px 10px; }
  .scene-top { top: 14px; left: 8px; right: 8px; gap: 8px; }
  .stats { gap: 14px; }
  .stats > div { min-width: 39px; }
  .stats output { font-size: 19px; }
  .state { font-size: 10px; padding: 6px 8px; }
  .toolbar { padding: 13px; border-radius: 19px; gap: 12px; }
  .grain-control { gap: 10px; }
  .selected-square { gap: 6px; }
  .selection-icon { font-size: 29px; }
  .selected-square h2 { font-size: 12px; }
  .selected-square p { font-size: 10px; }
  .primary { min-width: 0; padding: 0 12px; font-size: 12px; gap: 7px; }
  .reset-controls { gap: 6px; }
  .reset-controls button { padding: 0 10px; }
  .reset-controls svg { display: none; }
  .scene-bottom { flex-direction: column; gap: 2px; font-size: 10px; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

.drop-controls { display: flex; align-items: flex-end; gap: 12px; }
.drop-size-control { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 10px; }
.drop-size-control select { min-height: 48px; min-width: 102px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: #fffffb; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
#drop { min-width: 120px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#drop-label { font-size: 14px; }
#drop.pouring { background: #244c38; box-shadow: 0 0 0 4px #35624e20; }
@media (max-width: 520px) {
  .grain-control { flex-wrap: wrap; }
  .selected-square { flex: 1 0 100%; }
  .drop-controls { width: 100%; align-items: center; justify-content: space-between; }
  .drop-size-control { flex-direction: row; align-items: center; gap: 8px; }
  #drop { flex: 1; max-width: 175px; }
}
.view-switch { display: flex; padding: 4px; gap: 3px; border: 1px solid var(--line); border-radius: 15px; background: #ecefe6; }
.view-switch button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 11px; background: transparent; font-size: 12px; color: var(--muted); }
.view-switch button[aria-pressed="true"] { background: #fffffb; color: var(--green); box-shadow: 0 1px 4px #34432e15; }
.height-legend { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.height-legend[hidden] { display: none; }
.height-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.height-legend i { width: 13px; height: 13px; border-radius: 3px; border: 1px solid #30383118; }
.scene:has(.height-legend:not([hidden])) .scene-bottom { flex-wrap: wrap; gap: 8px 16px; }
@media (max-width: 620px) {
  .app-bar { flex-wrap: wrap; flex-basis: auto; padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .view-switch { order: 3; margin: auto; }
  .view-switch button { padding: 0 25px; }
  .height-legend { gap: 11px; }
}

.mode-switch { display: flex; flex-shrink: 0; padding: 4px; gap: 3px; border: 1px solid #cbd8cc; border-radius: 15px; background: #edf1e8; }
.mode-switch button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 11px; background: transparent; font-size: 12px; color: var(--green); }
.mode-switch button[aria-pressed="true"] { color: white; background: var(--green); box-shadow: 0 2px 4px #34432e12; }
button:disabled { opacity: .4; cursor: default; transform: none; }
.game-panel { width: min(100%, 1080px); align-self: center; margin-top: 16px; padding: 18px 22px; border: 1px solid #dfe3d8; border-radius: 22px; background: #fffffb; }
.challenge-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.game-panel .eyebrow { margin-bottom: 3px; font-size: 9px; }
.game-panel h2 { font: 25px/1.15 Georgia, serif; letter-spacing: -.5px; }
.level-progress { display: flex; gap: 6px; }
.level-progress button { position: relative; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: #f4f4ed; font-size: 12px; }
.level-progress button[aria-current="step"] { border-color: var(--green); background: var(--green); color: white; }
.level-progress button.complete::after { content: '✓'; position: absolute; right: -2px; top: -4px; display: grid; place-items: center; width: 17px; height: 17px; border: 2px solid #fffffb; border-radius: 50%; background: #35624e; color: white; font-size: 9px; }
.game-prompt { margin: 10px 0 0; font-size: 14px; }
.challenge-feedback { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; min-height: 22px; }
#game-message { margin: 0; font-size: 12px; color: #6f776b; }
.game-panel[data-status="won"] { border-color: #adc8af; background: #f5f9ee; }
.game-panel[data-status="won"] #game-message { color: #28553d; }
.game-panel[data-status="retry"] #game-message { color: #99452f; }
.game-actions { display: flex; align-items: center; gap: 10px; }
.game-actions button { padding: 0 16px; font-size: 12px; }
#game-budget { font-size: 11px; color: var(--muted); white-space: nowrap; margin-right: 4px; }
.game-active .drop-size-control, .game-active .speed-control, .game-active .reset-controls { display: none; }
.game-active .toolbar { grid-template-columns: minmax(0, 1fr) auto; }
.game-active .grain-control { grid-column: auto; padding: 0; border: 0; }
.game-active #drop { min-width: 116px; }
.game-active .scene { min-height: 270px; }
@media (max-width: 1100px) { .header-actions > .legend { display: none; } .app-bar { gap: 12px; padding-left: 20px; padding-right: 20px; } }
@media (max-width: 800px) {
  .view-switch button, .mode-switch button { padding: 0 12px; }
  .game-actions { gap: 8px; }
  .game-actions button { padding: 0 12px; min-width: 0; }
  .game-active .toolbar { gap: 16px; }
  .game-active .grain-control { gap: 14px; }
  .game-panel { padding: 16px 18px; }
}
@media (max-width: 700px) {
  .app-bar { flex-wrap: wrap; flex-basis: auto; gap: 8px; }
  .brand { flex: 1; }
  .header-actions { order: 1; }
  .mode-switch { order: 2; width: calc(50% - 4px); }
  .view-switch { order: 3; width: calc(50% - 4px); margin: 0; }
  .mode-switch button, .view-switch button { flex: 1; padding: 0 6px; }
  .game-active .toolbar { grid-template-columns: 1fr; gap: 12px; }
  .game-active .grain-control { flex-wrap: nowrap; }
  .game-active .selected-square { flex: initial; }
  .game-active .drop-controls { width: auto; }
  .game-actions { justify-content: flex-end; }
  #game-budget { margin-right: auto; }
  .challenge-heading { flex-wrap: wrap; gap: 12px; }
  .level-progress { gap: 8px; }
  .game-panel h2 { font-size: 23px; }
  .challenge-feedback { flex-wrap: wrap; }
  .game-prompt { font-size: 13px; }
}

.camera-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; max-width: 460px; pointer-events: auto; }
.scene .view-switch { order: 0; margin: 0; width: auto; background: #ecefe6ed; }
.scene .view-switch button { flex: initial; padding: 0 12px; }
.zoom-controls { display: flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fffffaed; }
.zoom-controls button { min-width: 42px; min-height: 42px; border: 0; border-radius: 0; background: transparent; font-size: 19px; }
.zoom-controls #zoom-reset { min-width: 52px; font-size: 11px; font-variant-numeric: tabular-nums; }
.level-library { display: flex; gap: 6px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.level-library button { min-height: 42px; padding: 0 15px; border: 0; background: #f2f3ed; color: var(--muted); font-size: 12px; }
.level-library button[aria-pressed="true"] { background: var(--green); color: white; }
.game-panel { padding-top: 12px; }
#game-best { font-size: 11px; color: var(--green); white-space: nowrap; }
#game-best:empty { display: none; }
.target-panel { position: absolute; z-index: 1; top: 88px; left: 12px; width: 136px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #fffffbef; pointer-events: none; }
.target-panel h2 { font-size: 11px; color: var(--muted); margin-bottom: 7px; }
.target-grid { display: grid; gap: 2px; }
.target-grid span { display: grid; place-items: center; aspect-ratio: 1; font-size: 12px; border-radius: 2px; }
@media (max-width: 800px) {
  .game-active .toolbar { grid-template-columns: 1fr; gap: 10px; }
  .game-actions { justify-content: flex-end; }
  #game-budget { margin-right: auto; }
  .level-library { gap: 4px; }
  .level-library button { padding: 0 10px; }
}
@media (max-width: 700px) { .camera-controls { max-width: 310px; } }
@media (max-width: 520px) {
  .app-bar .mode-switch { order: 0; width: auto; }
  .level-library { display: grid; grid-template-columns: 1fr 1.4fr; }
  .level-library button { padding: 0 8px; }
  .camera-controls { max-width: 175px; }
  .scene .view-switch button { padding: 0 9px; }
  .target-panel { width: 112px; top: 84px; left: 8px; padding: 8px; }
  .target-grid span { font-size: 10px; }
  .game-actions { flex-wrap: wrap; }
}

/* Exhibit welcome screen: one large, accessible tap target over the live board. */
.welcome { position: fixed; inset: 0; z-index: 5; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; background: transparent; color: var(--green); cursor: pointer; }
.welcome-copy { position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%); width: calc(100% - 32px); display: flex; flex-direction: column; align-items: center; text-shadow: 0 2px 28px var(--paper), 0 0 60px var(--paper); }
.welcome-title { font: clamp(64px, 12vw, 144px)/1 Georgia, serif; font-weight: 400; letter-spacing: -.055em; }
.welcome-subtitle { margin-top: 18px; color: var(--muted); font-size: clamp(15px, 2.2vw, 22px); font-weight: 400; }
.welcome-prompt { margin-top: 28px; font-size: clamp(13px, 1.7vw, 16px); font-weight: 500; letter-spacing: .035em; }
.welcome:hover, .welcome:active { background: transparent; transform: none; }
.welcome:focus-visible { outline-offset: -10px; }
.landing-active { min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 55%, #fffdf6, #efefe5); }
.landing-active .app-bar, .landing-active .game-panel, .landing-active .toolbar, .landing-active .scene-top, .landing-active .scene-bottom, .landing-active .target-panel { display: none; }
.landing-active .workspace { padding: 0; background: transparent; }
.landing-active .scene { min-height: 0; }
.landing-active canvas { top: 32%; left: 0; width: 100%; height: 68%; opacity: .78; pointer-events: none; }
.facilitator { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.facilitator button { padding: 0 16px; font-size: 12px; color: var(--muted); }
#participant-description { color: var(--muted); }
.participant-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.participant-actions button { flex: 1; padding: 12px 16px; }
#participant-reset { position: relative; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; color: #813c2f; border-color: #dac6ba; background: #fcf4eb; }
#participant-reset::before { content: ''; position: absolute; inset: 0; background: #e6bfa5; transform-origin: left; transform: scaleX(var(--reset-progress, 0)); }
#participant-label { position: relative; }

.versus-panel { width: min(100%, 1080px); align-self: center; margin-top: 16px; padding: 18px 22px; border: 1px solid #dfd1c9; border-radius: 22px; background: #fffaf5; }
.versus-panel[data-player="2"] { border-color: #c4d4e4; background: #f4f9ff; }
.versus-heading { display: flex; align-items: center; gap: 22px; }
.versus-heading > div:first-child { flex: 1; }
.versus-panel .eyebrow { margin-bottom: 4px; }
.versus-panel h2 { font: 28px/1.15 Georgia, serif; color: #ab392f; }
.versus-panel[data-player="2"] h2 { color: #245c9a; }
.versus-scores { display: flex; gap: 18px; font-size: 12px; }
.versus-scores output { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.red-player { color: #ab392f; }
.blue-player { color: #245c9a; }
#versus-new { padding: 0 16px; font-size: 12px; }
#versus-message { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.versus-active .drop-size-control, .versus-active .speed-control, .versus-active .reset-controls, .versus-active .legend { display: none; }
.versus-active .toolbar { display: block; max-width: 650px; }
.versus-active .grain-control { border: 0; padding: 0; }
.versus-active .scene { min-height: 270px; }
.versus-active #drop[data-player="1"] { background: #ab392f; border-color: #ab392f; }
.versus-active #drop[data-player="2"] { background: #245c9a; border-color: #245c9a; }
.landing-active .versus-panel { display: none; }
@media (max-width: 700px) { .app-bar .mode-switch { width: auto; } .mode-switch button { padding: 0 10px; } }
@media (max-width: 520px) { .versus-panel { padding: 14px; } .versus-heading { flex-wrap: wrap; gap: 12px; } .versus-heading h2 { font-size: 24px; } .versus-scores { gap: 12px; } }

/* A level keeps its header small; navigation lives in the level menu. */
.level-header { display: flex; align-items: center; gap: 18px; min-width: 0; }
.level-header h1 { font-size: 25px; letter-spacing: -.4px; }
#level-menu-open { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 14px; }
.game-active .app-bar { flex-wrap: nowrap; flex-basis: 66px; }
.game-active .app-bar > .brand, .game-active .app-bar > .mode-switch, .game-active .header-actions .legend { display: none; }
.game-active .header-actions { margin-left: auto; }
.game-active .game-panel { flex-shrink: 0; margin: 0; padding: 14px 12px 4px; border: 0; border-radius: 12px; background: transparent; }
.game-active .game-panel .game-prompt { margin: 0; font-size: 20px; line-height: 1.35; font-weight: 550; }
.game-goal { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; }
.match-budget { padding: 10px 16px; border: 1px solid #b5cbbb; border-radius: 12px; background: #edf4e9; color: #284f3d; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.match-budget[data-exhausted="true"] { background: #f4eee2; border-color: #d5c4a8; color: #70512f; }
.game-active .game-panel #game-message { font-size: 15px; }
.game-active .game-panel[data-status="won"] { background: #edf4e5; }
.game-active .game-panel[data-status="retry"] { background: #faf0e8; }
#level-menu { width: min(590px, calc(100% - 32px)); }
#level-menu .dialog-heading { margin-bottom: 20px; align-items: center; }
#level-menu-close { font-size: 25px; border: 0; background: transparent; }
#level-menu .level-library { flex-wrap: wrap; margin-bottom: 18px; }
#level-menu .level-progress { display: grid; grid-template-columns: 1fr; gap: 8px; }
#level-menu .level-progress button { min-height: 48px; padding: 12px 34px 12px 16px; border-radius: 12px; text-align: left; font-size: 14px; }
#level-menu .level-progress button.complete::after { right: 12px; top: 50%; transform: translateY(-50%); }
.level-menu-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.level-menu-footer > div { display: flex; gap: 8px; }
.level-menu-footer button { padding: 0 14px; font-size: 12px; }
@media (max-width: 520px) { .level-header { gap: 8px; } .level-header h1 { font-size: 21px; } #level-menu-open { padding: 0 6px; } .game-active .app-bar { gap: 6px; } }

/* Quiet camera controls with compact visuals and generous touch targets. */
.camera-controls { gap: 4px; }
.scene .view-switch, .rotation-controls, .zoom-controls { padding: 0; gap: 0; border: 0; border-radius: 9px; background: transparent; overflow: visible; }
.scene .view-switch button, .rotation-controls button, .zoom-controls button { min-height: 36px; min-width: 36px; padding: 0 7px; border: 0; border-radius: 8px; background: transparent; color: #71796e; font-size: 16px; box-shadow: none; }
.scene .view-switch button { font-size: 11px; padding: 0 8px; }
.scene .view-switch button[aria-pressed="true"] { color: var(--green); background: linear-gradient(#35624e0c, #35624e0c) center / 100% 28px no-repeat; box-shadow: none; }
.rotation-controls #view-home, .zoom-controls #zoom-reset { min-width: 40px; padding: 0 4px; font-size: 10px; }
.rotation-controls svg { width: 16px; height: 16px; }
.view-controls { gap: 6px; }
@media (pointer: coarse) {
  .scene .view-switch button, .rotation-controls button, .zoom-controls button { min-height: 44px; min-width: 44px; }
}

/* The target shares the board camera; Match the Pattern has a map of states. */
#target-grid { position: static; display: block; width: 100%; height: auto; aspect-ratio: 1; cursor: default; pointer-events: none; }
.graph-active .target-panel { width: 176px; top: 88px; padding: 10px; pointer-events: auto; }
.graph-active .scene { min-height: 440px; }
.graph-active #sandpile { cursor: grab; }
.graph-active #sandpile.rotating { cursor: grabbing; }
@media (max-width: 700px) {
  .graph-active .target-panel { width: 130px; left: 6px; padding: 8px; }
}
.graph-active .scene-top { justify-content: flex-end; }

/* Mode instructions appear once, leaving a short goal above the board. */
#mode-intro { width: min(460px, calc(100% - 32px)); }
#mode-intro .dialog-heading { margin-bottom: 20px; align-items: center; }
#intro-close { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 25px; }
#intro-lead { margin: 0 0 12px; font-size: 22px; line-height: 1.3; font-weight: 550; }
#intro-copy { margin: 0; font-size: 16px; line-height: 1.6; color: var(--muted); }
#intro-dismiss { width: 100%; margin-top: 24px; font-size: 16px; }
#intro-reopen { padding: 0 16px; }
