*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{margin:0;min-height:100%;overscroll-behavior-y:none}
body.pf-shell{font-family:'DM Sans',system-ui,sans-serif}
main{min-height:100svh;max-width:1100px;margin:auto;padding:28px 24px;display:flex;flex-direction:column;justify-content:center}
#toolbar{display:flex;align-items:center;gap:12px;width:100%;margin:0 auto 36px}
#toolbar nav{display:flex;gap:8px;margin-left:auto}
.pf-shell #toolbar nav{flex:0 0 auto;margin-left:auto;justify-content:flex-end}
.pf-shell #toolbar #languages{margin-left:0;flex:0 0 auto}
#toolbar .btn{min-height:32px;font-size:.8rem}
#toolbar #start{min-width:104px;min-height:36px}
#preparation{width:100%;max-width:720px;margin:auto}
.pf-shell #instructions{padding:30px 34px}
h1{font-size:1.3rem;font-weight:600;margin:0 0 20px}
p{line-height:1.65;font-size:.94rem;margin:0 0 18px}
p:last-child{margin-bottom:0}
.ready-hint{color:var(--pf-muted);font-size:.85rem}
#researcher{margin:22px 0 0;color:var(--pf-muted);font-size:.85rem}
#researcher summary{cursor:pointer;width:fit-content}
#researcherContent{overflow:hidden;padding-top:14px}
#researcher p{font-size:.85rem}
.saved-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--pf-border);flex-wrap:wrap}
.saved-actions{display:flex;gap:8px}
.saved-actions .btn,#clearAll{font-size:.8rem;min-height:32px}
#clearAll{margin-top:14px}
body.active{background:#F0F0F0;color:#303030}
body.active main{height:100svh;min-height:0;max-width:none;padding:24px;gap:28px}
body.active #toolbar{display:none}
#test{display:flex;align-items:center;justify-content:center;flex:1;min-height:0}
#board{display:grid;grid-template-columns:repeat(4,1fr);grid-template-rows:repeat(2,auto);gap:clamp(18px,3vw,40px);width:min(100%,1000px,calc((100svh - 60px)*1.333333));height:auto}
.colour-card{appearance:none;border:0;border-radius:12px;aspect-ratio:2/3;width:100%;display:block;min-width:0;min-height:0;padding:0;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:opacity .3s ease,transform .3s ease;box-shadow:none}
.colour-card:focus-visible{outline:2px solid #fff;outline-offset:5px}
.colour-card.selected{opacity:0;transform:scale(.98);pointer-events:none}
.colour-card.gone{visibility:hidden}
.colour-card:disabled{cursor:default}
#complete{width:100%;max-width:640px;margin:auto}
body.completed #toolbar{max-width:640px;margin:0 auto 18px}
body.completed #toolbar nav{margin-left:0;justify-content:flex-start}
body.completed #toolbar #languages{margin-left:auto}
body.completed #complete{margin:0 auto}
#qr,#savedQrCode{width:min(240px,100%,calc(100svh - 310px));margin:20px auto;background:white;padding:10px;border:1px solid var(--pf-border);border-radius:6px}
#qr img,#qr canvas,#savedQrCode img,#savedQrCode canvas{display:block;width:100%;height:auto}
#notice{font-size:.85rem;color:var(--pf-muted);margin:18px auto 0;max-width:720px}
dialog{border:1px solid var(--pf-border);border-radius:6px;padding:24px;max-width:calc(100vw - 32px);color:#374151;background:#fff}
dialog::backdrop{background:#20213366}
dialog h2{font-size:1.1rem;margin:0 0 12px}
dialog p{font-size:.9rem;margin-bottom:24px}
.actions{display:flex;justify-content:flex-end;gap:12px}
.actions .btn{min-width:104px}
#savedQr{padding:20px;width:284px;position:relative}
#savedQrCode{width:min(240px,100%,calc(100svh - 100px));margin:0 auto;border:0}
#closeQr{position:absolute;right:7px;top:3px;padding:0 5px;border:0;background:none;font-size:24px;color:var(--pf-muted);cursor:pointer}
#qrError{font-size:.85rem}
@media(max-width:600px){
 main{padding:20px 16px}
 #toolbar{gap:8px;margin-bottom:28px;flex-wrap:nowrap}
 #toolbar .btn{font-size:.75rem;padding:0 9px}
 #toolbar #start{min-width:80px;min-height:32px}
 #toolbar nav{gap:6px}
 .pf-shell #instructions{padding:24px 20px}
 h1{font-size:1.15rem}
 #languages button{padding:4px 8px}
 body.active main{padding:18px 22px;gap:24px}
 #board{grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(4,auto);width:min(100%,420px,calc((100svh - 56px)/3));height:auto;gap:18px}
 #complete{padding:24px 16px}
 #qr{width:min(240px,100%,calc(100svh - 290px))}
}
@media(max-height:500px) and (orientation:landscape){body.active main{padding:12px 24px;gap:14px}#board{grid-template-columns:repeat(4,1fr);grid-template-rows:repeat(2,auto);width:min(100%,1000px,calc((100svh - 48px)*1.333333));height:auto;gap:18px}#complete{padding:18px}#qr{width:min(240px,100%,calc(100svh - 190px));margin:10px auto}}
@media(prefers-reduced-motion:reduce){.colour-card{transition:none}}
@media(max-height:500px) and (orientation:landscape){
 main{padding:12px 20px}
 #toolbar{margin-bottom:12px}
 #complete{display:grid;grid-template-columns:minmax(0,1fr) 180px;gap:12px;align-items:center;padding:18px}
 #complete h1,#complete>p,#complete>#retry{grid-column:1;margin:0}
 #complete>p{font-size:.85rem}
 #complete #qr{grid-column:2;grid-row:1/span 4;width:180px;margin:0}
}
