/* Spore Grid: a daylight cloud garden. All pieces and marks are live game state. */
*{box-sizing:border-box}
body{margin:0;background:#77c5f2;color:#512806;font-family:"Arial",system-ui,sans-serif}
main{max-width:none;margin:0;padding:0}
.sg-scene{--u:min(1.15px,calc(100vw / 390),calc(100svh / 810));position:relative;width:calc(390 * var(--u));height:calc(810 * var(--u));margin:auto;isolation:isolate;background:#64baf5 url('../assets/play/sporegrid/cloud-garden.webp') center/100% 100% no-repeat;box-shadow:0 0 80px #fff8}
h1#sg-title{position:absolute;top:calc(7 * var(--u));left:calc(46 * var(--u));width:calc(298 * var(--u));margin:0;line-height:0;filter:drop-shadow(0 4px 2px #6a592244)}
#sg-title img{display:block;width:100%;height:auto}
.hud{position:absolute;top:calc(126 * var(--u));left:calc(20 * var(--u));width:calc(350 * var(--u));display:grid;grid-template-columns:1fr 1fr;gap:calc(6 * var(--u));font-size:calc(12 * var(--u));font-weight:900}
.hud>div{background:linear-gradient(#fff9e7,#f4dfb7);border:calc(2 * var(--u)) solid #fff8e3;border-radius:calc(20 * var(--u));box-shadow:inset 0 -3px 2px #cba879,0 3px 3px #76532755;display:flex;align-items:center;justify-content:center}
.hud .score{height:calc(48 * var(--u));gap:calc(5 * var(--u));padding:calc(3 * var(--u)) calc(8 * var(--u)) calc(5 * var(--u))}
.score>span:not(.dot){font-size:calc(13 * var(--u));text-transform:uppercase;letter-spacing:-.4px;line-height:1.05}
.hud b{font-variant-numeric:tabular-nums;font-weight:900;color:#542609;font-size:calc(27 * var(--u))}
.hud .counter{height:calc(27 * var(--u));font-size:calc(10 * var(--u));gap:calc(8 * var(--u));white-space:nowrap}
.counter b{font-size:calc(15 * var(--u))}
.dot{display:inline-block;flex-shrink:0;background:center/contain no-repeat;width:calc(36 * var(--u));height:calc(36 * var(--u));background-image:url('../assets/play/sporegrid/spore-gold.webp')}
.cpu-score .dot,.who.cpu .dot{background-image:url('../assets/play/sporegrid/spore-violet.webp')}
.turn-plaque{position:absolute;z-index:2;top:calc(217 * var(--u));left:calc(69 * var(--u));width:calc(252 * var(--u));height:calc(40 * var(--u));display:flex;align-items:center;justify-content:center;text-align:center;background:linear-gradient(#fff9e8,#f0d6a6);border:calc(3 * var(--u)) solid #fff5d7;box-shadow:inset 0 -3px 2px #cfb17a,0 4px 3px #74471b55;border-radius:calc(18 * var(--u));font-size:calc(19 * var(--u));font-weight:900;text-transform:uppercase;letter-spacing:calc(.2 * var(--u))}
.stage{touch-action:none;position:absolute;top:calc(249 * var(--u));left:calc(9 * var(--u));width:calc(372 * var(--u));height:calc(372 * var(--u));background:url('../assets/play/sporegrid/board-frame.webp') center/100% 100% no-repeat;filter:drop-shadow(0 6px 4px #5b492c66)}
#sg-grid{position:absolute;inset:6.8%;display:grid;grid-template-columns:repeat(7,minmax(0,1fr));grid-template-rows:repeat(7,minmax(0,1fr));gap:calc(1 * var(--u));background:#f7e3b9;touch-action:none;border-radius:calc(7 * var(--u));padding:0}
button{font:inherit;cursor:pointer;color:#542609;min-height:44px}
#sg-grid .cell{position:relative;min-width:0;min-height:0;padding:0;border:0;border-radius:calc(6 * var(--u));background:#e6b46d url('../assets/play/sporegrid/soil-cell.webp') center/100% 100%;display:flex;align-items:center;justify-content:center;touch-action:none;isolation:isolate}
.cell:disabled{opacity:1;cursor:default}
.cell .sp{position:absolute;width:100%;height:110%;bottom:1%;background:center/contain no-repeat;pointer-events:none;transform:scale(0);filter:drop-shadow(0 2px 1px #61341066);z-index:1}
.cell.you .sp{transform:none;background-image:url('../assets/play/sporegrid/spore-gold.webp')}
.cell.cpu .sp{transform:none;background-image:url('../assets/play/sporegrid/spore-violet.webp')}
.cell.stone .sp{transform:none;background-image:url('../assets/play/sporegrid/stones.webp')}
.cell .gain{position:relative;z-index:2;font:900 calc(16 * var(--u)) ui-rounded,"Trebuchet MS",sans-serif;color:#60300b;pointer-events:none}
.cell.clone::before{content:"";position:absolute;inset:calc(2 * var(--u));border-radius:inherit;background:#fff0ae;box-shadow:inset 0 2px 5px #fff,0 0 7px #ffec7b}
.cell.jump::before{content:"";position:absolute;inset:calc(3 * var(--u));border:calc(2 * var(--u)) dashed #6e4113;border-radius:inherit;background:#fff2c260}
.cell.can{box-shadow:inset 0 0 0 1px #fff0ab}
.cell.sel{z-index:2;box-shadow:inset 0 0 0 3px #fff9da,0 0 0 2px #ffc900,0 0 10px #fff}
.cell.last{box-shadow:inset 0 0 0 2px #9d56c3}
.cell.cur{outline:calc(2 * var(--u)) solid #ffcf14;outline-offset:-3px}
button:focus-visible,a:focus-visible{outline:3px solid #602da8;outline-offset:3px;z-index:3}
.scene-controls{position:absolute;top:calc(635 * var(--u));left:calc(15 * var(--u));width:calc(360 * var(--u));display:grid;grid-template-columns:1fr 1fr;gap:calc(8 * var(--u))}
.actions,.toolbar{display:contents}
.scene-controls button,#sg-over-btn{height:calc(55 * var(--u));padding:0 calc(10 * var(--u));border:0;border-radius:calc(26 * var(--u));background:transparent url('../assets/play/sporegrid/button-yellow.webp') center/100% 100% no-repeat;box-shadow:0 4px 3px #62481744;font-weight:900;font-size:calc(19 * var(--u));text-transform:uppercase;line-height:1.05;letter-spacing:calc(.2 * var(--u))}
#sg-new,.scene-controls .egm-juice-mute{background-image:url('../assets/play/sporegrid/button-cream.webp')}
.scene-controls button:disabled{color:#866735;filter:saturate(.65);cursor:default}
.scene-controls button:active:not(:disabled),#sg-over-btn:active{transform:translateY(2px)}
.scene-controls .egm-juice-mute{grid-column:1/-1;justify-self:center;width:calc(130 * var(--u));height:calc(36 * var(--u));min-height:44px;font-size:calc(13 * var(--u));text-transform:none}
.turn-notes{position:absolute;top:calc(737 * var(--u));left:calc(20 * var(--u));right:calc(20 * var(--u));display:flex;justify-content:space-between;gap:5px;font-size:calc(9 * var(--u));color:#4f2a0c}
.who{display:flex;align-items:center;gap:calc(3 * var(--u));white-space:nowrap}
.who .dot{width:calc(16 * var(--u));height:calc(16 * var(--u))}.who .note{font-weight:800}.who>span:not(.dot):not(.note){display:none}
#sg-status{position:absolute;top:calc(759 * var(--u));left:calc(15 * var(--u));width:calc(360 * var(--u));min-height:calc(45 * var(--u));margin:0;padding:calc(5 * var(--u)) calc(10 * var(--u));border-radius:calc(12 * var(--u));color:#4d2b13;background:#fff8e6ed;box-shadow:0 2px 3px #725a3444;font-size:calc(12 * var(--u));line-height:1.25;font-weight:700}
#sg-over{position:absolute;inset:5%;z-index:5;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:calc(14 * var(--u));padding:calc(20 * var(--u));border:calc(3 * var(--u)) solid #fff7db;border-radius:calc(25 * var(--u));background:#fff1d4f5;box-shadow:0 6px 15px #60431855;text-align:center}
#sg-over[hidden]{display:none}
#sg-over::before{content:"";width:calc(105 * var(--u));height:calc(105 * var(--u));background:url('../assets/play/sporegrid/spore-gold.webp') center/contain no-repeat;filter:drop-shadow(0 4px 3px #67422355)}
[data-result="loss"] #sg-over::before{background-image:url('../assets/play/sporegrid/spore-violet.webp')}
[data-result="loss"] #sg-over{border-color:#e4c6f0;background:#f4eaf6f5}
[data-result="draw"] #sg-over::before{background-image:url('../assets/play/sporegrid/spore-gold.webp'),url('../assets/play/sporegrid/spore-violet.webp');background-size:65% auto;background-position:left center,right center}
#sg-over p{font-weight:900;font-size:calc(26 * var(--u));line-height:1.15;margin:0;color:#542609}
#sg-over .sub{font-size:calc(15 * var(--u));font-weight:700}
#sg-over-btn{width:calc(180 * var(--u));font-size:calc(19 * var(--u))}
.sg-help{max-width:780px;margin:30px auto 0;padding:24px;background:#fff8e9;border:1px solid #f0dfc4;border-radius:22px;color:#51361f;box-shadow:0 7px 25px #5c583522;font-size:15px;line-height:1.6}
.sg-help h2{font-family:inherit;font-size:22px;color:#633712;margin:20px 0 10px}.sg-help p{margin:0 0 12px}.legend{padding-left:22px}.legend li{margin:8px 0}
header{max-width:780px;margin:16px auto;padding:12px 20px;text-align:center;font-size:14px;color:#3a381c}header a{color:#3d2b14;font-weight:700;text-decoration:underline}
@media(min-width:650px){body{background:radial-gradient(ellipse at 50% 25%,#d5f1ff,#82ccf3 65%,#5db3e8);background-attachment:fixed}.sg-scene{border-left:1px solid #fff9;border-right:1px solid #fff9}}
@media(max-width:650px){.sg-help{margin:20px 10px 0;padding:18px}}
@media(prefers-reduced-motion:reduce){.sg-scene *{animation:none!important;transition:none!important}}

/* Chunky lettering follows the reference without baking live text into art. */
.turn-plaque,.scene-controls button,.hud b,#sg-over p{font-family:"Arial Black","Arial",sans-serif}

/* The carved plaque is cut from the same mockup as the ceramic board. */
.turn-plaque{background:transparent url('../assets/play/sporegrid/turn-plaque.webp') center/100% 100% no-repeat;border:0;box-shadow:none;filter:drop-shadow(0 3px 2px #74471b66);font-size:calc(18 * var(--u));padding:0 calc(28 * var(--u))}
.cell.stone .sp{filter:saturate(.55) contrast(1.08) drop-shadow(0 2px 1px #61341066)}
#sg-status{font-family:Arial,sans-serif}
.sg-help{font-family:Arial,sans-serif}
.turn-notes{top:calc(743 * var(--u));font-size:calc(10 * var(--u))}

/* Final comparison: leave room between the carved leaves and variable turn labels. */
.turn-plaque{left:calc(55 * var(--u));width:calc(280 * var(--u));padding:0 calc(37 * var(--u));white-space:nowrap}
.sg-scene:has(#sg-cpu-turn:not(:empty)) .turn-plaque{font-size:calc(14 * var(--u))}
