/* Down Below. One stylesheet; fonts and sizes are decided here only. Painted plates come from assets/art/ui. */
:root {
  --font-ui: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, "Noto Sans", var(--sbg-font-fallback, sans-serif);
  --fs: 16px;
  --ink: #f4e8cf; --ink-dim: #cdbd9a; --dark: #2a1d0e; --night: #05080d; --teal: #75ebcf; --amber: #ffd26a; --danger: #ff655f; --warn: #ffb45c;
  --plate: url("./assets/art/ui/panel-wide.webp"); --plate-narrow: url("./assets/art/ui/panel-narrow.webp");
  --btn: url("./assets/art/ui/btn.webp"); --btn-lit: url("./assets/art/ui/btn-lit.webp"); --btn-down: url("./assets/art/ui/btn-pressed.webp");
  --trough: url("./assets/art/ui/trough.webp");
  --gap: 10px;
}
:root[data-text="large"] { --fs: 19px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font: var(--fs)/1.35 var(--font-ui); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: none; touch-action: none; outline: none; }
body[data-mode="play"] #game { display: block; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: inherit; }

/* plates and buttons */
.plate { border: 16px solid transparent; border-image: var(--plate) 40 44 fill / 16px 18px / 0 stretch; color: var(--ink); }
.plate-btn { border: 12px solid transparent; border-image: var(--btn) 34 30 fill / 12px 11px / 0 stretch; background: none; color: var(--dark); font-weight: 700; padding: 4px 14px; min-height: 52px; text-align: center; letter-spacing: 0.01em; text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5); }
.plate-btn:hover:not(:disabled), .plate-btn:focus-visible { border-image-source: var(--btn-lit); }
.plate-btn:active:not(:disabled) { border-image-source: var(--btn-down); }
.plate-btn.primary { border-image-source: var(--btn-lit); }
.plate-btn.small { min-height: 44px; padding: 2px 10px; }
.plate-btn:disabled { filter: grayscale(0.7) brightness(0.75); }
.exit-link { position: fixed; z-index: 30; inset-block-end: 8px; inset-inline-start: 8px; text-decoration: none; display: grid; place-items: center; }
/* On a touch screen the tool bar fills the bottom edge during a run: the back link would sit on Cut and Brace (a tap left the demo). */
body[data-mode="play"][data-touch="true"] .exit-link { display: none; }
.ico, .exh, .tile { display: inline-block; width: 1em; height: 1em; font-size: 40px; flex: none; }
.ico.big { font-size: 64px; } .exh.big { font-size: 96px; }
.tile { font-size: 28px; border-radius: 4px; }

/* screens */
#screen { position: absolute; inset: 0; background: #0a0f16 center / cover no-repeat; }
body[data-mode="title"] #screen { background-image: linear-gradient(rgba(5, 8, 13, 0.25), rgba(5, 8, 13, 0.7)), url("./assets/art/key-art.webp"); }
body[data-mode="station"] #screen { background-image: linear-gradient(rgba(5, 8, 13, 0.55), rgba(5, 8, 13, 0.82)), url("./assets/art/museum.webp"); }
.title-screen { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center; }
.logo { width: min(78vw, 520px, 56vh * 1.75); height: auto; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.7)); }
.tagline { max-width: 34em; color: var(--ink); text-shadow: 0 2px 6px #000; }
.menu { display: flex; flex-direction: column; gap: 4px; width: min(86vw, 330px); }
.menu-btn { width: 100%; }
.notice { position: absolute; inset-block-end: 10px; inset-inline: 0; font-size: 0.8rem; color: var(--ink-dim); text-shadow: 0 1px 3px #000; }
.station { height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 8px; }
.station-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 0 6px; }
.station-head h2 { font-size: 1.3rem; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(216, 180, 92, 0.5); border-radius: 6px; padding: 8px 14px; min-height: 44px; color: var(--ink); }
.tab[aria-selected="true"] { background: rgba(216, 180, 92, 0.3); border-color: var(--amber); font-weight: 700; }
.medal-total { display: inline-flex; align-items: center; gap: 4px; } .medal-total .ico { font-size: 28px; }
.station-body { overflow: auto; padding: 4px 6px 8px; scrollbar-color: #8b6a2d transparent; }
.station-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
.foot-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-width: 0; }
.progress-line { color: var(--ink-dim); margin-block: 4px; }
.band header { margin-block: 12px 6px; } .band h3 { font-size: 1.15rem; color: var(--amber); } .band header p { color: var(--ink-dim); font-size: 0.9rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 232px), 1fr)); gap: var(--gap); }
.plate-card { display: flex; flex-direction: column; gap: 4px; text-align: start; padding: 10px 12px; color: var(--ink); background: rgba(10, 14, 20, 0.82); border: 2px solid rgba(216, 180, 92, 0.55); border-radius: 10px; }
.plate-card:hover:not(:disabled), .plate-card:focus-visible { border-color: var(--amber); background: rgba(34, 26, 12, 0.88); }
.plate-card[data-selected="true"], .plate-card[data-active="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(117, 235, 207, 0.4), 0 0 18px rgba(117, 235, 207, 0.25); }
.plate-card[data-done="true"] strong::after { content: ""; }
.plate-card[data-locked="true"] { opacity: 0.6; }
.plate-card .objective, .plate-card .desc { font-size: 0.88rem; color: var(--ink-dim); }
.plate-card .stats { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 0.8rem; color: var(--ink-dim); }
.plate-card .equip { margin-block-start: auto; color: var(--amber); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 0.74rem; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(216, 180, 92, 0.5); }
.chip[data-kind="gas"] { border-color: #b6c94a; } .chip[data-kind="tremor"] { border-color: #e49b5c; } .chip[data-kind="flood"] { border-color: #63c7ef; }
.medal-row { display: flex; gap: 4px; } .medal-row .medal { font-size: 24px; }
.medal[data-earned="false"], .medal-card[data-earned="false"] .ico { filter: grayscale(1) brightness(0.45); }
.locked-line, .hint { color: var(--ink-dim); font-size: 0.9rem; margin-block: 8px; }
.tier { margin-block-end: 12px; padding: 0 8px; } .tier h3 { color: var(--amber); }
.exhibit[data-open="false"] { opacity: 0.55; }
.exhibit { align-items: center; text-align: center; }
.specimens { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.specimens li { display: flex; align-items: center; gap: 8px; }
.kit h3 { margin-block: 12px 4px; color: var(--amber); }
.kit-card { align-items: flex-start; }

/* modals */
.modal-layer { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(2, 4, 8, 0.66); padding: 12px; }
.modal { width: min(94vw, 680px); max-height: 92vh; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.modal.small { width: min(94vw, 420px); }
.modal h2 { font-size: 1.4rem; color: var(--amber); text-align: center; }
.modal-scroll { overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-inline-end: 4px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.opt-group { border: 1px solid rgba(216, 180, 92, 0.4); border-radius: 8px; padding: 6px 12px 10px; margin: 0; display: grid; gap: 6px; }
.opt-group legend { color: var(--amber); padding: 0 6px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 40px; } .opt input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--amber); flex: none; }
.opt.slider { justify-content: space-between; } .opt.slider input { flex: 1; max-width: 55%; accent-color: var(--amber); }
.opt-text { display: flex; flex-direction: column; } .opt-text small { color: var(--ink-dim); }
.help-list { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 4px; }
.medals { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.medal-card { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 150px; text-align: center; } .medal-card small { color: var(--ink-dim); font-size: 0.75rem; }
.stat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; color: var(--ink-dim); }
.result p, .modal p { text-align: center; }

/* HUD */
#hud, #touch { position: absolute; inset: 0; pointer-events: none; direction: ltr; z-index: 5; }
#hud > *, #touch > * { pointer-events: auto; }
#hud[hidden], #touch[hidden] { display: none; }
.hud-top { position: absolute; inset-block-start: 6px; inset-inline: 6px; display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.hud-top .plate { border-width: 12px; border-image: var(--plate-narrow) 28 28 fill / 12px 12px / 0 stretch; padding: 0 2px; min-height: 58px; display: flex; align-items: center; }
.hud-objective { flex: 2 1 220px; flex-direction: column; align-items: flex-start !important; justify-content: center; gap: 0; }
.hud-objective small { color: var(--amber); font-size: 0.7rem; text-transform: none; }
.hud-objective strong { font-size: 0.92rem; line-height: 1.2; font-weight: 600; } .hud-objective .progress { color: var(--teal); font-weight: 700; }
.hud-gauges { flex: 2 1 280px; gap: 10px; }
.gauge { display: flex; flex-wrap: wrap; align-items: center; gap: 1px 6px; min-width: 112px; flex: 1; }
.gauge-label { flex: 1 0 100%; font-size: 0.68rem; color: var(--ink-dim); line-height: 1; }
.gauge-trough { flex: 1 1 64px; min-width: 56px; height: 16px; border-radius: 8px; background: #151a20; border: 1px solid #000; overflow: hidden; display: block; }
.gauge-fill { display: block; height: 100%; background: url("./assets/art/ui/fill-teal.webp") center / 100% 100%; transition: width 0.25s; }
.gauge[data-kind="charge"] .gauge-fill { background-image: url("./assets/art/ui/fill-amber.webp"); }
.gauge-fill[data-low="true"] { background-image: url("./assets/art/ui/fill-red.webp") !important; }
.gauge-text { font-size: 0.82rem; font-weight: 700; min-width: 2.4em; text-align: end; }
.roof { display: flex; flex-direction: column; min-width: 72px; } .roof strong { font-size: 0.82rem; }
.roof[data-level="watch"] strong { color: var(--amber); } .roof[data-level="strained"] strong { color: var(--warn); } .roof[data-level="critical"] strong { color: var(--danger); }
.samples { display: flex; align-items: center; gap: 2px; } .samples .ico { font-size: 28px; } .samples b { font-size: 1rem; }
.hud-forecast { flex: 1 1 200px; gap: 6px; } .hud-forecast .ico { font-size: 30px; }
.forecast-text { display: flex; flex-direction: column; line-height: 1.15; } .forecast-text small { font-size: 0.66rem; color: var(--ink-dim); } .forecast-text strong { font-size: 0.8rem; font-weight: 600; }
.hud-forecast[data-state="warn"] strong { color: var(--danger); }
.hud-buttons { display: flex; gap: 6px; align-items: center; } .hud-buttons .plate-btn { min-height: 52px; min-width: 52px; padding: 0 4px; display: grid; place-items: center; } .hud-buttons .ico { font-size: 30px; }
.hud-chips { position: absolute; inset-inline-start: 8px; inset-block-start: calc(var(--hud-bottom, 112px) + 6px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.hud-chips .chip { font-size: 0.85rem; background: rgba(5, 8, 13, 0.85); } .hud-chips .chip[data-hot="true"] { border-color: var(--danger); color: #ffd7d3; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 12px rgba(255, 101, 95, 0.7); } }
.toolbar { position: absolute; inset-block-end: 6px; inset-inline: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; padding-inline: 6px; }
.tool { pointer-events: auto; position: relative; width: 66px; min-height: 66px; padding: 3px 2px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid rgba(216, 180, 92, 0.7); border-radius: 12px; background: rgba(8, 12, 18, 0.9); }
.tool:hover:not(:disabled) { border-color: var(--amber); background: rgba(40, 30, 12, 0.92); }
.tool:disabled { opacity: 0.4; } .tool .ico { font-size: 36px; }
.tool-name { font-size: 0.64rem; line-height: 1; color: var(--ink); }
.tool .keycap { position: absolute; inset-block-start: 1px; inset-inline-start: 2px; font-size: 0.6rem; padding: 0 3px; border-radius: 3px; background: rgba(0, 0, 0, 0.65); color: var(--amber); }
.tool-count { position: absolute; inset-block-start: 1px; inset-inline-end: 3px; font-size: 0.78rem; color: var(--teal); }
.toast { margin: 0 auto; max-width: min(92vw, 560px); padding: 8px 16px; border-radius: 10px; background: rgba(8, 12, 18, 0.92); border: 2px solid var(--teal); text-align: center; animation: pop 0.2s ease-out; }
.toast[data-danger="true"] { border-color: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
#toasts { position: absolute; inset-inline: 0; inset-block-start: calc(var(--hud-bottom, 118px) + 14px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 8; padding-inline: 8px; }
.note { position: absolute; inset-inline: 0; margin-inline: auto; inset-block-end: 96px; width: min(92vw, 520px); z-index: 8; pointer-events: none; padding: 0 6px; }
.note[hidden] { display: none; } .note strong { color: var(--amber); } .note p { font-size: 0.9rem; }
.boot-failed { padding: 40px; text-align: center; }

/* touch */
body[data-touch="true"] .tool { width: 58px; min-height: 58px; } body[data-touch="true"] .tool .keycap { display: none; }
.dpad-ring { position: absolute; inset-inline-start: 8px; inset-block-end: 82px; width: 168px; height: 168px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 2px; }
.dpad { padding: 0; min-height: 0; border-width: 10px; font-size: 0.72rem; display: grid; place-items: center; touch-action: none; }
.dpad-up { grid-area: 1 / 2; } .dpad-left { grid-area: 2 / 1; } .dpad-right { grid-area: 2 / 3; } .dpad-down { grid-area: 3 / 2; }
.cut-btn { position: absolute; inset-inline-end: 8px; inset-block-end: 92px; width: 112px; height: 112px; border-radius: 50%; border-width: 18px; font-size: 1.1rem; }
@media (max-height: 460px) { .dpad-ring { width: 138px; height: 138px; inset-block-end: 76px; } .cut-btn { width: 96px; height: 96px; inset-block-end: 80px; } }

@media (max-width: 760px) {
  .hud-top .plate { min-height: 50px; } .hud-objective strong { font-size: 0.84rem; } .hud-gauges { flex-basis: 100%; }
}
@media (max-height: 460px) {
  .toast { padding: 4px 12px; font-size: 0.86rem; line-height: 1.25; } #toasts { gap: 4px; }
  .hud-top { gap: 4px; } .hud-top .plate { min-height: 44px; border-width: 9px; } .tool { min-height: 56px; width: 56px; } .tool .ico { font-size: 30px; }
  .station-head h2 { font-size: 1.05rem; } .station { gap: 4px; padding: 4px; } .tab { padding: 4px 10px; min-height: 36px; }
  .logo { width: min(60vw, 360px, 40vh * 1.75); } .menu { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(94vw, 760px); } .menu-btn { width: auto; min-width: 150px; }
}

/* display options */
:root[data-contrast="high"] .plate-card, :root[data-contrast="high"] .tool, :root[data-contrast="high"] .toast, :root[data-contrast="high"] .chip { border-color: #fff; }
:root[data-contrast="high"] .hud-top strong, :root[data-contrast="high"] .hud-top small { text-shadow: 0 0 3px #000, 0 0 3px #000; color: #fff; }
:root[data-contrast="high"] .roof[data-level="critical"] strong { text-decoration: underline; }
:root[data-motion="reduced"] * { transition: none !important; animation: none !important; }

/* phones: a one-row HUD in landscape, nothing past the edge in portrait, a compact station header */
@media (max-height: 460px) {
  .hud-top { inset-block-start: 4px; inset-inline: 4px; }
  .hud-top .plate { min-height: 40px; border-width: 8px; border-image-width: 8px 9px; }
  .hud-objective { flex: 2 1 150px; } .hud-objective strong { font-size: 0.8rem; } .hud-objective small { font-size: 0.62rem; }
  .hud-gauges { flex: 2 1 220px; gap: 6px; } .gauge { min-width: 88px; } .gauge-label { font-size: 0.6rem; } .gauge-text { font-size: 0.74rem; min-width: 2.2em; }
  .hud-forecast { flex: 1 1 150px; } .forecast-text strong { font-size: 0.72rem; } .hud-forecast .ico { font-size: 24px; }
  .hud-buttons { gap: 4px; } .hud-buttons .plate-btn { min-height: 40px; min-width: 40px; border-width: 8px; border-image-width: 8px 8px; } .hud-buttons .ico { font-size: 22px; }
  .station .plate { border-width: 9px; border-image-width: 9px 10px; } .station .plate-btn.small { min-height: 36px; }
  .station-head { gap: 4px 10px; } .station-foot .plate-btn.primary { min-height: 40px; }
}
@media (max-width: 760px) {
  .gauge { min-width: 90px; } .hud-gauges { gap: 6px; padding-inline: 4px; }
  .station-head h2 { order: 1; flex: 1; } .station-head > .plate-btn:last-child { order: 2; }
  .tabs { order: 3; flex-basis: 100%; } .station-head > .medal-total { order: 4; flex: 1; } .station-head > .plate-btn:nth-last-child(2) { order: 5; }
}

/* touch plates: the direction plates are painted arrows (the word is for screen readers and stays translatable), the Cut plate grows with its word */
.dpad::before { content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border: 11px solid transparent; }
.dpad { position: relative; }
.dpad-up::before { border-top-width: 0; border-bottom: 17px solid var(--dark); } .dpad-down::before { border-bottom-width: 0; border-top: 17px solid var(--dark); }
.dpad-left::before { border-left-width: 0; border-right: 17px solid var(--dark); } .dpad-right::before { border-right-width: 0; border-left: 17px solid var(--dark); }
.cut-btn { width: auto; min-width: 112px; padding-inline: 2px; } .cut-label { white-space: nowrap; }
@media (max-height: 460px) { .cut-btn { width: auto; min-width: 96px; } }
