.aq-shell { --aq-paper: #f5fcf7; --aq-ink: #153b3d; --aq-line: #829f98; color: var(--ink); isolation: isolate; }
.aq-shell[data-display=screen] { --aq-paper: #12343a; --aq-ink: #f0fcf4; --aq-line: #789e9e; }
.aq-stage { padding: 14px; background: #dae7df; }
.aq-shell[data-display=screen] .aq-stage { background: #0e292f; }
.aq-world { position: relative; isolation: isolate; overflow: hidden; border: 2px solid #31585a; border-radius: 18px; padding: 18px 24px 14px; background: #507c77; display: flex; flex-direction: column; box-shadow: 0 4px 0 #284749, 0 8px 18px #153b3d30; }
.aq-backdrop { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; pointer-events: none; }
.aq-world::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg,#123c394a,transparent 65%); pointer-events: none; }
.aq-brief { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; color: var(--aq-ink); }
.aq-brief>div { background: var(--aq-paper); border: 1px solid var(--aq-line); border-radius: 12px; padding: 10px 16px; box-shadow: 0 3px 0 #264e4c60; min-width: 0; }
.aq-brief>div:first-child { flex: 1; }
.aq-brief span { font: 600 13px/1.4 var(--font-sans); display: block; }
.aq-brief h2 { font: 700 clamp(20px,2.2vw,28px)/1.3 var(--font-sans); margin: 2px 0 0; color: inherit; overflow-wrap: anywhere; }
.aq-protocol { display: flex; justify-content: center; flex-direction: column; }
.aq-protocol strong { font: 700 clamp(18px,2vw,26px)/1.4 var(--font-sans); white-space: nowrap; }
.aq-tanks { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 22px; align-items: stretch; width: 100%; max-width: 900px; margin: 16px auto 10px; }
.aq-tank { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px 8px 12px; min-width: 0; background: transparent; border: 2px solid transparent; border-radius: 16px; color: var(--aq-ink); font-family: var(--font-sans); cursor: pointer; transition: background .18s, border-color .18s, box-shadow .18s; }
.aq-tank:disabled { cursor: default; opacity: 1; }
.aq-tank:not(:disabled):hover { background: #ffffff26; border-color: #f5fff799; }
.aq-tank[data-selected=source] { border-color: #fff4b0; background: #fff4b038; box-shadow: 0 0 0 3px #3d674e, inset 0 0 20px #fff5b536; }
.aq-tank[data-selected=target] { border-color: #b6fff0; background: #73f1d73d; box-shadow: 0 0 0 3px #245b60, inset 0 0 20px #80ffdf2e; }
.aq-tank-title { display: flex; align-items: center; flex-direction: column; padding: 5px 12px; border: 1px solid var(--aq-line); background: var(--aq-paper); border-radius: 9px; max-width: 100%; box-shadow: 0 2px 0 #284b4a50; }
.aq-tank-title b { font-size: 20px; line-height: 1.3; }
.aq-tank-title>span { font-size: 13px; line-height: 1.4; }
.aq-equipment { position: relative; display: block; width: 100%; height: 230px; margin: 4px 0; }
.aq-tank-art { width: 100%; height: 100%; display: block; overflow: hidden; }
.aq-water { transition: transform .85s ease-in-out; }
.aq-role { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: 14px; line-height: 1.4; font-weight: 700; background: var(--aq-paper); border: 1px solid var(--aq-line); border-radius: 8px; padding: 3px 12px; white-space: nowrap; }
.aq-role:empty, .aq-tank[data-selected=none] .aq-role { visibility: hidden; }
.aq-world[data-done=true] .aq-role { visibility: visible; color: #195335; background: #efffdf; }
.aq-reading { min-width: 118px; max-width: 100%; background: var(--aq-paper); color: var(--aq-ink); padding: 6px 12px; border: 1px solid var(--aq-line); border-radius: 12px; box-shadow: 0 3px 0 #203e3f80; display: flex; flex-direction: column; align-items: center; }
.aq-reading>strong { font-size: 34px; line-height: 1.15; font-weight: 700; }
.aq-reading>span { font-size: 14px; line-height: 1.5; }
.aq-tank[data-matched=true] .aq-reading { border-color: #446a48; }
/* Transfer arc: drawn under the tank buttons (whose labels are solid cards), from
 * the source column to the destination. Dashes travel towards the destination. */
.aq-tanks { position: relative; }
.aq-tank { z-index: 1; }
.aq-arc { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: visible; }
.aq-arc path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.aq-arc-pipe { stroke: #5a3d26; stroke-width: 16px; opacity: .85; }
.aq-arc-water { stroke: #8af4ee; stroke-width: 8px; stroke-dasharray: 14 12; }
.aq-arc[data-flow=true] .aq-arc-pipe { stroke: #c27f45; }
.aq-arc[data-flow=true] .aq-arc-water { stroke: #b5fff7; animation: aq-stream .45s linear infinite; }
.aq-brief-main { display: flex; align-items: center; gap: 12px; }
.aq-brief-main>div { flex: 1; min-width: 0; }
.aq-keeper { flex-shrink: 0; width: 66px; height: 66px; overflow: visible; }
.aq-keeper-lamp { transition: fill .2s; }
.aq-keeper[data-mood=flow] .aq-keeper-lamp { animation: aq-blink .35s ease-in-out infinite alternate; }
.aq-keeper[data-mood=blocked] .aq-keeper-body { animation: aq-shake .4s ease-in-out; transform-origin: 62px 100px; }
.aq-keeper[data-mood=done] .aq-keeper-body { animation: aq-hop .7s ease-in-out 3; transform-origin: 62px 118px; }
/* Result: the station powers up. Warm lamp glows and light shafts sit behind the
 * reading cards (z-index -1 like the backdrop shade), never behind the text. */
.aq-glow { position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 15% 8%,#ffe9a066,transparent 28%),radial-gradient(circle at 50% 4%,#fff2bf73,transparent 30%),radial-gradient(circle at 85% 8%,#ffe9a066,transparent 28%),linear-gradient(0deg,#7ff5d533,transparent 45%); animation: aq-arrive .8s ease-out both; }
.aq-glow i { position: absolute; top: -10%; width: 14%; height: 120%; background: linear-gradient(180deg,#fff7d066,transparent 80%); transform: skewX(-18deg); animation: aq-shaft 3.2s ease-in-out infinite alternate; }
.aq-glow i:nth-child(1) { left: 12%; } .aq-glow i:nth-child(2) { left: 44%; animation-delay: .6s; } .aq-glow i:nth-child(3) { left: 76%; animation-delay: 1.2s; }
.aq-world[data-done=true] .aq-water rect { filter: brightness(1.15) saturate(1.2); }
.aq-console { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--aq-paper); color: var(--aq-ink); border: 1px solid var(--aq-line); border-radius: 14px; margin-top: 14px; padding: 12px 16px; }
.aq-status { flex: 1; min-width: 0; }
.aq-instruction { font: 700 18px/1.4 var(--font-sans); margin: 0; }
.aq-rule { font: 500 13px/1.5 var(--font-sans); margin: 5px 0 0; }
.aq-counters { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; flex-shrink: 0; margin: 0; }
.aq-counters dt { font-size: 13px; line-height: 1.4; font-weight: 600; }
.aq-counters dd { font: 700 24px/1.25 var(--font-sans); margin: 4px 0 0; }
.aq-dock { padding: 14px 20px; }
.aq-dock .sprout-controls { flex-wrap: wrap; }
.aq-warning { background: var(--surface); color: var(--ink); margin: 0; padding: 12px 18px; font-size: 14px; }
.aq-settings { padding: 18px 20px; border-top: 1px solid var(--border); }
.aq-settings h3 { font: 700 17px/1.4 var(--font-sans); margin: 0 0 12px; }
.aq-missions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.aq-missions .lb-tool { display: grid; grid-template-columns: 26px 1fr; padding: 10px 12px; text-align: left; white-space: normal; height: auto; min-width: 0; }
.aq-missions b { grid-row: span 2; font-size: 20px; }
.aq-missions span { font-size: 14px; line-height: 1.4; }
.aq-missions small { font-size: 13px; line-height: 1.4; }
.aq-missions [aria-pressed=true] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.aq-stars-help { font: 500 13px/1.6 var(--font-sans); color: var(--muted); padding: 0 20px 16px; margin: 0; }
.aq-history { border-top: 1px solid var(--border); padding: 14px 20px; font-size: 14px; }
.aq-history summary { cursor: pointer; font-weight: 600; }
.aq-history ol { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px 26px; max-height: 260px; overflow: auto; padding-left: 26px; }
.aq-history li { padding: 3px; }
.aq-dialog { max-width: 620px; width: calc(100% - 32px); max-height: 85dvh; overflow: auto; padding: 26px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); }
.aq-dialog::backdrop { background: #102f36c9; }
.aq-dialog h2 { font-size: 26px; margin: 0 0 18px; }
.aq-dialog h3 { font-size: 19px; margin: 16px 0 6px; }
.aq-dialog p { font-size: 15px; line-height: 1.7; }
.aq-dialog .sprout-controls { flex-wrap: wrap; }
.aq-shell button:focus-visible { outline: 3px solid #008cb0; outline-offset: 3px; }
.aq-victory-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.aq-stars { flex-shrink: 0; font-size: 38px; line-height: 1.1; color: #6d4510; white-space: nowrap; animation: aq-arrive .5s ease-out both; }
.aq-shell[data-display=screen] .aq-stars { color: #ffda7b; }
.aq-world[data-done=true] { box-shadow: 0 0 0 3px #d6b56c,0 8px 20px #2f695e50; }
.aq-world[data-done=true] .aq-backdrop { filter: saturate(1.12) brightness(1.08); }
.aq-world[data-done=true] .aq-equipment { height: 180px; }
.aq-bubble { animation: aq-bubble .7s ease-out both; }

/* Ready needs the task and launch button, rather than an unused move journal.
 * Keep the full equipment scale for play and for the audience presentation. */
@media(min-width:851px) {
  .aq-shell[data-phase=setup]:not(.aq-present) .aq-world { padding-top: 12px; padding-bottom: 12px; }
  .aq-shell[data-phase=setup]:not(.aq-present) .aq-equipment { height: 160px; }
  .aq-shell[data-phase=setup]:not(.aq-present) .aq-counters,
  .aq-shell[data-phase=setup]:not(.aq-present) .aq-rule { display: none; }
}

/* Presentation uses available height. Keep all three tanks, targets and the
 * action visible together; setup and history never consume audience space. */
.aq-present { position: fixed; inset: 0; z-index: 10000; width: 100%; height: 100dvh; border: 0; border-radius: 0; display: flex; flex-direction: column; }
.aq-present .sprout-bar { flex-shrink: 0; padding: 8px 16px; }
.aq-present .aq-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 20px; }
.aq-present .aq-world { flex: 1; min-height: 0; padding: 14px 24px 12px; }
.aq-present .aq-tanks { flex: 1; min-height: 0; max-width: 1250px; margin: 12px auto 6px; gap: 5%; }
.aq-present .aq-tank { min-height: 0; padding: 4px 8px 8px; }
.aq-present .aq-equipment, .aq-present .aq-world[data-done=true] .aq-equipment { flex: 1; min-height: 0; height: auto; }
.aq-present .aq-tank-title { flex-shrink: 0; flex-direction: row; gap: 12px; }
.aq-present .aq-tank-title b { font-size: clamp(22px,2vw,34px); }
.aq-present .aq-tank-title>span { font-size: clamp(15px,1.25vw,22px); }
.aq-present .aq-reading { flex-shrink: 0; flex-direction: row; gap: 14px; padding: 6px 20px; }
.aq-present .aq-reading>strong { font-size: clamp(36px,3.2vw,62px); }
.aq-present .aq-reading>span { font-size: clamp(18px,1.6vw,28px); }
.aq-present .aq-brief h2 { font-size: clamp(25px,2.5vw,42px); }
.aq-present .aq-brief span { font-size: clamp(15px,1.2vw,22px); }
.aq-present .aq-protocol strong { font-size: clamp(26px,2.5vw,42px); }
.aq-present .aq-console { flex-shrink: 0; padding: 10px 16px; margin-top: 12px; }
.aq-present .aq-instruction { font-size: clamp(24px,2.5vw,38px); }
.aq-present .aq-rule { font-size: clamp(14px,1.1vw,19px); }
.aq-present .aq-counters { gap: 18px; }
.aq-present .aq-counters dt { font-size: clamp(14px,1.1vw,20px); }
.aq-present .aq-counters dd { font-size: clamp(26px,2vw,38px); }
.aq-present .aq-dock { flex-shrink: 0; padding: 10px 20px; }
.aq-present .aq-stars { font-size: clamp(38px,3.5vw,64px); }
.aq-present .aq-keeper { width: clamp(66px,6vw,104px); height: clamp(66px,6vw,104px); }
@media(max-width:850px) {
  .aq-console { flex-direction: column; align-items: stretch; gap: 12px; }
  .aq-counters { gap: 12px; }
  .aq-brief { gap: 10px; }
  .aq-brief>div { padding: 8px 12px; }
  .aq-tanks { gap: 8px; }
  .aq-equipment { height: 180px; }
  .aq-missions { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:600px) {
  .aq-stage { padding: 8px; }
  .aq-world { padding: 12px 6px; }
  .aq-brief { flex-direction: column; gap: 8px; }
  .aq-brief>div { padding: 8px 10px; }
  .aq-brief h2 { font-size: 20px; }
  .aq-keeper, .aq-present .aq-keeper { width: 46px; height: 46px; }
  .aq-protocol { flex-direction: row; align-items: center; gap: 8px; }
  .aq-protocol strong { font-size: 18px; white-space: normal; }
  .aq-tanks { gap: 4px; margin: 12px auto; }
  .aq-tank { padding: 4px 0 8px; border-radius: 12px; }
  .aq-tank-title { padding: 4px; width: 100%; }
  .aq-tank-title b { font-size: 16px; }
  .aq-tank-title>span { font-size: 13px; }
  .aq-equipment, .aq-world[data-done=true] .aq-equipment { height: clamp(110px,27vw,160px); }
  .aq-reading { min-width: 0; width: 100%; padding: 6px 2px; }
  .aq-reading>strong { font-size: 28px; }
  .aq-reading>span { font-size: 13px; }
  .aq-role { font-size: 13px; padding: 1px 5px; }
  .aq-console { padding: 10px; margin-top: 10px; }
  .aq-instruction { font-size: 17px; }
  .aq-counters { gap: 6px; }
  .aq-counters dt { font-size: 13px; }
  .aq-counters dd { font-size: 22px; }
  .aq-dock { padding: 12px; }
  .aq-settings { padding: 14px 12px; }
  .aq-missions { gap: 8px; }
  .aq-missions .lb-tool { grid-template-columns: 20px 1fr; padding: 8px; gap: 4px; }
  .aq-stars-help { padding: 0 12px 14px; }
  .aq-history ol { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .aq-victory-heading { flex-direction: column; gap: 4px; align-items: flex-start; }
  .aq-stars { font-size: 26px; }
  .aq-dialog { padding: 20px; }
  .aq-dialog h2 { font-size: 24px; }
  .aq-present .aq-stage { padding: 8px; }
  .aq-present .aq-world { padding: 8px 6px; }
  .aq-present .aq-brief { flex-direction: column; gap: 4px; }
  .aq-present .aq-brief h2 { font-size: 18px; }
  .aq-present .aq-protocol strong { font-size: 20px; }
  .aq-present .aq-tanks { gap: 4px; }
  .aq-present .aq-tank { padding: 2px 0 6px; }
  .aq-present .aq-tank-title { flex-direction: column; gap: 0; }
  .aq-present .aq-tank-title b { font-size: 17px; }
  .aq-present .aq-tank-title>span { font-size: 13px; }
  .aq-present .aq-reading { padding: 4px 2px; flex-direction: column; gap: 0; }
  .aq-present .aq-reading>strong { font-size: 26px; }
  .aq-present .aq-reading>span { font-size: 13px; }
  .aq-present .aq-instruction { font-size: 18px; }
  .aq-present .aq-counters dt { font-size: 13px; }
  .aq-present .aq-counters dd { font-size: 22px; }
  .aq-present .aq-rule { display: none; }
  .aq-present .aq-stars { font-size: 26px; }
  /* Audience controls use two rows. Setup stays available after leaving the
   * presentation; the visible exit has a full accessible name in PuzzleToolbar. */
  .aq-present .sprout-bar [data-action=fullscreen] span { display: none; }
  .aq-present .aq-dock [data-action=setup] { display: none; }
  .aq-present .aq-counters { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .aq-present .aq-counters>div:last-child { display: none; }
  .aq-present .aq-brief>div { padding: 6px 8px; }
}
@media(max-height:540px) and (min-width:601px) {
  /* Share the short landscape height between status and actions on the right.
   * The equipment keeps the full height below the toolbar, rather than shrinking
   * to make room for a second full-width row of teacher controls. */
  .aq-present { display: grid; grid-template-columns: minmax(0,1fr) 210px; grid-template-rows: auto minmax(0,1fr) auto; column-gap: 10px; }
  .aq-present .sprout-bar { grid-column: 1 / -1; }
  .aq-present .aq-stage { display: contents; }
  .aq-present .aq-world { grid-column: 1; grid-row: 2 / 4; margin: 6px 0 6px 12px; padding: 6px 12px; }
  .aq-present .aq-brief>div { padding: 4px 10px; }
  .aq-present .aq-brief h2 { font-size: 20px; }
  .aq-present .aq-brief span { font-size: 13px; }
  .aq-present .aq-keeper { width: 44px; height: 44px; }
  .aq-present .aq-protocol strong { font-size: 24px; }
  .aq-present .aq-tanks { margin: 4px auto; gap: 8px; }
  .aq-present .aq-tank { padding: 2px 0 6px; border-width: 1px; }
  .aq-present .aq-tank-title { flex-direction: row; gap: 6px; padding: 2px 6px; white-space: nowrap; }
  .aq-present .aq-tank-title b { font-size: 18px; }
  .aq-present .aq-tank-title>span { font-size: 13px; }
  .aq-present .aq-reading { flex-direction: row; gap: 10px; padding: 2px 10px; }
  .aq-present .aq-reading>strong { font-size: 24px; }
  .aq-present .aq-reading>span { font-size: 14px; }
  .aq-present .aq-console { grid-column: 2; grid-row: 2; margin: 6px 12px 0 0; padding: 10px; flex-direction: column; gap: 12px; }
  .aq-present .sprout-bar [data-action=fullscreen] span { display: none; }
  .aq-present .aq-dock [data-action=setup] { display: none; }
  .aq-present .aq-counters { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .aq-present .aq-counters>div:last-child { display: none; }
  .aq-present .aq-rule { display: none; }
  .aq-present .aq-instruction { font-size: 20px; }
  .aq-present .aq-counters dt { font-size: 13px; }
  .aq-present .aq-counters dd { font-size: 20px; }
  .aq-present .aq-stars { font-size: 28px; }
  .aq-present .sprout-bar { padding: 6px 12px; }
  .aq-present .aq-dock { grid-column: 2; grid-row: 3; padding: 6px 12px 6px 0; border: 0; }
  .aq-present .aq-dock .sprout-primary { min-width: 0; width: 100%; padding: 10px 12px; font-size: 16px; }
}
.aq-reduced .aq-water { transition: none; }
@media(prefers-reduced-motion:reduce) {
  .aq-water { transition: none; }
}
@keyframes aq-bubble { to { transform: translateY(-70px); opacity: 0; } }
@keyframes aq-stream { to { stroke-dashoffset: -26; } }
@keyframes aq-blink { to { fill: #e9ffff; } }
@keyframes aq-shake { 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes aq-hop { 50% { transform: translateY(-7px) rotate(-4deg); } }
@keyframes aq-shaft { from { opacity: .35; } to { opacity: 1; } }
@keyframes aq-arrive { from { transform: translateY(8px); opacity: 0; } }

.aq-reduced :is(.aq-stars, .aq-bubble, .aq-arc-water, .aq-keeper-lamp, .aq-keeper-body, .aq-glow, .aq-glow i) { animation: none; }
@media(prefers-reduced-motion:reduce) { :is(.aq-stars, .aq-bubble, .aq-arc-water, .aq-keeper-lamp, .aq-keeper-body, .aq-glow, .aq-glow i) { animation: none; } }
