@font-face{font-family:'Noto Sans JP';font-style:normal;font-weight:400 500;font-display:swap;src:url('fonts/NotoSansJP-Regular.woff') format('woff')}
body,button,input,select{font-family:'Noto Sans JP',sans-serif;-webkit-font-smoothing:antialiased}
button{border-radius:12px;background:#151617;border-color:#343638;font-weight:400;letter-spacing:.04em}
button:active,button.pressed{background:#303337;border-color:#8d9298;transform:none;filter:none}
#stageLabel{min-width:120px;color:#e3e4e7;gap:7px}
#stageLabel span{display:inline-block!important}
#stageLabel .dialDigit{display:block!important;font-family:Arial,sans-serif;font-size:15px}
#stageLabel .dialWindow{min-width:23px;height:24px;mask-image:none;-webkit-mask-image:none}
#stageLabel .dialDigit{line-height:24px}
#stageLabel .dialPrefix{font:10px Arial,sans-serif;letter-spacing:.12em;color:#999da2}
.dialSeparator{color:#666b70}.stageNav{gap:0}
header{left:12px;right:18px}.stageNav>button:not(#stageLabel){width:30px}
.brand{font:10px Arial,sans-serif;letter-spacing:.28em;color:#777e85;text-align:center}
#question{font-weight:400;letter-spacing:.02em;color:#e3e5e8}
#infoButton{border-radius:10px;font:10px Arial,sans-serif;letter-spacing:.09em;min-height:34px}
#answerForm input{background:#0e0f10;border:1px solid #34373b;border-radius:12px;font:17px Arial,sans-serif;letter-spacing:.1em}
#answerForm input::placeholder{font:11px 'Noto Sans JP',sans-serif;color:#777d84}
#ok{background:#e7e9eb!important;border-color:#e7e9eb!important;color:#17191c!important;border-radius:12px;font:13px Arial,sans-serif;letter-spacing:.1em}
#ok:active{background:#bac0c7!important}
.cinema.opening{display:block;padding:0;background:#000}
.opening .openingLogo{position:absolute;top:50%;left:0;width:100%;margin:0!important;transform:translateY(-50%);font:300 clamp(32px,9vw,46px) Arial,sans-serif;letter-spacing:.15em;animation:openingFade 1.1s ease both}
.opening #startGame{position:absolute;top:calc(50% + 78px);left:50%;transform:translateX(-50%);border:1px solid #45494d;border-radius:12px;min-height:44px;min-width:130px;padding:0 26px;font:11px Arial,sans-serif;letter-spacing:.18em;background:#101112;animation:openingFade .8s .3s both}
.opening .openingNote{display:none}
.opening .mission{position:absolute;top:50%;left:0;width:100%;margin:0;transform:translateY(-50%);font-size:clamp(14px,4.2vw,19px)}
@keyframes openingFade{from{opacity:0}to{opacity:1}}
.clearOverlay .clearHeading{margin:0;font-family:Arial,sans-serif;font-size:clamp(27px,8vw,42px);font-weight:400;letter-spacing:.07em}
.singleButton{background:#17191b;border:1px solid #42464b;border-radius:14px;transition:background .2s,border-color .2s,box-shadow .2s}
.singleButton.neutral{background:#090a0c!important;border-color:#292c31!important;color:#b2b7bf;box-shadow:none!important;font:300 27px Arial,sans-serif}
.singleButton.activated:not(.lit){background:#263039;border-color:#68737e}
.singleButton:active{transform:scale(.96);background:#353e47}
.lightCell,.morphBlock{background:#272a2e;border-color:#484d54;border-radius:13px}
.lightCell:after{background:linear-gradient(135deg,#30343a,#24272c);border-radius:12px}
.lightText{font-family:Arial,sans-serif;font-weight:500}
.lightText.insertBefore,.lightText.insertAfter{left:50%;top:50%;font:500 clamp(29px,9vw,40px) Arial,sans-serif;line-height:1;filter:none;min-width:0}
.lightText.insertBefore{transform:translate(-110%,-50%);color:#f0f3f8;text-shadow:1px 1px 2px #aab4c355,3px 4px 6px #000a,7px 9px 15px #000a}
.lightText.insertAfter{transform:translate(10%,-50%);color:#202731;text-shadow:none;filter:url('#letterRecess')}
.effectDefinitions{position:absolute;width:0;height:0;overflow:hidden;pointer-events:none}
#lightBar:before{background:#23262a;border-color:#494e55;height:4px}#lightBar:after{height:4px;background:#cfd5dc;box-shadow:0 0 9px #c7d1e233}
#keyPanel{width:calc(100% - 16px);max-width:432px}
.dualKeyHeader{gap:7px;margin-bottom:8px}.dualKeyHeader button{font-size:10px;background:#15181c;border:1px solid #3c4148;border-radius:7px;color:#b4bbc4;min-height:28px;padding:0 10px}
.dualKeys{gap:8px}
.alphaKeys{position:relative;grid-template-rows:repeat(3,minmax(0,1fr));gap:5px}
.alphaRow button{font:14px Arial,sans-serif;background:#23262a;border:1px solid #3c4148;border-radius:7px}
.cornerCursorKeys{position:absolute;inset:0;pointer-events:none}
.cornerCursorKeys button{position:absolute;bottom:0;pointer-events:auto;min-height:0;width:calc((100% - 27px)/10);height:calc((100% - 10px)/3);padding:0;border:1px solid #3c4148;background:#23262a;border-radius:7px;font:19px Arial,sans-serif}
.cornerCursorKeys button:first-child{left:0}.cornerCursorKeys button:last-child{right:0}
.numberKeys button{font:14px Arial,sans-serif;background:#23262a;border-color:#3c4148;border-radius:7px}
.modal{background:#101214;border-color:#343a41;border-radius:18px;padding:25px}
.modalHead>span{display:none}.modal h2{font:15px Arial,sans-serif;letter-spacing:.15em}.settings{margin-top:24px}.setting{padding:15px 0;border-color:#2b3036}
.seg button{border-radius:7px;background:#191c20;border-color:#343a42}.seg button.active{background:#dce0e5;color:#181c21}
.share{gap:8px}.share button{font:11px Arial,sans-serif;min-height:40px;background:#1b1e22;border-color:#373d45;border-radius:9px}
#info .closeRow{margin:10px auto 0;width:calc((100% - 16px)/3);display:block}
#info .closeRow button{width:100%;min-height:28px;font:9px Arial,sans-serif;letter-spacing:.12em;background:#1b1e22;border:1px solid #373d45;border-radius:7px;color:#aab1ba;padding:0}
#historyList{display:flex;flex-direction:column;gap:12px}
.pickerCaption{font:10px Arial,sans-serif;letter-spacing:.15em;color:#8c959f;margin:10px 0 0}
.pickerStages,.pickerParts{display:grid;grid-template-columns:repeat(5,1fr);gap:7px}
#historyList button{min-height:44px;padding:0;font:14px Arial,sans-serif;background:#1b1e22;border-radius:9px}
#historyList button.active{background:#e2e6eb;color:#161a20;border-color:#e2e6eb}
@media(max-width:350px){#stageLabel{min-width:108px;gap:4px}.alphaRow button{font-size:12px}.cornerCursorKeys button{font-size:17px}}
/* Stage jumps and class steps have separate controls. */
#stageLabel{min-width:112px;gap:5px}.stageNav>button:not(#stageLabel){width:27px}
.stageNav>.majorStep{font-size:16px!important;color:#c2c9d2}
.stageNav>button:disabled{opacity:.2}
.numberedClear .clearHeading{display:flex;flex-direction:column;align-items:center;gap:12px;line-height:1.15;animation:overlayReveal .5s both}
.clearStageLine{display:flex;align-items:center;gap:.2em;font:400 clamp(31px,9vw,47px) Arial,sans-serif;letter-spacing:.04em;white-space:nowrap}
.clearDialWindow{display:inline-block;position:relative;height:1.2em;min-width:.72em;overflow:hidden;perspective:120px;font-variant-numeric:tabular-nums}
.clearDialCurrent,.clearDialIncoming{display:block;line-height:1.2;transform-origin:50% 50% -12px}
.clearDialIncoming{position:absolute;inset:0}
.clearWord{font:400 clamp(31px,9vw,47px) Arial,sans-serif;letter-spacing:.1em}
.memoSlot{height:30px;flex:none;width:100%}
#app>.boardTools{position:absolute;right:calc((100% - var(--grid))/2);bottom:calc(var(--bottom) + var(--key-reserve) - 14px);width:var(--cell);height:24px;min-height:24px;margin:0;z-index:12;justify-content:stretch}
#app>.boardTools .memoHelp{display:none}
#app>.boardTools button{width:100%;min-height:24px;font:9px Arial,sans-serif;border:1px solid #414750;border-radius:7px;background:#15181c;color:#c1c9d3;padding:0}
#app>.boardTools button.active{background:#cbd2dc;color:#11161c}
body:has(#app[data-stage^="3"]) .dualKeyHeader{justify-content:flex-start}
@media(max-width:350px){#stageLabel{min-width:102px;gap:3px}.stageNav>button:not(#stageLabel){width:26px}}
/* Revision 11: generous clear rhythm; the stage and its numeral stay together. */
.numberedClear .clearHeading{gap:8px;animation:overlayReveal .85s both;max-width:100%}
.numberedClear .clearStageLine{display:flex!important;flex-flow:row nowrap;align-items:center;gap:.18em;font-size:clamp(45px,13.5vw,70px);font-weight:500;line-height:1.15;letter-spacing:0}
.numberedClear .clearStageLine span{margin-top:0!important}
.numberedClear .clearWord{font-size:clamp(50px,15vw,78px);line-height:1.1;font-weight:500;letter-spacing:.06em;margin-top:0}
.classClearMark{font:300 80px Arial,sans-serif;line-height:1;animation:overlayReveal .3s both;color:#edf1f5}
#keyPanel{position:absolute;z-index:20;box-sizing:border-box;background:#101215;border:1px solid #252a30;border-radius:13px;padding:8px;height:auto;bottom:calc(var(--bottom) + 8px);overflow:visible;isolation:isolate}
.dualKeyHeader{justify-content:flex-end;height:30px;margin-bottom:8px;gap:6px}
.dualKeyHeader button{display:flex;align-items:center;justify-content:center;width:66px;height:30px;min-height:30px;padding:0;flex:none;font-size:10px;background:#1c2025}
.dualKeyHeader button svg{width:27px;height:21px;display:block}
.dualKeyHeader button:last-child{width:44px}
#answerCaret{position:absolute;top:50%;height:21px;width:1.5px;background:#e9edf3;transform:translateY(-50%);pointer-events:none;animation:caretBlink 1.1s steps(1) infinite;z-index:2}
@keyframes caretBlink{0%,50%{opacity:1}51%,100%{opacity:0}}
#app[data-stage="1A"] #answerForm{display:flex;justify-content:center;gap:0}
#app[data-stage="1A"] #answer{display:none}
#app[data-stage="1A"] #ok{width:var(--cell);flex:0 0 var(--cell)}
#app[data-stage="1B"] #answer{animation:openingFade .5s both}
#app[data-stage="1B"] #ok{animation:okMoveRight .5s cubic-bezier(.22,.7,.3,1) both}
@keyframes okMoveRight{from{transform:translateX(calc(-1 * (var(--cell) + 7px)))}to{transform:translateX(0)}}
#firstReset{position:absolute;right:calc((100% - var(--grid))/2);bottom:calc(var(--bottom) + var(--key-reserve) - 21px);width:var(--cell);height:30px;min-height:30px;padding:0;font-size:10px;z-index:12;background:#101215;border-color:#343a42}
#app[data-stage="1A"] #firstReset{right:calc((100% - var(--cell))/2)}
.singleButton.neutral{background:#060708!important;border-color:#25282d!important}
.singleButton:not(.lit){box-shadow:none!important}
.lightText.insertBefore{left:16%;transform:translate(0,-50%);text-shadow:3px 5px 9px #000b,7px 10px 18px #0008}
.lightText.insertAfter{left:auto;right:16%;transform:translate(0,-50%);color:#f0f3f8;text-shadow:none;filter:none}
.board .tile{transition:transform 160ms cubic-bezier(.2,.7,.3,1),background 70ms;will-change:transform}
#app>#wordResults{position:absolute;top:calc(var(--vh) - var(--bottom) - var(--key-reserve) + 30px);left:calc((100% - var(--grid))/2);width:var(--grid);height:auto;max-height:calc(var(--key-reserve) - 46px);margin:0;padding:9px 12px;box-sizing:border-box;background:#15181c;border:1px solid #383f47;border-radius:10px;z-index:13;overflow:auto;font-size:11px}
#wordResults .wordHeader{font-size:10px}.wordMeanings span{font-size:11px;line-height:1.5;padding:3px 7px}
#fan{height:242px}
#swap{position:absolute;top:157px;left:80px;width:110px;height:40px;min-height:40px;margin:0;padding:0;font-size:12px}
#fanClose{position:absolute;top:200px;left:113px;width:44px;height:40px;min-height:40px;padding:0;background:transparent;border:0;font:26px Arial,sans-serif;color:#e3e7ed}
#fanLetters span{pointer-events:auto}
@media(prefers-reduced-motion:reduce){#answerCaret{animation:none}.classClearMark,#app[data-stage="1B"] #ok{animation:none}}
#app{min-height:0;height:var(--vh);overflow:hidden}
.singleButton{transition:background 65ms,border-color 65ms,box-shadow 65ms}
#answer{caret-color:transparent}
/* Internal answer display: glyphs and caret share the same layout flow. */
#app #answerForm #answer{grid-column:span 2;min-width:0;width:100%;height:var(--cell);display:flex;align-items:center;padding:0 18px;overflow:hidden;background:#0e0f10;border:1px solid #34373b;border-radius:12px;color:#edf0f4;font:17px Arial,sans-serif;letter-spacing:.1em;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:text}
#answer .answerTrack{display:inline-flex;align-items:center;flex:none;white-space:pre;min-height:24px}
#answer .answerGlyph{display:inline-block;flex:none}
#answer .answerGlyph.selected{background:#53647a}
#answer .inlineCaret{display:block;position:relative;flex:0 0 0;width:0;height:21px;box-shadow:none;pointer-events:none}
#answer .inlineCaret.visible:after{content:'';position:absolute;left:0;top:0;width:1.5px;height:21px;background:#edf0f4;animation:caretBlink 1.1s steps(1) infinite}
#answer .answerPlaceholder{font:11px 'Noto Sans JP',sans-serif;letter-spacing:0;color:#777d84;pointer-events:none}
#app #answerForm #answer[aria-disabled="true"]{background:#101113;border-color:#25282d;color:#606466;cursor:default}
#answer:focus-visible{outline:1px solid #89939f;outline-offset:3px}
#app[data-stage="1A"] #answerForm #answer{display:none}
#app[data-stage="1B"] #answerForm #answer{animation:openingFade .5s both}
#firstReset{bottom:calc(var(--bottom) + var(--key-reserve) - 33px)}
/* Keep the reset separated from both OK and the keyboard frame. */
body:has(#app[data-stage^="1"]) #keyPanel{bottom:var(--bottom)}
#app[data-stage="2B"] .lightText.insertBefore{left:9%;right:auto}
#app[data-stage="2B"] .lightText.insertAfter{right:9%;left:auto}
@media(prefers-reduced-motion:reduce){#answer .inlineCaret.visible:after{animation:none}}
.classClearMark{width:min(64vw,300px);height:min(64vw,300px);border:3px solid #edf1f5;border-radius:50%;font-size:0;line-height:0;flex:none;box-sizing:border-box;animation:overlayReveal .3s both}

#swap{top:24px;opacity:.35;transition:opacity 140ms,background 140ms}
#fanLetters{transition:opacity 140ms}
/* Revision 13: flat lettering, centered arrows and radial trapezoid keys. */
.classClearMark{width:min(48vw,220px);height:min(48vw,220px);border-width:6px}
.lightText.insertBefore,.lightText.insertAfter{text-shadow:none;filter:none}
#app[data-stage="2C"] .lightText.directionGlyph{position:absolute;inset:0;display:grid;place-items:center;min-width:0;transform:none;margin:0;padding:0;line-height:1}
.lightText.directionGlyph svg{display:block;width:32px;height:32px}
#fanLetters span{width:55px;height:62px;clip-path:polygon(0 0,100% 0,79% 100%,21% 100%);border-radius:0;transform:translate(-50%,-50%) rotate(var(--fan-angle,0deg));background:#e4e7eb;color:#252a30;border:0;box-shadow:none;padding-bottom:4px;font:22px Arial,sans-serif}
#fanLetters span.chosen{background:#fff;color:#080a0d;border:0;font-size:28px;box-shadow:none}
/* Revision 14 */
#app>.brand{display:none!important}
.opening .mission{font-size:clamp(18px,5.5vw,25px);letter-spacing:.015em;white-space:nowrap}
.titleSwap{display:inline-grid;position:relative}
.titleSwap>span{grid-area:1/1}
.titleSwap>span:first-child{animation:spellingOut .28s .18s both}
.titleSwap>span:last-child{animation:spellingIn .28s .18s both}
@keyframes spellingOut{to{opacity:0;transform:translateY(-8px)}}
@keyframes spellingIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.opening #startGame{animation:none;opacity:1}
#app #ok,#app #ok.clearedOK{background:#151617!important;border:1px solid #343638!important;color:#edf0f4!important;font-weight:700}
#app #ok:active{background:#303337!important}
#keyPanel .numberKeys .dot{background:#23262a!important;color:#edf0f4!important;border:1px solid #3c4148!important;font-weight:700;font-size:20px}
#app #answerForm #answer,#app #answerForm #answer[aria-disabled="true"]{background:#1b1e22;border-color:#34373b}
#keyPanel .numberKeys .zero{background:#292d33;border-color:#3c4148}
#firstReset{bottom:calc(var(--bottom) + var(--key-reserve) - 27px)}
.questionSuccess{position:absolute;right:0;bottom:calc(100% + 10px);width:var(--cell);height:58px;display:grid;place-items:center;background:#f3f4f5;border-radius:12px;z-index:32;pointer-events:none;animation:overlayReveal .18s both}
.questionSuccess:after{content:'';position:absolute;bottom:-5px;left:calc(50% - 5px);width:10px;height:10px;transform:rotate(45deg);background:#f3f4f5;border-radius:1px}
.questionSuccess>span{width:29px;height:29px;border:4px solid #171a1e;border-radius:50%;font-size:0}
#app[data-stage="1A"] .questionSuccess{right:calc((100% - var(--cell))/2)}
.singleButton{position:relative;overflow:visible}
.singleButton:after{content:'';position:absolute;inset:0;border-radius:inherit;background:#fff;opacity:0;pointer-events:none}
.singleButton.stepFlash:after{animation:stepLight .2s ease-out}
@keyframes stepLight{from{opacity:.22}to{opacity:0}}
#app #status,body.keyboardOpen #app #status{top:auto;bottom:calc(var(--bottom) + var(--key-reserve) - 76px);min-height:28px;padding:5px 12px;line-height:1.6;width:var(--grid);border-radius:8px;background:#161a20e8;z-index:30;white-space:normal}
#status:empty{display:none}
body:has(#app[data-stage^="3"]) .dualKeyHeader{justify-content:flex-end}
#app[data-stage="3B"]>.boardTools{display:none}
#app[data-stage="1A"] #play:before,#app[data-stage="1B"] #play:before,#app[data-stage^="3"] #play:before{content:'';position:absolute;left:50%;top:50%;width:calc(var(--grid) + 70px);height:calc(var(--grid) + 70px);transform:translate(-50%,-50%);background:radial-gradient(ellipse,#c4d5ee40,transparent 67%);opacity:var(--ambient,0);filter:blur(20px);pointer-events:none;z-index:-1;transition:opacity .35s}
#app #play{isolation:isolate}
.scene:not(.rubikRevealed) .face:not(.whiteBlock):not(.glow){background:color-mix(in srgb,#353c46, #b7cbe9 var(--cube-tint,0%));transition:background .35s}
#fan{height:210px}
#fanClose{top:164px}
#fanLetters span,#fanLetters span.chosen{width:48px;height:44px;clip-path:none;background-color:transparent;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 44'%3E%3Cpath fill='%23e4e7eb' d='M6 1H42Q47 1 45 6L37 39Q36 43 32 43H16Q12 43 11 39L3 6Q1 1 6 1Z'/%3E%3C/svg%3E");background-size:100% 100%;padding:0;border:0;border-radius:0;font-size:21px}
#fanLetters span.chosen{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 44'%3E%3Cpath fill='white' d='M6 1H42Q47 1 45 6L37 39Q36 43 32 43H16Q12 43 11 39L3 6Q1 1 6 1Z'/%3E%3C/svg%3E");font-size:26px}
.opening .openingLogo{animation:openingFade .35s both}
#app #status,body.keyboardOpen #app #status{bottom:calc(var(--bottom) + var(--key-reserve) - 20px);width:calc(var(--cell)*2 + 7px);font-size:10px}
#app[data-stage="1A"] #status{bottom:calc(var(--bottom) + var(--key-reserve) - 74px);width:var(--grid)}
/* Revision 15 */
.titleSwap>span:first-child{animation:spellingOut .65s .85s both}
.titleSwap>span:last-child{color:inherit;animation:spellingIn .65s .85s both}
.singleButton:before{content:'';position:absolute;inset:-24px;border-radius:28px;background:radial-gradient(ellipse,#ffffff75 0%,#ffffff20 45%,transparent 72%);filter:blur(11px);opacity:0;pointer-events:none;z-index:-1}
.singleButton.stepFlash:before{animation:stepHalo .38s ease-out}
@keyframes stepHalo{from{opacity:.8}to{opacity:0}}
#app #status,body.keyboardOpen #app #status,#app[data-stage="1A"] #status{top:calc(var(--top) + 132px);bottom:auto;width:var(--grid);min-height:0;padding:0;background:none;border-radius:0;font-size:11px;line-height:1.6}
#memoRadial{position:fixed;z-index:85;pointer-events:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none}
#memoRadial svg{display:block;width:100%;height:100%;overflow:visible;animation:openingFade .15s both}
/* Revision 16: tile-local letter placement and memo reset. */
#app[data-stage="3A"]>.boardTools{width:calc(var(--cell)*2 + 7px);display:grid;grid-template-columns:repeat(2,var(--cell));gap:7px}
#app[data-stage="3A"]>.boardTools #resetMemos{font-size:10px}
.board .tile{display:flex;align-items:center;justify-content:center;padding:0}
.board .tile>span{display:block;line-height:1;margin:0;padding:0;text-align:center;letter-spacing:0}
/* Revision 17: separate Reset and MEMO across the board width. */
#app[data-stage="3A"]>.boardTools{width:var(--grid);grid-template-columns:repeat(3,var(--cell));gap:7px}
#app[data-stage="3A"]>.boardTools #resetMemos{grid-column:1}
#app[data-stage="3A"]>.boardTools #memoToggle{grid-column:3}
.memoSlot{display:flex;align-items:center;justify-content:center;color:#8a8f96;font-size:10px;font-weight:400;letter-spacing:.015em;white-space:nowrap}

/* Stage 4: separate instructions, controls, clue and floating cube. */
#app[data-stage^="4"] #question{font-size:clamp(11px,3.5vw,15px);line-height:1.6;white-space:nowrap;text-align:center;letter-spacing:0}
#app[data-stage^="4"] #play{inset:50px -14px 0;gap:8px;justify-content:flex-start}
#app[data-stage^="4"] .cubeModeTools{width:100%;justify-content:center;margin:0;gap:8px}
#app[data-stage^="4"] .cubeModeTools button{flex:0 1 auto;min-height:32px;padding:0 14px;font-size:10px}
#app[data-stage^="4"] .cluebar{width:100%;margin:0;min-height:42px;gap:8px}
#app[data-stage^="4"] .cluebar .clue{font-size:14px;line-height:1.3}
#app[data-stage^="4"] .cluebar small{margin-top:4px;line-height:1.2;font-size:8px}
#app[data-stage^="4"] .interactionNote{font-size:9px;line-height:1.4;letter-spacing:0;white-space:nowrap}
#app[data-stage^="4"] .scene{flex:1;min-height:0;animation:none}
#app[data-stage^="4"] .cubie{transition:none}
#app[data-stage^="4"] .scene:not(.rubikTurning) .face,#app[data-stage^="4"] .scene:not(.rubikTurning) .face.whiteBlock{background:#282b2f!important;color:#f1f2f4;border-color:#3b3e42;box-shadow:none}
#app[data-stage^="4"] .scene:not(.rubikTurning) .face.path{outline:3px solid #d9e0e6;outline-offset:-4px}
#app[data-stage^="4"] .routeLink:after,#app[data-stage^="4"] .routeStart:before{display:none}
#cubeLetterReset{position:absolute;left:calc((100% - var(--grid))/2);bottom:calc(var(--bottom) + var(--key-reserve) - 14px);width:var(--cell);height:24px;min-height:24px;padding:0;font:10px Arial,sans-serif;background:#15181c;color:#c1c9d3;border:1px solid #414750;border-radius:7px;z-index:12}

/* Keep the whole Stage 4 text area in front of the 3D scene. */
#app[data-stage^="4"] .scene{position:relative;z-index:0;isolation:isolate}
#app[data-stage^="4"] #question{position:relative;z-index:6;background:rgba(0,0,0,.72)}
#app[data-stage^="4"] .cluebar{position:relative;z-index:5;background:rgba(0,0,0,.72);isolation:isolate}
#app[data-stage^="4"] .cluebar .clue{background:transparent}
#app[data-stage^="4"] .interactionNote{position:relative;z-index:5;background:rgba(0,0,0,.72);padding:4px 6px;max-width:100%;isolation:isolate}
#app[data-stage^="4"] .cubeModeTools,#app[data-stage^="4"] .turnControls{position:relative;z-index:5}
#app[data-stage^="4"] header,#app[data-stage^="4"] #answerForm{z-index:7}

/* The cube center is anchored to stageContent, independently of mode controls. */
#app[data-stage^="4"] .scene{position:absolute;left:0;right:0;bottom:auto;height:160px;flex:none}
#app[data-stage^="4"] .interactionNote{position:absolute;bottom:0;left:0;right:0;margin:0}
#app[data-stage^="4"] .turnControls{position:absolute;bottom:0;left:0;right:0}

/* Face selection applies to all blocks in the moving layer. */
#app[data-stage^="4"] .selectedTurnFace{outline:none}
#app[data-stage^="4"] .selectedTurnFace:after{display:none!important}


/* A soft glowing outline encloses the entire selected 3x3x1 layer. */
#app[data-stage^="4"] .cubeLayerOutline{position:absolute;width:0;height:0;transform-style:preserve-3d;pointer-events:none}
#app[data-stage^="4"] .cubeLayerEdge{position:absolute;border:1.5px solid #f0f3f5;border-radius:5px;background:transparent;box-shadow:0 0 5px #ffffff65,inset 0 0 3px #ffffff25;pointer-events:none;backface-visibility:hidden;-webkit-backface-visibility:hidden}

#app[data-stage^="4"] .cubeModeTools{flex-wrap:wrap;row-gap:6px}
#app[data-stage^="4"] .cubeRescueRow{flex:0 0 100%;display:flex;justify-content:center}
#app[data-stage^="4"] .cubeRescueRow .cubeRescue{min-height:30px;padding:0 12px;font-size:10px;color:#bbc2ca;background:#121519;border:1px solid #394049}

#app[data-stage^="4"] .cubeInstructionLead{white-space:nowrap}

.opening #restartGame{position:absolute;top:calc(50% + 136px);left:50%;transform:translateX(-50%);min-height:44px;min-width:130px;padding:0 26px;border:1px solid #34383e;border-radius:12px;background:#101112;color:#bfc5cd;font:11px Arial,sans-serif;letter-spacing:.18em}
#returnToTitle{display:block;width:100%;min-height:38px;margin-top:14px;padding:0 12px;font-size:11px;background:#1b1b1b;border-color:#373b42}

.opening .openingLogo{color:#eee}

/* Revision 35: stable title alignment, gentle hold feedback, continuous dice body. */
.opening #restartGame{animation:none;opacity:1}
.opening #restartGame:active,.opening #startGame:active{transform:translateX(-50%) scale(.97)}
#info.holdShaking .modal{animation:gentleInfoHold .46s ease-in-out infinite;transform-origin:50% 60%}
@keyframes gentleInfoHold{0%,100%{transform:translateX(0) rotate(0)}25%{transform:translateX(-.7px) rotate(-.15deg)}75%{transform:translateX(.7px) rotate(.15deg)}}
.scene .roundedDie:before{display:none!important}
.scene .roundedDie .face{width:72px;height:72px;left:-36px;top:-36px;border:0!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;font:500 12px Arial,sans-serif;letter-spacing:.01em;text-shadow:0 1px 1px #000;color:#eee;pointer-events:none}
.scene .roundedDie .face.red{color:#ff4c57}
.dieSurface{position:absolute;left:0;top:0;transform-origin:0 0;backface-visibility:hidden;-webkit-backface-visibility:hidden;pointer-events:none}
@media(prefers-reduced-motion:reduce){#info.holdShaking .modal{animation:none}}

/* Revision 36: one continuous die surface, no engraved text shadow. */
.scene .roundedDie .face{text-shadow:none!important}
.dieVisual{position:absolute;left:50%;top:50%;width:360px;height:360px;margin:-180px 0 0 -180px;pointer-events:none;z-index:1}
.dieVisual canvas{display:block;width:360px;height:360px;pointer-events:none}
#app[data-stage="6"] .scene,#app.breakingCube .scene{animation:none!important;height:160px;flex:none;position:absolute;top:50%;left:0;right:0;margin-top:-80px}
#app.breakingCube #stageContent{top:calc(var(--top) + 84px);bottom:calc(var(--bottom) + var(--key-reserve) + var(--cell) + 23px)}
#app.breakingCube #play{inset:54px 0 0}
.scene.diceOnly .assembly{display:none}
/* Revision 37: the dice answer dock shares the cube's exact closed/open positions. */
#app[data-stage="6"] #answerForm{bottom:calc(var(--bottom) + 66px);height:var(--cell)!important;min-height:0;grid-template-rows:var(--cell);align-items:start;z-index:7}
body.keyboardOpen #app[data-stage="6"] #answerForm{bottom:calc(var(--bottom) + var(--key-reserve) + 16px)}
#app[data-stage="6"] #answerForm #answer,#app[data-stage="6"] #answerForm #ok{height:var(--cell)!important;min-height:0!important;max-height:var(--cell);box-sizing:border-box}
/* Revision 38: centered return dock and the final celebration sequence. */
#app[data-stage="6"] > .referenceCube{position:absolute;left:50%;bottom:calc(var(--bottom) + 66px + var(--cell) + 18px);transform:translateX(-50%);z-index:7;min-height:34px;margin:0}
body.keyboardOpen #app[data-stage="6"] > .referenceCube{bottom:calc(var(--bottom) + var(--key-reserve) + 16px + var(--cell) + 18px)}
#app[data-stage="6"] > .referenceCube:active{transform:translateX(-50%) scale(.97)}
.cinema.finalCongratulations{background:#000;overflow:hidden}
.finalCongratulationsText{position:relative;z-index:2;font:400 clamp(19px,5.5vw,30px) Arial,sans-serif;letter-spacing:.035em;white-space:nowrap;color:#f1f3f6;animation:openingFade .85s both}
.finalConfetti{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:1}
.finalConfetti i{position:absolute;top:-15px;display:block;border-radius:1px;opacity:0;animation:finalConfettiFall 3s cubic-bezier(.15,.45,.45,1) both}
@keyframes finalConfettiFall{0%{opacity:0;transform:translate3d(0,-20px,0) rotate(0)}10%{opacity:.9}82%{opacity:.75}100%{opacity:0;transform:translate3d(var(--drift),calc(var(--vh) + 40px),0) rotate(var(--spin))}}
.finaleLogo{font:300 clamp(32px,9vw,46px) Arial,sans-serif;letter-spacing:.15em;white-space:nowrap;margin:0 0 56px;text-align:center;color:#eee;animation:openingFade 1.1s both}
.completed .finalShareCaption{font:11px 'Noto Sans JP',sans-serif;color:#aeb4bc;letter-spacing:.07em;margin:0 0 15px;animation:openingFade .7s .4s both}
.completed .finalShare{animation:openingFade .7s .55s both}
@media(prefers-reduced-motion:reduce){.finaleLogo,.finalCongratulationsText,.completed .finalShareCaption,.completed .finalShare{animation:none}}

/* Revision 39: supplied artwork on the title screen only. */
.cinema.opening:has(.openingLogo){background:#000 url('assets/title-background.png') center center / cover no-repeat}
@media(min-aspect-ratio:1/1){.cinema.opening:has(.openingLogo){background-size:auto 100%}}

/* Revision 40: completed artwork, with text kept clear of the pictured die. */
#app.completed{background:#000 url('assets/clear-background-v2.png') center center / cover no-repeat}
#app.completed .finaleLogo{position:absolute;top:18%;left:50%;width:max-content;max-width:calc(100vw - 24px);transform:translateX(-50%);margin:0}
#app.completed .finalShareCaption{position:absolute;left:0;right:0;bottom:66px;margin:0;text-align:center}
#app.completed .finalShare{position:absolute;left:50%;bottom:0;transform:translateX(-50%);width:min(260px,calc(100vw - 48px));margin:0}
/* Revision 41: downloadable clear artwork in its own modal. */
#app.completed .clearImageTrigger{position:absolute;bottom:106px;left:50%;transform:translateX(-50%);min-height:34px;padding:0 16px;border-radius:9px;background:#0f1114dd;border:1px solid #444951;font:11px 'Noto Sans JP',sans-serif;white-space:nowrap;animation:openingFade .7s .4s both}
#app.completed .clearImageTrigger:active{transform:translateX(-50%) scale(.97)}
.clearImageOverlay{z-index:100;padding:18px}
.clearImagePanel{width:min(100%,820px);padding:18px;border-radius:12px;background:#101113;border:1px solid #34383d;max-height:calc(var(--vh) - 36px);overflow-y:auto}
.clearImagePanel h2{font:13px 'Noto Sans JP',sans-serif;letter-spacing:.06em;margin:0 0 16px;color:#e7ebef}
.clearImagePanel .clearImagePreview{display:block;width:100%;height:auto;max-height:calc(var(--vh) - 210px);object-fit:contain;background:#000;border-radius:5px;-webkit-touch-callout:default!important;-webkit-user-select:auto!important;user-select:auto!important;touch-action:auto}
.clearImageNote{font:11px/1.7 'Noto Sans JP',sans-serif;color:#999fa8;margin:13px 0 16px}
.clearImageActions{display:flex;gap:10px;justify-content:flex-end}
.clearImageActions button,.clearImageDownload{display:flex;align-items:center;justify-content:center;min-height:40px;padding:0 16px;border:1px solid #454b52;border-radius:8px;background:#181b1f;color:#eef1f4;font:11px 'Noto Sans JP',sans-serif;letter-spacing:.03em;text-decoration:none}
.clearImageDownload:focus-visible{outline:2px solid #e2e5df;outline-offset:4px}
@media(prefers-reduced-motion:reduce){#app.completed .clearImageTrigger{animation:none}}
/* Revision 44: the post-clear spelling reveal, then four colors filling in. */
.clearImageWarning{font:11px/1.8 'Noto Sans JP',sans-serif;color:#e3c8b8;margin:14px 0 8px;padding:10px 12px;border:1px solid #695247;border-radius:7px;background:#241c1840}
.finaleColor{color:var(--final-color);animation:finaleColorFill 1.4s 2.7s both}
.finaleSwap{display:inline-grid;position:relative;vertical-align:baseline}
.finaleSwap>span{grid-area:1/1}
.finaleSwap>.finaleS{opacity:0;color:#eee;animation:finaleSpellingOut .75s 1.8s both}
.finaleSwap>.finaleColor{animation:finaleSpellingIn .75s 1.8s both,finaleColorFill 1.4s 2.7s both}
@keyframes finaleSpellingOut{from{opacity:1}to{opacity:0}}
@keyframes finaleSpellingIn{from{opacity:0}to{opacity:1}}
@keyframes finaleColorFill{from{color:#eee}to{color:var(--final-color)}}
@media(prefers-reduced-motion:reduce){.finaleColor,.finaleSwap>.finaleS,.finaleSwap>.finaleColor{animation:none}}

.resetConfirmOverlay{z-index:120;background:#0009;backdrop-filter:blur(9px);-webkit-backdrop-filter:blur(9px)}.resetConfirmPanel{border-radius:14px;background:#141618;border:1px solid #3b4045;padding:27px 24px;box-shadow:0 20px 70px #0007}.resetConfirmPanel p{margin:0 0 24px;font-size:15px;line-height:1.9;text-align:center;color:#e3e6e9;letter-spacing:.02em}.resetConfirmActions{display:grid;grid-template-columns:1fr 1fr;gap:12px}.resetConfirmActions button{min-height:44px;border-radius:9px;background:#1d2023;border:1px solid #454b50;font-size:12px;letter-spacing:.12em}.resetConfirmActions button:active{background:#363c41}.resetConfirmActions button:focus-visible{outline:2px solid #c9ced4;outline-offset:3px}

#app[data-stage="3B"] .board{pointer-events:none;user-select:none;-webkit-user-select:none}#app[data-stage="3B"] .board .tile,#app[data-stage="3B"] .board .tile:disabled,#app[data-stage="3B"] .board .tile:hover,#app[data-stage="3B"] .board .tile:active{background:#2c2f33;border-color:#4b5056;color:#edf0f3;opacity:1;filter:none;box-shadow:none;cursor:default;pointer-events:none}#app[data-stage="3B"] .board .tile span{color:#f0f2f5}
