/* Game surface and game-specific controls only. */
:root{--cube-size:clamp(174px,56cqw,280px);--cube-count:3;--cubie-size:calc(var(--cube-size)/var(--cube-count));--half-cubie:calc(var(--cubie-size)/2);}
[role=button]{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;touch-action:manipulation}
img,canvas{user-select:none;-webkit-user-select:none;-webkit-user-drag:none}
.turn-arrow:focus-visible,.face-turn-button:focus-visible,.joystick-base:focus-visible{outline:3px solid #fff1b8;outline-offset:2px}
.premium-stage{position:relative;isolation:isolate;overflow:hidden;--picture-stage-min:585px;--picture-view-height:clamp(440px,70cqw,500px);min-height:var(--picture-stage-min);border:0;border-radius:0;padding:6px 10px 12px;background:transparent;box-shadow:none}
.stage-glow{display:none;position:absolute;z-index:-1;width:240px;height:240px;border-radius:50%;filter:blur(50px);opacity:.2}
.stage-glow-left{left:-130px;top:27%;background:#d7a73f}
.stage-glow-right{right:-130px;top:12%;background:#4d76cb}
.start-game-button{position:absolute;z-index:8;top:12px;left:50%;min-width:160px;transform:translateX(-50%)}
.cube-viewport{--cube-center-y:34%;position:relative;height:var(--picture-view-height);margin-top:0;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;overscroll-behavior:contain;perspective:950px}
.turn-canvas{position:absolute;z-index:2;inset:0;display:none;width:100%;height:100%;pointer-events:none;filter:drop-shadow(0 14px 15px #0009) drop-shadow(0 0 9px #ffe29a33)}
.turn-canvas.active{display:block}
.cube-scene{position:absolute;left:50%;top:var(--cube-center-y);width:0;height:0;transform-style:preserve-3d}
.cube{position:absolute;width:0;height:0;transform-style:preserve-3d;transform:rotateX(var(--view-x,-25deg)) rotateY(var(--view-y,-36deg));transition:filter .2s}
.cube.busy{filter:drop-shadow(0 0 13px #ffe29a66)}
.cubie-orbit{position:absolute;left:0;top:0;width:0;height:0;transform-style:preserve-3d;-webkit-transform-style:preserve-3d}
.cubie{position:absolute;left:calc(var(--cubie-size)/-2);top:calc(var(--cubie-size)/-2);width:var(--cubie-size);height:var(--cubie-size);pointer-events:none;transform-style:preserve-3d;-webkit-transform-style:preserve-3d;will-change:transform}
.cubie-face{position:absolute;inset:1px;display:block;border:1px solid #020305;border-radius:clamp(5px,1.5cqw,10px);background:linear-gradient(145deg,#20242d,#080a0e 72%);box-shadow:inset 0 0 0 2px #000,inset 0 1px 2px #ffffff20;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}
.cubie-face::after{content:"";position:absolute;inset:6%;border-radius:clamp(4px,1.2cqw,8px);background:var(--sticker,#11151e);box-shadow:inset 0 1px 2px #fff8,inset 0 -5px 10px #0005,0 0 0 1px #0009;transition:filter .15s}
.face-front{transform:rotateY(0deg) translateZ(var(--half-cubie))}
.face-back{transform:rotateY(180deg) translateZ(var(--half-cubie))}
.face-right{transform:rotateY(90deg) translateZ(var(--half-cubie))}
.face-left{transform:rotateY(-90deg) translateZ(var(--half-cubie))}
.face-top{transform:rotateX(90deg) translateZ(var(--half-cubie))}
.face-bottom{transform:rotateX(-90deg) translateZ(var(--half-cubie))}
.sticker-white{--sticker:linear-gradient(145deg,#fff,#d9dbe0)}
.sticker-yellow{--sticker:linear-gradient(145deg,#ffe970,#e9af00)}
.sticker-orange{--sticker:linear-gradient(145deg,#ffad38,#e25a08)}
.sticker-red{--sticker:linear-gradient(145deg,#ff5b51,#b60918)}
.sticker-green{--sticker:linear-gradient(145deg,#50dd91,#078c52)}
.sticker-blue{--sticker:linear-gradient(145deg,#58bfff,#1457c7)}
.touch-controller{position:absolute;z-index:6;right:8px;bottom:5px;left:8px;display:flex;align-items:flex-end;justify-content:space-between;gap:16px;pointer-events:none}
.layer-control,.joystick-control{pointer-events:auto}
.layer-control{display:grid;width:174px;grid-template-columns:1fr auto;align-items:center;gap:2px 8px;border:1px solid #6f592b;border-radius:16px;padding:8px;background:#070a10e8;box-shadow:0 10px 28px #000b,inset 0 1px #fff1;backdrop-filter:blur(8px)}
.selected-face-label{color:#a99e89;font-size:8px;font-weight:900;letter-spacing:.11em;text-transform:uppercase}
.selected-face-value{display:grid;width:27px;height:27px;grid-row:1;grid-column:2;place-items:center;border:1px solid #80662f;border-radius:50%;color:var(--gold-light);font:normal 17px Georgia,serif}
.arrow-pad{position:relative;display:grid;height:96px;grid-column:1/-1;grid-template:repeat(3,1fr)/repeat(3,1fr);gap:3px}
.turn-arrow,.face-turn-button{display:grid;min-width:0;place-items:center;border:1px solid #77622f;border-radius:10px;background:linear-gradient(145deg,#1a2230,#080b11);box-shadow:inset 0 1px #fff1;color:#ffe5a0;font-size:18px;touch-action:none}
.turn-arrow:active,.face-turn-button:active{transform:scale(.92);background:linear-gradient(145deg,#a77c2c,#e4c878)}
.turn-arrow:disabled,.face-turn-button:disabled{opacity:.28}
.turn-arrow.hint-pulse,.face-turn-button.hint-pulse,.secondary-button.hint-pulse{animation:hint-pulse .7s ease-in-out 3}
.turn-up{grid-area:1/2}
.turn-left{grid-area:2/1}
.arrow-centre{display:grid;grid-area:2/2;place-items:center;color:#79642e}
.turn-right{grid-area:2/3}
.turn-down{grid-area:3/2}
.face-turn-row{display:grid;height:34px;grid-column:1/-1;grid-template-columns:42px 1fr 42px;align-items:center;gap:5px;margin-top:4px}
.face-turn-row span{text-align:center;color:#9e927c;font-size:7px;font-weight:900;letter-spacing:.11em;text-transform:uppercase}
.face-turn-button{height:34px;font-size:20px}
.joystick-control{display:grid;justify-items:center;gap:5px;color:#b5aa94;font-size:8px;font-weight:900;letter-spacing:.12em;text-transform:uppercase}
.joystick-base{position:relative;width:112px;height:112px;border:1px solid #9b7d3b;border-radius:50%;background:radial-gradient(circle,#202a3c 0 16%,#111722 17% 52%,#080b11 53%);box-shadow:inset 0 0 22px #000,0 10px 28px #000b;touch-action:none}
.joystick-base::before,.joystick-base::after{content:"";position:absolute;background:#8b743c55}
.joystick-base::before{left:15%;right:15%;top:50%;height:1px}
.joystick-base::after{top:15%;bottom:15%;left:50%;width:1px}
.joystick-knob{position:absolute;z-index:2;left:50%;top:50%;width:46px;height:46px;border:1px solid #f3d98f;border-radius:50%;background:radial-gradient(circle at 34% 28%,#fff1b1,#c69a3f 45%,#5c3d14 100%);box-shadow:inset 0 2px #fff9,0 6px 13px #000b;transform:translate(-50%,-50%);will-change:transform}
.move-console{position:relative;z-index:3;width:min(100%,600px);margin:4px auto 0}
.assist-row{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.assist-row .secondary-button{min-height:38px;padding:8px;font-size:11px}
@keyframes hint-pulse{50%{border-color:#fff0b0;background:#b88a32;color:#090806;box-shadow:0 0 18px #ffd96d}}
.play-secondary-ad{display:grid;min-height:90px;place-items:center;margin-top:16px;border:1px dashed #615332;border-radius:14px;background:#080b11aa;color:#837a69;font-size:10px;font-weight:800;letter-spacing:.14em;text-transform:uppercase}
.result-cube{margin:10px auto;color:#f0c75c;font-size:54px;text-shadow:0 0 22px #f0c75c}
@container gf-page (max-width:520px) {:root{--cube-size:clamp(172px,56cqw,228px);}
.premium-stage{--picture-stage-min:550px;--picture-view-height:525px;padding-inline:6px}
.cube-viewport{--cube-center-y:35%}
.layer-control{width:152px}
.joystick-base{width:96px;height:96px}
.joystick-knob{width:42px;height:42px}}
@container gf-page (min-width:700px) {.premium-stage{--picture-stage-min:700px;--picture-view-height:530px}
.cube-viewport{height:var(--picture-view-height)}
:root{--cube-size:300px;}}
@media (min-height:850px) {@container gf-page (min-width:650px) and (max-width:1100px) and (min-width:0px) {:root{--cube-size:clamp(370px,52cqw,430px);}
.premium-stage{--picture-stage-min:max(790px,calc(100svh - 234px));--picture-view-height:max(765px,calc(100svh - 259px));padding-inline:12px}
.cube-viewport{--cube-center-y:34%;height:var(--picture-view-height)}
.touch-controller{bottom:12px;width:min(calc(100% - 34px),700px);grid-template-columns:minmax(205px,230px) minmax(140px,1fr) 140px;gap:14px}
.layer-control{padding:10px}
.arrow-pad{height:112px;gap:5px}
.face-turn-row{height:40px;grid-template-columns:50px 1fr 50px}
.face-turn-button{height:40px}
.joystick-base{width:132px;height:132px}
.joystick-knob{width:52px;height:52px}
.controller-action{min-height:48px;font-size:14px}}}
@media (max-height:700px) {@container gf-page (min-width:100000px) {.premium-stage{min-height:505px}
.cube-viewport{--cube-center-y:39%;height:395px}
.touch-controller{right:5px;left:auto;width:330px}
.layer-control{width:150px}
.joystick-base{width:96px;height:96px}
.move-console{width:420px}}}
.touch-controller{right:auto;bottom:5px;left:50%;display:grid;width:min(calc(100% - 16px),520px);grid-template-columns:minmax(166px,174px) minmax(90px,1fr) 112px;align-items:end;justify-content:normal;gap:10px;transform:translateX(-50%)}
.layer-control{width:100%}
.view-control-stack{display:grid;align-self:end;gap:8px;pointer-events:none}
.controller-action{width:100%;min-height:40px;padding:7px 6px;text-align:center;font-size:12px;line-height:1.15;pointer-events:auto;touch-action:manipulation}
.controller-undo{align-self:end}
.view-control-stack .joystick-control,.view-control-stack .controller-action{pointer-events:auto}
@container gf-page (max-width:520px) {.touch-controller{width:calc(100% - 8px);grid-template-columns:152px minmax(82px,1fr) 96px;gap:6px}
.layer-control{width:100%}
.controller-action{min-height:40px;padding-inline:4px;font-size:11px}}
@media (max-height:700px) {@container gf-page (min-width:100000px) {.touch-controller{right:auto;left:50%;width:min(calc(100% - 10px),430px);grid-template-columns:150px minmax(90px,1fr) 96px;transform:translateX(-50%)}}}
.preview-capture .play-secondary-ad{display:none}
@media (min-height:850px) {@container gf-page (min-width:650px) and (max-width:1100px) and (min-width:0px) {.touch-controller{bottom:12px;width:min(calc(100% - 34px),700px);grid-template-columns:minmax(205px,230px) minmax(140px,1fr) 140px;gap:14px}
.controller-action{min-height:48px;font-size:14px}}}
.layer-control{display:block}
.arrow-pad{grid-column:auto}
.cube-position-note{position:absolute;z-index:8;width:max-content;max-width:min(250px,calc(100% - 16px));border:1px solid #b99a51;border-radius:12px;padding:10px 12px;background:#10151f;color:#f5e5bd;box-shadow:0 5px 18px #0009;font-size:13px;line-height:1.4;text-align:center;pointer-events:none}
.assist-control-stack{display:grid;align-self:end;gap:8px;pointer-events:none}
.assist-control-stack .controller-action{pointer-events:auto}
.face-metal-star{position:absolute;z-index:5;pointer-events:none;user-select:none;transform-origin:center}
.face-metal-star:before{content:"";position:absolute;inset:0;background:linear-gradient(135deg,#fff9 0%,transparent 34%,#0003 75%,#fff9 100%);pointer-events:none}
.face-star-glint{position:absolute;inset:-10% -25%;pointer-events:none;background:linear-gradient(105deg,transparent 27%,#fff4 39%,#ffffed 48%,#fff8 53%,transparent 66%);mix-blend-mode:screen}
.cube-victory-stars{position:absolute;z-index:9;inset:0;overflow:hidden;border-radius:inherit;pointer-events:none}
.cube-gold-star{filter:drop-shadow(0 0 2px #ffe58c77)}
.turn-canvas{filter:drop-shadow(0 12px 12px #0008)}
.demo-tap-target{position:absolute;z-index:5;width:30px;height:30px;border:0;border-radius:50%;pointer-events:none;transform:translate(-50%,-50%)}
.demo-control-focus{border-color:#fff0b0!important;background:linear-gradient(145deg,#a77c2c,#e4c878)!important;box-shadow:0 0 18px #ffd96d!important;color:#090806!important}
body.demo-running .premium-stage{pointer-events:none}
body.demo-running .turn-canvas{filter:drop-shadow(0 14px 15px #0009) drop-shadow(0 0 9px #ffe29a33)}

/* Keep every control inside the viewport instead of overflowing a fixed third column. */
.touch-controller{left:50%;right:auto;bottom:8px;width:min(calc(100% - 16px),520px);min-width:0;transform:translateX(-50%);grid-template-columns:minmax(154px,1.35fr) minmax(88px,1fr);grid-template-areas:"turn view" "assist view";gap:8px;align-items:end}
.layer-control{grid-area:turn;display:grid;grid-template:repeat(2,44px)/repeat(3,minmax(0,1fr));gap:3px;width:100%;min-width:0;padding:8px}
.layer-control .arrow-pad,.layer-control .face-turn-row{display:contents}
.layer-control .arrow-centre,.layer-control .face-turn-row>span{display:none}
.layer-control .turn-up{grid-area:1/2}.layer-control .turn-left{grid-area:2/1}.layer-control .turn-down{grid-area:2/2}.layer-control .turn-right{grid-area:2/3}
.layer-control [data-cubie-spin="-1"]{grid-area:1/1}.layer-control [data-cubie-spin="1"]{grid-area:1/3}
.layer-control .turn-arrow,.layer-control .face-turn-button{width:100%;height:44px;min-width:0;min-height:44px;padding:0}
.assist-control-stack{grid-area:assist;grid-template-columns:repeat(2,minmax(0,1fr));min-width:0;gap:6px}
.view-control-stack{grid-area:view;min-width:0;width:100%;max-width:180px;justify-self:end}
.touch-controller .controller-action{min-width:0;min-height:44px;margin:0;padding:6px 4px;white-space:normal;overflow-wrap:anywhere}
.view-control-stack .joystick-control{width:100%;min-width:0}
.view-control-stack .joystick-base{width:min(100%,112px);height:auto;aspect-ratio:1;min-width:0}
@media (min-height:850px){@container gf-page (min-width:650px){.view-control-stack .joystick-base{width:min(100%,132px)}}}
@container gf-page (max-width:319px){.touch-controller{grid-template-columns:minmax(0,1.35fr) minmax(0,1fr)}.layer-control{padding:4px}}

/* Let the common page gradient show through behind the cube and its controls. */
.layer-control{border:0;background:transparent;box-shadow:none;backdrop-filter:none}
main.shell:focus,main.shell:focus-visible{outline:none}

/* Keep the cube below an opaque control layer, including disabled buttons. */
.cube-viewport{isolation:isolate}
.cube-scene{z-index:0}
.turn-canvas{z-index:1}
.touch-controller{z-index:20;isolation:isolate;transform:translateX(-50%) translateZ(0);transform-style:flat;opacity:1}
/* Keep the six separate keys opaque without a surrounding panel. */
.touch-controller .layer-control{padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;backdrop-filter:none;gap:6px}
/* Let the upper grid row absorb joystick height so this gap stays exactly 4px. */
.touch-controller{grid-template-rows:minmax(0,1fr) auto;row-gap:4px}
.premium-stage button:disabled,.touch-controller button,.touch-controller button:disabled,.touch-controller [aria-disabled="true"],.touch-controller .joystick-base,.touch-controller .joystick-knob{opacity:1;filter:none}
.touch-controller button:disabled{background:linear-gradient(145deg,#161d29,#080b11);color:#9d927a;border-color:#51472f;cursor:not-allowed}

/* Match the overview divider exactly at the start of the transparent play area. */
.premium-stage::before{content:"";position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent 0%,rgba(201,168,83,.25) 14%,rgba(231,199,119,.9) 38%,#ead49a 50%,rgba(231,199,119,.9) 62%,rgba(201,168,83,.25) 86%,transparent 100%);pointer-events:none}

/* Halve the complete gap to the overview divider, including responsive spare stage height.
   Current gap: 8px below the controls + 12px stage padding + 16px overview padding,
   plus any extra height imposed by the stage minimum. Keep cube/control positions fixed. */
body[data-localized-page-kind="play"] .premium-stage{margin-bottom:calc((36px + max(0px,calc(var(--picture-stage-min) - var(--picture-view-height) - 18px))) / -2)}

/* Replace the joystick and undo row with Center and Help beside the six turn keys. */
.touch-controller{grid-template-areas:"turn view";grid-template-rows:auto;row-gap:0}
.view-control-stack{gap:6px;grid-auto-rows:44px;align-self:end}
.view-control-stack .controller-action{height:44px}

/* Lower the cube by 12px without moving the stage, controls or dividers. */
.cube-viewport{--cube-center-offset:12px}
.cube-scene{top:calc(var(--cube-center-y) + var(--cube-center-offset,0px))}

/* Match the menu-to-divider gap to the statistics-to-menu gap:
   8px scorebar margin + 2px header top = 6px header bottom + 4px stage margin. */
.premium-stage{margin-top:4px}
