/* Bugila – tyyli A (Piirros). */
:root {
  --bg: #FFF6E9; --paper: #FFFFFF; --ink: #2B2340; --muted: #5E5670;
  --pink: #FF8FAB; --pink-d: #E4607F; --mint: #7ED6B5; --mint-l: #F1FFF8; --sun: #FFD166; --sky: #8EC5FF; --focus: #3D7BE0;
  --r: 22px; --line: 3px solid var(--ink); --shadow: 5px 5px 0 var(--ink);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; }
h1, h2, h3, h4 { line-height: 1.2; overflow-wrap: break-word; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
h4 { font-size: .95rem; margin: .8rem 0 .3rem; }
p { margin: 0 0 .6rem; }
a { color: inherit; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -100px; background: var(--paper); border: var(--line); padding: 8px 12px; border-radius: 12px; z-index: 10; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.lead { font-size: 1.1rem; max-width: 60ch; }

/* Yläpalkki */
.top { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; max-width: 1280px; margin: 0 auto; padding: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.4rem; }
.logo svg { width: 40px; height: 40px; }
/* Alaotsikko vain kartalla ja tasovalikossa: pelinäkymässä yläpalkissa on tilatiedot. */
.tagline { font-size: .95rem; font-weight: 600; color: var(--muted); padding-left: 10px; border-left: 2px solid #D9D2C5; }
.top:has(#hud:not(:empty)) .tagline { display: none; }
@media (max-width: 600px) { .tagline { display: none; } }
.hud { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.chip { border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); padding: 3px 12px; font-weight: 700; font-size: .9rem; }
.badge { border: var(--line); border-radius: 999px; background: var(--sun); padding: 5px 14px; font-weight: 800; font-size: .85rem; box-shadow: 3px 3px 0 var(--ink); }
.foot { color: var(--muted); font-size: .85rem; padding-top: 32px; padding-bottom: 32px; }

/* Painikkeet */
.btn { font: inherit; font-weight: 700; border: var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); padding: 8px 14px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; min-height: 44px; }
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--sun); }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: .9rem; }
.btn.link { border: 0; box-shadow: none; background: none; text-decoration: underline; padding: 4px 0; }
.btn.link:hover:not(:disabled), .btn.link:active:not(:disabled) { box-shadow: none; transform: none; text-decoration-thickness: 2px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Kortit */
.card { background: var(--paper); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.panel { background: var(--paper); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.grid-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.is-soon { box-shadow: none; border-style: dashed; background: #FBF7F0; }
[hidden] { display: none !important; }
.intro { margin-bottom: 28px; }
.map svg { width: 100%; max-width: 720px; height: auto; display: block; border-radius: 14px; margin: 12px auto 0; }
.buildings h2 { margin-bottom: 14px; }
.levels { margin-top: 16px; }

/* Peli: tehtävärivi ja kaksi saraketta (tarina tai vaatimukset | automaatti) */
.taskline { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; background: #FFF3CC; border: 2px solid var(--ink); border-radius: 16px; padding: 10px 16px; margin-bottom: 20px; }
.taskline h2 { font-size: 1.05rem; margin: 0; }
.taskline p { margin: 0; flex: 1 1 30ch; }
.game { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); align-items: start; }
@media (max-width: 860px) { .game { grid-template-columns: minmax(0, 1fr); } .machine-col { order: -2; } }
.task .story, .task .reqs { margin-top: 0; }
.task .story { padding: 14px 18px; }
.task .story h2 { font-size: 1.1rem; }
.task .story p { font-size: 1rem; }
.task .reqs { background: var(--paper); }
.fb { margin-top: 14px; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 14px; background: var(--paper); }
.fb summary { font-weight: 800; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.fb[open] summary { margin-bottom: 4px; }
.tour-on .bug-note, .tour-on .s-next { display: none; }
.facts { list-style: none; padding: 0; margin: 4px 0 0; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .92rem; }
.facts li:not(:last-child)::after { content: "·"; margin-left: 8px; color: var(--muted); }
/* Vaatimukset tarkistuslistana */
.reqs-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.reqs-head h2 { margin: 0; font-size: 1.1rem; }
.reqs-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.reqs-total { margin: 6px 0 10px; color: var(--muted); font-size: .92rem; }
.rgroup { border-top: 2px solid #EDE6DA; }
.rgroup > summary { cursor: pointer; padding: 9px 4px; display: grid; grid-template-columns: 1.4em minmax(0, 1fr); align-items: baseline; list-style: none; min-height: 32px; }
.rgroup > summary::-webkit-details-marker { display: none; }
.rgroup > summary::before { content: "▶"; display: inline-block; font-size: .8rem; justify-self: start; }
.g-text { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.rgroup[open] > summary::before { transform: rotate(90deg); }
.g-name { font-weight: 800; }
.g-meta { color: var(--muted); font-size: .88rem; }
.g-done { font-size: .82rem; font-weight: 800; border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; background: var(--paper); }
.g-done.all { background: var(--mint-l); }
.rgroup fieldset { border: 0; margin: 0 0 10px; padding: 0; min-width: 0; }
.req { display: grid; grid-template-columns: 26px 3.2em minmax(0, 1fr); gap: 2px 6px; align-items: start; padding: 5px 4px; border-radius: 10px; line-height: 1.4; font-size: .92rem; cursor: pointer; }
.req:hover { background: #FFF8EC; }
.req input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); cursor: pointer; }
.req .vid { font-weight: 800; font-variant-numeric: tabular-nums; }
.req:has(input:checked) { background: #F4F1EC; }
.req:has(input:checked) .vtext { color: var(--muted); }
.req:has(input:checked) .vid::after { content: " ✓"; }
/* Puhelin: tarina tai vaatimukset alapalkin painikkeesta ikkunaan */
.src-bar { display: none; }
.src-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.src-head h2 { margin: 0; }
@media (max-width: 860px) {
  .game > .task { display: none; }
  .src-bar { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: #FFF6E9; border-top: 2px solid var(--ink); text-align: center; box-shadow: 0 -6px 12px rgba(43, 35, 64, .12); }
  .src-btn { min-width: 60%; }
  body:has(.src-bar) .foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
.feedback { padding-left: 1.1rem; margin: 0; }
.feedback li { margin: .35rem 0; }
.reqs { margin-top: 12px; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; }
.story { margin-top: 12px; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; background: var(--mint-l); }
.story h3 { margin-top: 0; }
.story p { margin: 0 0 8px; font-size: .95rem; }
.real ul { padding-left: 1.2rem; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tcard { display: flex; gap: 10px; align-items: center; justify-content: space-between; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 10px; flex-wrap: wrap; }
.tcard div { display: flex; flex-direction: column; min-width: 0; }
.tcard span { font-size: .88rem; color: var(--muted); }
.tcard.in-use { background: var(--mint-l); }

/* Automaatti */
.machine { background: var(--pink); border: var(--line); border-radius: 28px 28px 18px 18px; padding: 14px 16px 18px; box-shadow: var(--shadow); }
.possu { width: 92px; margin: -6px auto 0; }
.possu svg { width: 100%; height: auto; display: block; }
.m-title { text-align: center; font-size: 1.05rem; margin: 2px 0 10px; }
.screen { background: #F4FFF9; border: var(--line); border-radius: 14px; padding: 12px 14px; min-height: 150px; }
.screen:focus-visible { outline-offset: 4px; }
.s-head { font-weight: 700; margin: 0 0 4px; }
.s-main { font-size: 1.5rem; font-weight: 800; margin: 0 0 6px; overflow-wrap: anywhere; }
.s-msg { margin: 0; min-height: 1.5em; }
.receipt { margin-top: 10px; background: #fff; border: 2px dashed var(--ink); border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.receipt p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; } /* viesti täsmälleen kirjoitetussa muodossa (V26), pelitestaus 2026-12-01 */
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.opts:empty { display: none; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.keypad .btn { font-size: 1.15rem; }
.k-cancel { background: #FFE1E7 !important; }
.k-ok { background: var(--mint) !important; }
.slot { height: 12px; border: var(--line); border-radius: 8px; background: var(--ink); margin: 14px 28% 0; }
.transfer { margin-top: 10px; background: #F4FFF9; border: var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 4px; }
.transfer label { font-weight: 700; font-size: .92rem; margin-top: 4px; }
.transfer input, .transfer select, .report select, .report textarea { font: inherit; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; background: #fff; color: var(--ink); min-height: 44px; width: 100%; }
.tx-note { font-size: .82rem; color: var(--muted); margin: 0; }
.tx-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
/* Testikortit korttiaukon alla, automaatin sisällä */
.cards-panel { margin-top: 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.cards-panel h2 { font-size: 1rem; margin: 0 0 8px; }
/* Kapeassa paneelissa painike aina tekstin alle, ettei rivitys vaihtele kortista toiseen */
.cards-panel .tcard { flex-direction: column; align-items: flex-start; gap: 6px; }
.keypad.locked .btn { opacity: .35; }
.lock-note { margin: 8px 0 0; text-align: center; font-size: .88rem; font-weight: 700; }
/* Testaajan työkalut: suljettava tiivistelmärivi sovelluksen yläpuolella (sparraus 2026-11-28, työkalurivi) */
.toolbar { background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 3px 3px 0 var(--ink); margin-bottom: 14px; }
.toolbar > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 12px; min-height: 44px; }
.toolbar > summary::-webkit-details-marker { display: none; }
.toolbar .tb-title { font-size: 1rem; margin: 0; }
.tb-items { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .88rem; color: var(--muted); min-width: 0; }
.tb-items b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tb-toggle { grid-column: 2; grid-row: 1; font-size: .85rem; font-weight: 800; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.toolbar[open] .tb-toggle .when-closed, .toolbar:not([open]) .tb-toggle .when-open { display: none; }
.tb-hint { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.tb-panel { border-top: 2px solid #EDE6DA; padding: 4px 12px 12px; }
.clock, .tools { margin-top: 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.clock p, .tools p { margin: 0 0 4px; }
.clock h3, .tools h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.clock-ex { margin: 0 0 6px; padding-left: 1.1rem; }
.tools .btn-row { margin: 6px 0; }
.tool-contrast { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 6px 0; }
.tool-contrast label { font-weight: 700; }
.tool-contrast select { min-width: 0; max-width: 100%; }
.tool-out:not(:empty) { margin-top: 8px; padding: 8px 10px; border: var(--line); border-radius: 12px; background: var(--bg, #fff); }
.tool-title { font-weight: 700; }
.tool-big { font-size: 1.4rem; font-weight: 800; }
.sr-lines { margin: 0; padding-left: 1.4rem; font-size: .9rem; overflow-wrap: anywhere; }

/* Opastus, Näin pelaat ja Löysin bugin! */
.howto { background: #FFF3CC; border: 2px solid var(--ink); border-radius: 16px; padding: 12px 14px; margin-bottom: 16px; }
.howto h2 { font-size: 1.1rem; }
.howto ol { margin: 0 0 4px; padding-left: 1.3rem; }
.howto li { margin: .3rem 0; }
.coach { background: var(--paper); border: var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 18px; position: relative; }
/* Kapealla näytöllä automaatti on opastuksen alla, joten opastus pysyy ylhäällä näkyvissä (pelitestaus 2026-12-01). */
@media (max-width: 860px) { .coach { position: sticky; top: 0; z-index: 4; max-height: 45vh; overflow-y: auto; } }
.coach h2 { font-size: 1.05rem; margin: 0 0 2px; }
.coach-step { margin: 0 0 4px; }
.coach-text { font-weight: 600; }
.coach-note { background: #FFE1E7; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; }
.coach-inline { background: #FFF3CC; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; margin: 4px 0; }
.coach-target { outline: 4px dashed #B4235A; outline-offset: 4px; border-radius: 14px; animation: coach-pulse 1.6s ease-in-out infinite; }
@keyframes coach-pulse { 50% { outline-color: var(--focus); } }
.s-next { margin: 8px 2px 0; font-weight: 700; font-size: .92rem; }
.bug-row { margin-top: 16px; }
.bug-actions { display: flex; gap: 10px; align-items: stretch; }
.bug-note { margin: 6px 0 0; text-align: center; }
.bug-btn { flex: 1 1 auto; font-size: 1.2rem; padding: 12px 16px; background: #FFE066; min-height: 56px; }
.hint-btn { flex: 0 1 auto; font-size: .9rem; max-width: 45%; }
.sel-events { list-style: none; padding: 0; margin: 4px 0 0; max-height: 220px; overflow: auto; }
.sel-events li { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.sel-events input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.sel-events label { font-weight: 400 !important; margin: 0 !important; overflow-wrap: anywhere; cursor: pointer; }
.group-title { font-weight: 800; font-size: .85rem; margin: 6px 0 0; color: var(--muted); }
.report details { border: 2px solid var(--ink); border-radius: 12px; padding: 6px 12px; margin-top: 8px; }
.report details summary { font-weight: 700; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.report details[open] summary { margin-bottom: 4px; }
.report .extra { display: grid; gap: 4px; }
.dlg .report label.choice { font-weight: 400; margin-top: 6px; }
.choice { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 8px; margin: 6px 0; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.term { display: block; color: var(--muted); font-size: .85rem; }
.why { text-align: left; padding-left: 1.1rem; }
.result.left { text-align: left; }

/* Yläpalkin laskuri, ohje ja lopetus */
.hud { align-items: center; }
.hud-status, .hud-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip.counter { background: var(--mint-l); display: inline-flex; align-items: center; gap: 6px; }
.critters { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.counter .mini svg { width: 22px; height: auto; display: block; }
.help-btn { min-height: 36px; padding: 2px 12px; border-radius: 999px; }
@media (max-width: 600px) {
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .top .badge { grid-column: 2; grid-row: 1; justify-self: end; font-size: .75rem; padding: 4px 10px; }
  .top .logo { font-size: 1.15rem; white-space: nowrap; }
  .top .logo svg { width: 32px; height: 32px; }
  .top .hud { grid-column: 1 / -1; margin-left: 0; flex-direction: column; align-items: flex-start; }
  .hud .chip { font-size: .82rem; padding: 2px 9px; }
}
.quit { font-size: .9rem; min-height: 36px; padding: 2px 14px; border-radius: 999px; }
.hud-actions { padding-left: 10px; border-left: 2px solid #D9D2C5; }
@media (max-width: 600px) { .hud-actions { padding-left: 0; border-left: 0; } }
.h-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; }
.hints { padding-left: 1.1rem; margin: 10px 0 0; }
.hints:empty { display: none; }

/* Dialogit */
.dlg { border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--paper); color: var(--ink); }
.dlg::backdrop { background: rgba(43, 35, 64, .45); }
.report { display: grid; gap: 6px; }
.report label:not(.radio) { font-weight: 700; margin-top: 6px; }
.report fieldset { border: 2px solid var(--ink); border-radius: 12px; margin: 8px 0 0; padding: 8px 12px; }
.report legend { font-weight: 700; padding: 0 4px; }
.radio { display: inline-flex; align-items: center; gap: 4px; margin: 4px 14px 4px 0; min-height: 32px; cursor: pointer; }
.radio.block { display: flex; flex-wrap: wrap; }
.radio input { width: 20px; height: 20px; accent-color: var(--ink); }
.form-error { color: #A4133C; font-weight: 700; margin: 4px 0 0; min-height: 1em; }
.result { text-align: center; }
.big-critter svg { width: 150px; height: auto; }
.critter-name { font-weight: 800; font-size: 1.2rem; }
.points { display: inline-block; background: var(--sun); border: var(--line); border-radius: 999px; padding: 2px 12px; font-weight: 800; }
.points.neg { background: #FFE1E7; }
.result .btn-row { justify-content: center; }
.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }

/* Tulokset */
.results { margin-bottom: 24px; }
.big-score { font-size: 2.2rem; font-weight: 800; margin: 0 0 .4rem; }
.score-rows { padding-left: 1.1rem; }
.bug-list { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 16px; }
.bug-card { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 14px; align-items: start; }
.bug-card h3 { margin-top: 0; }
.bug-card.missed { background: #FBF7F0; }
.mid-critter svg { width: 90px; height: auto; }
@media (max-width: 480px) { .bug-card { grid-template-columns: minmax(0, 1fr); } .top { padding: 12px 16px; } .hud { margin-left: 0; } }

@media (prefers-reduced-motion: reduce) {
  .bob, .coach-target { animation: none; }
  .btn:hover:not(:disabled), .btn:active:not(:disabled) { transform: none; }
  .theory details.how > summary::before { transition: none; }
}

/* Julkaisupäätös ja Bugilan Sanomat */
.decision { margin-bottom: 24px; }
.dec-parts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.dec-parts dt { font-weight: 800; font-variant-numeric: tabular-nums; }
.dec-parts dd { margin: 0; }
.block { display: block; margin-top: 2px; }
.paper { background: #FFFDF7; border: var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 24px; }
.paper-lead { color: var(--muted); font-size: .9rem; }
.paper-name { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.6rem, 5vw, 2.3rem); text-align: center; border-top: 3px double var(--ink); border-bottom: 3px double var(--ink); padding: 6px 0; margin: 4px 0 12px; letter-spacing: .02em; }
.paper-heads { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.paper-heads li { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 1.15rem; line-height: 1.3; padding-bottom: 10px; border-bottom: 1px solid #CFC6B8; }
.paper-heads li:last-child { border-bottom: 0; padding-bottom: 0; }
@media (max-width: 480px) { .dec-parts { grid-template-columns: minmax(0, 1fr); } .dec-parts dd { margin-bottom: 6px; } }

/* Tutkija-taso: tutkimustehtävät ja yhteenveto */
.charters { background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 16px; }
.charters h2 { margin: 0 0 6px; font-size: 1.1rem; }
.charters fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.charters legend { font-size: .92rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.debrief dl { display: grid; grid-template-columns: minmax(10em, auto) 1fr; gap: 6px 14px; margin: 0; }
.debrief dt { font-weight: 800; }
.debrief dd { margin: 0; }
@media (max-width: 600px) { .debrief dl { grid-template-columns: 1fr; } .debrief dd { margin-bottom: 6px; } }

/* Kahvila Kaarnan puoti */
.shop { --bark: #8B5E3C; --bark-l: #F6EBDD; background: var(--bark-l); border: var(--line); border-radius: 18px; padding: 14px 16px 18px; box-shadow: var(--shadow); display: grid; gap: 8px; min-width: 0; }
.shop-sign { width: 80px; margin: -6px auto 0; }
.shop-sign svg { width: 100%; height: auto; display: block; }
.shop .m-title { margin-bottom: 2px; }
.shop-who { margin: 0; text-align: center; font-weight: 700; }
.shop-msg { margin: 0; background: #FFFDF8; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; min-height: 2.6em; }
.shop-body { display: grid; gap: 12px; }
.shop-body section { background: #FFFDF8; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.shop-body h3 { margin: 0 0 8px; font-size: 1rem; }
.prod-list, .cart-list, .co-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.prod { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; }
.prod-name { font-weight: 700; }
.prod-price { grid-column: 1; font-size: .88rem; color: var(--muted); }
.prod .btn { grid-column: 2; grid-row: 1 / span 2; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name line" "qty del"; gap: 4px 10px; align-items: center; padding-bottom: 6px; border-bottom: 1px dashed #D9D2C5; }
.cart-name { grid-area: name; font-weight: 700; }
.cart-line { grid-area: line; justify-self: end; font-variant-numeric: tabular-nums; }
.cart-row .qty-form { grid-area: qty; }
.cart-row .btn.link { grid-area: del; justify-self: end; }
.qty-form { display: flex; gap: 6px; align-items: center; }
.qty-form input { width: 3.5em; font: inherit; padding: 4px 6px; border: 2px solid var(--ink); border-radius: 8px; }
.cart-sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.cart-sum dd { margin: 0; text-align: right; }
.cart-sum .sum-total { font-weight: 800; font-size: 1.05rem; }
.code-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.code-form label { font-weight: 700; flex-basis: 100%; font-size: .9rem; }
.code-form input { flex: 1 1 8em; min-width: 0; font: inherit; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 10px; }
.shop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.shop-confirm { background: var(--mint-l) !important; }
.shop-confirm ul { margin: 0 0 6px; padding-left: 1.1rem; }
.offer-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: space-between; margin: 0 0 8px; }
.offer-banner { margin: 0; font-weight: 800; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; font-size: .88rem; }

/* Hissitorni */
.lift { background: #E6F2F7; border: var(--line); border-radius: 18px; padding: 14px 16px 18px; box-shadow: var(--shadow); display: grid; gap: 8px; min-width: 0; }
.lift-sign { width: 80px; margin: -6px auto 0; }
.lift-sign svg { width: 100%; height: auto; display: block; }
.lift .m-title { margin-bottom: 2px; }
.lift-display { margin: 0 auto; display: inline-flex; gap: 10px; align-items: center; justify-self: center; background: #1F2A36; color: #FFE08A; border: var(--line); border-radius: 12px; padding: 4px 16px; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 6.5rem; justify-content: center; }
.lift-state { margin: 0; text-align: center; font-weight: 800; }
.lift-alarm { margin: 0; text-align: center; font-weight: 800; background: #FFE1E7; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; }
.lift-msg { margin: 0; background: #FFFDF8; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; min-height: 2.6em; }
.lift-body { display: grid; grid-template-columns: minmax(7.5rem, 9rem) minmax(0, 1fr); gap: 10px; align-items: start; }
.tower { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tw-floor { border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; background: #FFFDF8; display: grid; gap: 2px; font-size: .85rem; min-height: 3.2em; }
.tw-floor.has-lift { background: #FFF3C4; }
.tw-num { font-weight: 800; }
.tw-lift { font-weight: 700; }
.tw-wait, .tw-call { color: var(--muted); }
.lift-controls { display: grid; gap: 10px; min-width: 0; }
.lift-controls section { background: #FFFDF8; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; display: grid; gap: 8px; }
.lift-controls h3 { margin: 0; font-size: 1rem; }
.floor-btns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.floor-btn { font-size: 1.1rem; padding: 6px 0; }
.floor-btn.lit { background: var(--sun); }
.floor-btn.here { outline: 3px dotted var(--ink); outline-offset: 1px; }
.help-call { background: #FFE1E7; }
.lift-load { margin: 0; font-weight: 700; }
.lift-actions { align-items: center; }
.obstacle { margin: 0; }
.lift-path { background: #FFFDF8; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; }
.lift-path h3 { margin: 0 0 4px; font-size: .95rem; }
.lift-path-list { margin: 0; padding-left: 1.4rem; font-size: .9rem; }
.riders { display: grid; gap: 8px; }
.riders select { font: inherit; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 10px; }
.riders .tcard { padding: 6px 10px; }
@media (max-width: 420px) { .lift-body { grid-template-columns: minmax(0, 1fr); } .tower { grid-template-columns: repeat(4, minmax(0, 1fr)); } .tw-floor { font-size: .75rem; } }
.car-note { margin: 0; font-size: .85rem; color: var(--muted); }
.time-note, .fetch-note { margin: 0; }
.riders .card-line { margin: 0; }
.card-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; justify-content: space-between; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; margin: 0; }

/* UX vaihe 1 (2026-11-29): aloitussuositus, aloituskortti, Seuraavaksi-vihje, kosketuskoot ja fokuksen peittyminen. */
.start-here { display: inline-block; margin-left: 8px; vertical-align: middle; font-size: .78rem; font-weight: 800; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; }
.level-intro p { margin: 0 0 10px; }
.s-next { background: var(--mint-l); border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; }
.s-next:empty { display: none; }
@media (max-width: 860px), (pointer: coarse) {
  /* Pelikuoren painikkeet vähintään 44 × 44 px. Testattavan sovelluksen omiin painikkeisiin ei kosketa. */
  .hud .btn.small, .toolbar .btn.small, .dlg .btn.small, .dlg .btn, .src-bar .btn { min-height: 44px; min-width: 44px; }
  .rgroup > summary, .fb summary, .report details summary { min-height: 44px; }
}
@media (max-width: 860px) {
  /* Kiinteä alapalkki ei saa peittää fokusta eikä viimeistä sisältöä (WCAG 2.4.11). */
  html:has(.src-bar) { scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
.emoji-row { display: flex; gap: 6px; margin: 4px 0 8px; }
.emoji-row .btn.emoji { min-width: 44px; min-height: 44px; font-size: 1.2rem; padding: 2px 6px; }

/* Tilisiirron merkkilaskuri (Tutkija) */
.tx-count { font-size: .85rem; font-weight: 700; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }

/* Tulossivun bugiosiot: otsikko irti edellisen kortin varjosta */
.bug-sec { margin-top: 32px; }
.bug-sec h2 { margin-bottom: 14px; }

/* Kaikki bugit löydetty (vain tasoilla, joilla bugien määrä näytetään) */
.chip.counter.all-found { background: var(--mint); font-weight: 800; }
.result .all-found { font-weight: 800; background: var(--mint-l); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; }

/* Katso käyttäjän silmin (docs/12) */
.persona-bar { margin: 0 0 10px; background: var(--paper); border: var(--line); border-radius: 16px; padding: 8px 10px; }
.persona-bar h2 { font-size: 1rem; margin: 0 0 2px; }
.persona-bar .small { margin: 0 0 6px; }
/* Tiivis palkki (Antti 2026-11-30): kaksi saraketta, jotta automaatin näyttö näkyy ilman vieritystä. */
.persona-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.persona-chip { display: inline-flex; align-items: center; gap: 4px; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 10px; min-height: 40px; background: #fff; cursor: pointer; font-weight: 700; font-size: .85rem; line-height: 1.2; }
.persona-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.persona-chip:has(input:checked) { background: var(--sun); }
.persona-chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.persona-info:empty { display: none; }
.persona-info { margin: 8px 0 0; background: var(--mint-l); border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; font-size: .9rem; }
/* Kuvitteellisen automaatin oma esitys */
.screen.pin-err { border-color: #E0263A; box-shadow: inset 0 0 0 3px #E0263A; }
.sim-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.receipt.faded p { color: #B7AFA3; }
/* Pikku Orava: värit kuten punavihersokea näkee */
.machine[data-persona="orava"] { filter: url(#cb-filter); }
/* Mummo Mäyrä: puhekupla */
.sr-bubble { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; font-size: .85rem; max-height: 220px; overflow: auto; }
.sr-bubble-t { margin: 0 0 4px; font-weight: 800; }
.sr-bubble ol { margin: 0; padding-left: 1.4rem; }
.sr-bubble li.odd { color: #B00020; font-weight: 800; }
/* Professori Pöllö: Tab-järjestyksen numerot */
.machine [data-tab] { position: relative; }
.machine [data-tab]::after { content: attr(data-tab); position: absolute; top: -10px; right: -8px; background: var(--ink); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; font-size: .75rem; font-weight: 800; display: grid; place-items: center; padding: 0 4px; z-index: 2; }
/* Herra Siili: erottuvuusmerkit */
.machine[data-persona="siili"] .screen, .machine[data-persona="siili"] .opts, .machine[data-persona="siili"] .s-next, .machine[data-persona="siili"] .receipt { position: relative; }
.cr-badge { display: inline-block; margin-top: 6px; font-family: inherit; font-size: .75rem; font-weight: 800; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px; background: #fff; }
.cr-badge.ok { background: #DFF7EA; }
.cr-badge.bad { background: #FFD6DC; }
.machine.is-active .screen { border-color: #2E9E4F; }
.machine.is-active .screen.pin-err { border-color: #E0263A; }
.cb-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
/* Kokeilu: ruudunlukijan laatikko erottuu automaatin näytöstä (tumma, kuulokkeet) */
.sr-bubble { background: #2B2340; color: #F4F0FF; border-color: #2B2340; border-style: dashed; font-family: ui-monospace, Menlo, Consolas, monospace; }
.sr-bubble-t { color: #FFD166; font-family: system-ui, sans-serif; }
.sr-bubble ol.heard li { opacity: .6; }
.sr-bubble ol.heard li.newest { opacity: 1; font-weight: 700; }
/* Kokeilu: heikkonäköinen näkee automaatin sumeana ja haaleana (ei lukemia) */
.machine[data-persona="siili"] { filter: blur(1.6px) contrast(.45) brightness(1.15); }

/* Nostosumma näytöllä: näyttää näytön tekstiltä, mutta siihen voi myös kirjoittaa (B21:n reitti puhelimella) */
.s-amount { font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 2px dotted transparent; width: 4.2ch; padding: 0; text-align: right; }
.s-amount:focus { outline: none; border-bottom-color: var(--ink); }
.s-amount:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Äänipainike yläpalkissa */
.sound-btn.on { background: var(--mint-l); }

/* Tietoa-sivu (tietoa.html) */
.info-page { max-width: 760px; }
.info-page .card { margin-bottom: 16px; }
.info-page h3 { margin: 1.2rem 0 .3rem; font-size: 1.05rem; }
a.logo { color: inherit; text-decoration: none; }

/* Testaustekniikoiden avattava osio tulossivulla (2026-12-01) */
.theory details.how { margin: 4px 0 8px; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 12px; background: var(--paper); }
.theory details.how > summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
.theory details.how > summary::-webkit-details-marker { display: none; }
.theory details.how > summary::before { content: "▶"; font-size: .8rem; transition: transform .15s; }
.theory details.how[open] > summary::before { transform: rotate(90deg); }
.theory details.how ol { margin: 4px 0 8px; padding-left: 1.3rem; }
.theory details.how li { margin-bottom: 4px; }
.bug-card:focus { outline: 4px solid var(--focus); outline-offset: 4px; }
.theory .tech:focus { outline: 4px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
