:root{color-scheme:dark;--bg:#1d2124;--panel:#292c2f;--button:#303234;--button-hi:#3b3d3f;--grid:#1b1f22;--line:#444b50;--outer:#687178;--chalk:#a6a6a3;--text:#f0f0ed;--muted:#969b9d;--green:#16b889;--green-bright:#27dba4;--green-soft:rgba(22,184,137,.14);--red:#ef3e61;--blue:#4389ec}
*{box-sizing:border-box;margin:0;padding:0;font-family:Arial,Helvetica,sans-serif;touch-action:manipulation}html,body{min-height:100%;background:var(--bg);color:var(--text)}body{display:flex;justify-content:center;overflow-x:hidden}button,select{font:inherit;color:inherit}button{cursor:pointer}.app-shell{width:100%;max-width:540px;min-height:100dvh;position:relative}.screen{display:none;min-height:100dvh}.screen.active{display:flex}.brand{display:flex;align-items:center;justify-content:center;gap:.42em;font-size:1.7rem;font-weight:800;line-height:1}.brand i{display:block;width:.35em;height:.35em;border-radius:50%;background:#ddd}.brand .three{color:var(--red)}.brand .two{color:var(--blue)}.brand .one{color:var(--green)}.brand-large{font-size:2.2rem}.home-screen{flex-direction:column;align-items:center;justify-content:center;padding:24px}.home-screen>.brand{margin-top:auto}.home-actions{display:grid;gap:10px;width:min(250px,75vw);margin:auto 0}.action-primary,.action-secondary{min-height:44px;border-radius:10px;font-weight:800;letter-spacing:.02em}.action-primary{border:0;background:var(--green);color:#fff}.action-primary:disabled{opacity:.4}.action-secondary{border:1px solid var(--green);background:transparent;color:var(--green)}.bottom-nav{width:100%;height:55px;background:var(--panel);display:flex;align-items:center;justify-content:space-between;border-radius:12px;padding:0 10px}.home-screen .bottom-nav,.profile-screen>.bottom-nav{margin-top:auto}.nav-btn{width:50%;height:100%;border:0;background:none;color:#a6adae}.nav-btn.active{color:var(--green)}svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.nav-btn svg{fill:currentColor;stroke:none}.simple-header,.game-titlebar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;width:100%}.simple-header{height:64px;padding:8px}.simple-header>:last-child{justify-self:end}.icon-text-btn,.header-button{border:0;border-radius:11px;background:var(--button);padding:0 14px;height:44px;font-size:.86rem}.profile-screen{flex-direction:column;padding:8px}.profile-content{padding:32px 10px}.profile-content h1{text-align:center;font-size:1.5rem;margin-bottom:24px}.profile-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.profile-grid article{background:var(--panel);border-radius:10px;padding:22px 10px;text-align:center}.profile-grid strong{display:block;color:var(--green);font-size:1.8rem}.profile-grid span{color:var(--muted);font-size:.8rem}.profile-detail{display:flex;justify-content:space-between;padding:17px 4px;border-bottom:1px solid var(--line);color:var(--muted)}.profile-detail strong{color:var(--text)}
.game-screen{flex-direction:column;padding:5px;min-height:100dvh}.game-header{position:relative}.game-titlebar{height:50px}.game-titlebar .header-button:last-child{justify-self:end}.game-statusbar{height:26px;display:grid;grid-template-columns:1.3fr .75fr 1fr auto;align-items:center;gap:7px;background:var(--panel);padding:2px 4px;color:#9da2a3;font-size:.72rem}.progress-wrap{display:flex;align-items:center;gap:4px}.progress-track{height:9px;flex:1;background:#e3e5e3;border-radius:6px;overflow:hidden}.progress-track span{display:block;width:0;height:100%;background:var(--green);transition:width .25s}.progress-wrap small{color:var(--green)}#error-count{color:var(--red)}.timer-button{height:23px;display:flex;align-items:center;gap:3px;border:0;background:none;color:#9da2a3;font-size:.72rem}.timer-button svg{width:17px;height:17px;fill:currentColor;stroke:none}.settings-menu{position:absolute;right:0;top:50px;z-index:50;width:205px;background:#282c2f;border:1px solid #4b5256;padding:10px;border-radius:8px;box-shadow:0 10px 24px #0009;display:none}.settings-menu.open{display:grid;gap:10px}.settings-menu label{display:flex;justify-content:space-between;align-items:center;font-size:.82rem}.settings-menu input{display:none}.settings-menu label>input+span{width:34px;height:19px;border-radius:12px;background:#616669;position:relative;flex:0 0 auto}.settings-menu label>input+span:after{content:"";position:absolute;width:15px;height:15px;border-radius:50%;background:#eee;left:2px;top:2px;transition:.18s}.settings-menu input:checked+span{background:var(--green)}.settings-menu input:checked+span:after{left:17px}
.board-container{width:100%;margin-top:3px;background:var(--grid);border:3px solid var(--outer);overflow:hidden}.grid{display:grid;width:100%;background:var(--grid)}.cell,.target{aspect-ratio:1;display:flex;align-items:center;justify-content:center;position:relative;user-select:none;-webkit-user-select:none}.cell{background:var(--grid);border:.5px solid var(--line);font-size:clamp(1.35rem,7vw,2.25rem);font-weight:500;color:#f4f4f1;cursor:pointer}.cell.fixed{color:var(--green);font-weight:700}.cell.peer-selected{background:#292d30}.cell.selected{background:#3b3e40;box-shadow:inset 0 0 0 2px #dadbd7;z-index:2}.cell.rule-error{color:var(--red);background:rgba(239,62,97,.12)}.cell.line-solved{background:var(--green-soft)}.target{background:#858585;border:.5px solid #737779;color:#d8d8d5;cursor:pointer;font-weight:700}.target .val{font-size:clamp(1rem,4.5vw,1.45rem)}.target .separator{margin:0 1px;color:#c3c3c0}.target .max-val{font-size:clamp(.85rem,3.7vw,1.2rem);color:#c3c3c0}.target.selected-line{background:#696d6f;box-shadow:inset 0 0 0 2px #dadbd7}.target.line-solved{background:rgba(22,184,137,.35)}.target.over .val{color:var(--red)}.corner{background:var(--grid);border:0}.notes-grid{display:flex;gap:1px;font-size:clamp(.55rem,2.5vw,.8rem);font-weight:700}.notes-grid span{color:#eee}.cell.board-enter{animation:gridSweep .34s ease-out both;animation-delay:var(--sweep-delay)}@keyframes gridSweep{from{opacity:0;transform:translateY(12px);background:#3e4447}to{opacity:1;transform:none;background:var(--grid)}}.cell.line-success-wave,.target.line-success-wave{animation:lineWave .42s ease-out both;animation-delay:var(--line-delay)}@keyframes lineWave{0%{background:var(--green-bright);box-shadow:inset 0 0 0 1px #81f6d2}100%{background:rgba(22,184,137,.18);box-shadow:none}}
.game-tools{margin-top:9px}.tool-row{height:48px;display:grid;grid-template-columns:repeat(6,1fr);gap:3px}.number-btn,.tool-btn{border:0;border-radius:9px;background:var(--button);font-size:1.35rem}.number-btn{font-weight:700}.tool-btn{display:flex;align-items:center;justify-content:center;color:#ddd}.tool-btn.active{background:var(--green);color:#fff}.combinations-panel{display:none;margin-top:7px;min-height:168px;background:var(--panel);border:2px solid var(--green);padding:6px;overflow:auto}.combinations-panel.open{display:grid;align-content:start;gap:4px}.combination-row{display:grid;grid-template-columns:1fr 54px;min-height:42px;align-items:center}.combination-equation{padding:8px 14px;font-size:clamp(.9rem,4vw,1.08rem);white-space:nowrap}.combination-trash{height:38px;border:0;border-radius:8px;background:var(--button-hi);color:#ddd;display:flex;align-items:center;justify-content:center}.combination-trash svg{width:20px}.combination-row.manual-discard .combination-equation,.combination-row.auto-discard .combination-equation{text-decoration:line-through;text-decoration-thickness:2px;color:#a7aaab}.combination-row.auto-discard{opacity:.55}.combination-row.auto-discard .combination-trash{visibility:hidden}
.modal-overlay,.pause-overlay{position:fixed;inset:0;z-index:200;background:rgba(18,21,23,.94);display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity .18s}.modal-overlay.open,.pause-overlay.open{opacity:1;pointer-events:auto}.modal{width:min(330px,90vw);background:var(--panel);border:1px solid #555b5e;border-radius:12px;padding:20px;display:grid;gap:16px}.modal h2{text-align:center}.modal label{display:grid;gap:6px;color:var(--muted);font-size:.82rem}.modal select{height:44px;border:1px solid #555b5e;border-radius:8px;background:var(--button);padding:0 10px}.modal-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}.modal-actions button,.message-modal>button{min-height:42px;border-radius:8px}.modal-actions>button:first-child{border:1px solid #555b5e;background:transparent}.message-modal p{text-align:center;color:var(--muted);line-height:1.4}.pause-overlay{flex-direction:column;gap:50px}.pause-overlay .action-primary{width:220px}
body.light-mode{--bg:#e7e6e2;--panel:#d5d4d0;--button:#c5c4c0;--button-hi:#b7b6b2;--grid:#f1f0ec;--line:#b9b9b5;--outer:#777b7c;--text:#272a2c;--muted:#666b6d;--chalk:#696969;color-scheme:light}body.light-mode .cell{color:#272a2c}body.light-mode .cell.fixed{color:#087c60}body.light-mode .target{background:#9a9a96;color:#fff}
@media(min-width:620px){.app-shell{padding:10px}.game-screen{justify-content:flex-start}.board-container{margin-top:6px}.home-screen,.profile-screen{border-left:1px solid #2d3235;border-right:1px solid #2d3235}}
@media(max-height:690px){.game-titlebar{height:44px}.game-tools{margin-top:5px}.tool-row{height:43px}.combinations-panel{min-height:130px}.header-button{height:38px}}
.target.tooltip-active{box-shadow:inset 0 0 0 2px var(--green)}
.game-titlebar .header-button{width:42px;height:42px;padding:0;display:flex;align-items:center;justify-content:center;color:#d5d7d7}.game-titlebar .header-button svg{width:22px;height:22px}.game-statusbar{grid-template-columns:1fr .85fr 1.05fr auto}.progress-wrap{max-width:76px}.progress-track{height:7px}.target{background:#3b3e40;border-color:#4a4e50}.target.selected-line{background:#474b4d}.target.line-solved{background:#3b3e40}.target.line-solved .val{color:var(--green-bright)}.corner{background:#3b3e40;border:.5px solid #4a4e50}.combination-row{min-height:32px}.combination-equation{padding:3px 10px}.combination-trash{height:29px}.combinations-panel.open{gap:0}.cell.same-value{background:rgba(22,184,137,.24)}.cell.same-value.selected{background:rgba(39,219,164,.34)}
.cell.rule-error.same-value{background:rgba(239,62,97,.16)}

/* Sum mode + home how-to */
.how-to-play{border:0;background:none;color:var(--green);font-weight:800;font-size:.82rem;margin-top:26px;cursor:pointer}
.home-actions{margin-top:56px;margin-bottom:auto}
.target .val{font-size:clamp(1.05rem,5vw,1.55rem)}
.sum-mode-toggle{font:inherit;font-size:clamp(1.25rem,6vw,1.8rem);font-weight:700;color:var(--green-bright);padding:0;outline:0}
.sum-mode-toggle:active{background:#474b4d}
.combinations-panel .combination-row:has(.combination-equation:only-child){grid-template-columns:1fr}

.how-rules{margin:14px 0 22px;padding-left:24px;text-align:left}.how-rules li{margin:9px 0;line-height:1.35}

/* v3 UX polish */
.home-screen>.brand,.home-screen>.how-to-play,.home-screen>.home-actions{transform:translateY(34px)}
.cell.same-value{background:rgba(39,219,164,.38)}
.cell.same-value.selected{background:rgba(39,219,164,.50)}
.combination-equation{font-size:clamp(1.05rem,4.8vw,1.28rem)}

/* v4 shared bottom navigation + language */
.screen{position:relative;padding-bottom:76px}
.bottom-nav{position:absolute;left:16px;bottom:8px;width:calc(100% - 32px);height:55px;margin:0!important;z-index:20}
.nav-btn{width:33.333%}
.language-screen{flex-direction:column;padding:8px 8px 76px}
.language-content{width:100%;padding:32px 10px;display:grid;gap:10px}
.language-content h1{text-align:center;font-size:1.5rem;margin-bottom:14px}
.language-option{height:52px;border:1px solid var(--green);border-radius:10px;background:transparent;color:var(--green);font-weight:800}
.language-option.active{background:var(--green);color:#fff}

/* v5 language icon */
.nav-btn .globe-icon{fill:none!important;stroke:currentColor!important;stroke-width:1.8!important;stroke-linecap:round!important;stroke-linejoin:round!important}
.settings-menu .setting-label{width:auto;height:auto;border-radius:0;background:none;position:static;flex:1}
.settings-menu .setting-label:after{display:none}


/* v6 gameplay feedback, victory and complete light theme */
.modal label{color:#c5c9c9}.modal select{color:var(--text)}
.cell.line-success-wave,.target.line-success-wave{animation-duration:.9s}
@keyframes lineWave{0%{background:var(--green-bright);box-shadow:inset 0 0 0 1px #81f6d2}100%{background:rgba(22,184,137,.18);box-shadow:none}}
.cell.victory-wave,.target.victory-wave{animation:victoryWave 1.05s ease-out both;animation-delay:var(--victory-delay)}
@keyframes victoryWave{0%{background:var(--grid);box-shadow:none;transform:scale(1)}35%{background:var(--green-bright);box-shadow:inset 0 0 0 2px #9affdc;transform:scale(.94)}100%{background:rgba(22,184,137,.22);box-shadow:none;transform:scale(1)}}
.victory-modal{gap:12px}.victory-stars{display:flex;justify-content:center;gap:9px;font-size:2.65rem;line-height:1;color:#5f6668}.victory-stars .earned{color:var(--green-bright)}.victory-stat{display:flex;align-items:center;justify-content:space-between;padding:10px 4px;border-bottom:1px solid var(--line);color:var(--muted)}.victory-stat strong{color:var(--text);font-size:1.15rem}.victory-record{display:flex;align-items:center;justify-content:center;gap:7px;color:var(--green-bright);font-weight:800;font-size:.78rem;text-align:center}.victory-record[hidden]{display:none}.medal-icon{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8}

body.light-mode{--bg:#e7e6e2;--panel:#d5d4d0;--button:#c5c4c0;--button-hi:#b7b6b2;--grid:#f1f0ec;--line:#b9b9b5;--outer:#777b7c;--text:#202426;--muted:#4e5456;--chalk:#4d5152;color-scheme:light}
body.light-mode .brand i{background:#4b4f50}
body.light-mode .nav-btn{color:#303537}body.light-mode .nav-btn.active{color:#087c60}
body.light-mode .game-titlebar .header-button,body.light-mode .tool-btn{color:#25292b}
body.light-mode .game-statusbar,body.light-mode .timer-button{color:#414749}
body.light-mode .settings-menu{background:#f1f0ec;border-color:#aaaead;box-shadow:0 10px 24px #0003;color:#272b2d}
body.light-mode .settings-menu label>input+span{background:#969b9c}body.light-mode .settings-menu label>input+span:after{background:#fff}
body.light-mode .cell{color:#272a2c}body.light-mode .cell.fixed{color:#087c60}
body.light-mode .cell.peer-selected{background:#d9e2df}body.light-mode .cell.selected{background:#cbd8d4;box-shadow:inset 0 0 0 2px #555b5c}
body.light-mode .cell.line-solved{background:rgba(22,184,137,.13)}
body.light-mode .cell.same-value{background:rgba(39,219,164,.42)}body.light-mode .cell.same-value.selected{background:rgba(39,219,164,.58)}
body.light-mode .target{background:#c9c9c5;border-color:#aaaead;color:#353a3c}body.light-mode .target.selected-line{background:#b8c0bd;box-shadow:inset 0 0 0 2px #626768}body.light-mode .target.line-solved{background:#c9c9c5}body.light-mode .target.line-solved .val{color:#087c60}body.light-mode .corner{background:#c9c9c5;border-color:#aaaead}
body.light-mode .sum-mode-toggle:active{background:#b8c0bd}
body.light-mode .modal-overlay,body.light-mode .pause-overlay{background:rgba(225,224,220,.94)}body.light-mode .modal{border-color:#a5aaa9}body.light-mode .modal label{color:#454b4d}body.light-mode .modal select{border-color:#a5aaa9}
body.light-mode .combination-trash{color:#25292b}body.light-mode .notes-grid span{color:#272a2c}

/* v7: give the longer Spanish victory CTA comfortable horizontal breathing room */
html[lang="es"] #btn-victory-new{font-size:.88rem;letter-spacing:0}

/* v8 portrait gameplay layout: width drives the 8-unit game geometry */
@media (orientation:portrait){
  #game-screen{
    padding:0;
    padding-bottom:0;
    height:100dvh;
    min-height:100dvh;
    overflow:hidden;
    display:none;
  }
  #game-screen.active{
    display:flex;
    flex-direction:column;
  }
  #game-screen .game-header{
    flex:0 0 auto;
    width:100%;
  }
  #game-screen .game-titlebar{
    height:calc(100vw / 8);
    min-height:44px;
    max-height:68px;
    padding:0 5px;
  }
  #game-screen .game-statusbar{
    height:calc(100vw / 8);
    min-height:36px;
    max-height:58px;
    padding:4px 7px;
    font-size:clamp(.68rem,2.7vw,.82rem);
  }
  #game-screen .timer-button{font-size:inherit;height:auto}
  #game-screen .board-container{
    flex:0 0 auto;
    width:100%;
    margin:0;
  }
  #game-screen .game-tools{
    flex:1 1 auto;
    min-height:calc(3 * (100vw / 8));
    margin:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  #game-screen .tool-row{
    flex:0 0 calc(100vw / 8);
    height:calc(100vw / 8);
    min-height:44px;
    padding:3px 4px;
  }
  #game-screen .combinations-panel{
    flex:1 1 auto;
    min-height:calc(2 * (100vw / 8));
    margin-top:0;
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
  }
  #game-screen .combinations-panel.open{
    display:grid;
  }
  #game-screen .settings-menu{top:calc(100vw / 8);max-height:calc(100dvh - (100vw / 8));overflow-y:auto}
}

/* v9 portrait: use the full viewport width and compact fixed rows */
@media (orientation:portrait){
  .app-shell{max-width:none;width:100%;padding:0}
  #game-screen .game-titlebar{
    height:calc(100vw / 8);
  }
  #game-screen .game-statusbar{
    height:calc(.5 * (100vw / 8));
    min-height:26px;
    max-height:40px;
    padding:2px 7px;
  }
  #game-screen .tool-row{
    flex-basis:calc(.75 * (100vw / 8));
    height:calc(.75 * (100vw / 8));
    min-height:42px;
  }
  #game-screen .game-tools{
    min-height:0;
  }
  #game-screen .combinations-panel{
    min-height:64px;
  }
}

/* v10 portrait: width is maximized only while preserving two full rows below the controls */
@media (orientation:portrait){
  #game-screen{
    --portrait-unit:min(12.5vw, calc(100dvh / 12.25));
    --portrait-width:calc(8 * var(--portrait-unit));
    align-items:center;
  }
  #game-screen .game-header,
  #game-screen .board-container,
  #game-screen .game-tools{
    width:var(--portrait-width);
    max-width:var(--portrait-width);
    margin-left:auto;
    margin-right:auto;
  }
  #game-screen .game-titlebar{
    height:var(--portrait-unit);
    min-height:0;
    max-height:none;
  }
  #game-screen .game-statusbar{
    height:calc(.5 * var(--portrait-unit));
    min-height:0;
    max-height:none;
  }
  #game-screen .tool-row{
    flex:0 0 calc(.75 * var(--portrait-unit));
    height:calc(.75 * var(--portrait-unit));
    min-height:0;
  }
  #game-screen .game-tools{
    flex:1 1 auto;
    min-height:calc(2.75 * var(--portrait-unit));
  }
  #game-screen .combinations-panel{
    flex:1 1 auto;
    min-height:calc(2 * var(--portrait-unit));
  }
  #game-screen .settings-menu{
    top:var(--portrait-unit);
    max-height:calc(100dvh - var(--portrait-unit));
  }
}

/* v11 portrait modular frame: 8 columns across the complete gameplay area */
.combination-hint{padding:10px 12px;color:var(--muted);font-size:clamp(.82rem,3.2vw,1rem);line-height:1.35}
@media (orientation:portrait){
  #game-screen{
    --portrait-unit:min(12.5vw, calc(100dvh / 12.5));
    --portrait-width:calc(8 * var(--portrait-unit));
    align-items:center;
    justify-content:flex-start;
    padding:0;
  }
  #game-screen .game-frame{
    width:var(--portrait-width);
    max-width:var(--portrait-width);
    border:calc(var(--portrait-unit) * .08) solid var(--outer);
    background:var(--panel);
    overflow:visible;
  }
  #game-screen .game-header,
  #game-screen .board-container,
  #game-screen .game-tools{width:100%;max-width:none;margin:0}
  #game-screen .game-titlebar{
    height:var(--portrait-unit);padding:calc(var(--portrait-unit)*.06);gap:calc(var(--portrait-unit)*.04);
    grid-template-columns:var(--portrait-unit) 6fr var(--portrait-unit);
  }
  #game-screen .game-titlebar .header-button{
    width:100%;height:100%;border-radius:calc(var(--portrait-unit)*.16);padding:0;
  }
  #game-screen .game-titlebar .brand{
    width:100%;height:100%;background:var(--button);border-radius:calc(var(--portrait-unit)*.16);
    font-size:calc(var(--portrait-unit)*.48);
  }
  #game-screen .game-statusbar{
    height:calc(.5 * var(--portrait-unit));padding:0 calc(var(--portrait-unit)*.08);gap:0;
    grid-template-columns:repeat(4,2fr);font-size:calc(var(--portrait-unit)*.14);
    border-top:1px solid var(--outer);border-bottom:1px solid var(--outer);
  }
  #game-screen .game-statusbar>*:nth-child(1){justify-self:stretch;text-align:left}
  #game-screen .game-statusbar>*:nth-child(2),#game-screen .game-statusbar>*:nth-child(3){justify-self:center;text-align:center}
  #game-screen .game-statusbar>*:nth-child(4){justify-self:end;text-align:right}
  #game-screen .progress-wrap{max-width:none;width:100%;justify-content:flex-start}
  #game-screen .progress-track{max-width:calc(var(--portrait-unit)*1.25)}
  #game-screen .board-container{border:0;margin:0}
  #game-screen .tool-row{
    height:var(--portrait-unit);min-height:0;flex:0 0 var(--portrait-unit);
    grid-template-columns:1fr 2fr 2fr 2fr 1fr;gap:calc(var(--portrait-unit)*.04);
    padding:calc(var(--portrait-unit)*.06);
    border-top:1px solid var(--outer);
  }
  #game-screen .number-btn,#game-screen .tool-btn{border-radius:calc(var(--portrait-unit)*.13)}
  #game-screen .number-btn{font-size:calc(var(--portrait-unit)*.48)}
  #game-screen .tool-btn svg{width:calc(var(--portrait-unit)*.38);height:calc(var(--portrait-unit)*.38)}
  #game-screen .game-tools{display:flex;flex-direction:column;min-height:0;flex:0 0 auto;overflow:visible}
  #game-screen .combinations-panel,
  #game-screen .combinations-panel.open{
    display:grid;align-content:start;flex:none;
    height:clamp(calc(2 * var(--portrait-unit)), calc(100dvh - 10.5 * var(--portrait-unit)), calc(4 * var(--portrait-unit)));
    min-height:calc(2 * var(--portrait-unit));max-height:calc(4 * var(--portrait-unit));
    margin:0;border:0;border-top:1px solid var(--outer);padding:calc(var(--portrait-unit)*.08);
    overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  }
  #game-screen .settings-menu{top:var(--portrait-unit);max-height:calc(100dvh - var(--portrait-unit))}
}

/* v15 universal modular gameplay frame.
   One geometry in every orientation. The complete frame (including its gray
   rim) is sized against the viewport, so it never creates page scrolling. */
body.game-active{overflow:hidden;height:100dvh;background:var(--bg)}
body.game-active .app-shell{min-height:0;height:100dvh}
#game-screen{
  /* 8 units wide; 12.5 units high at the two-row minimum.
     The .08u rim exists on both sides, hence 8.16 / 12.66. */
  --game-unit:min(calc(100vw / 8.16), calc(100dvh / 12.66));
  --game-rim:calc(var(--game-unit) * .08);
  --game-width:calc(8 * var(--game-unit) + 2 * var(--game-rim));
  width:100vw;max-width:none;
  margin-left:calc((100% - 100vw) / 2);
  padding:0;min-height:0;height:100dvh;
  overflow:hidden;
  align-items:center;justify-content:flex-start;
  background:var(--bg);
}
#game-screen.active{display:flex;flex-direction:column}
#game-screen .game-frame{
  width:var(--game-width);max-width:var(--game-width);
  padding:var(--game-rim);
  border:0;
  background:var(--outer);
  overflow:hidden;
  flex:0 0 auto;
}
#game-screen .game-header,
#game-screen .board-container,
#game-screen .game-tools{width:calc(8 * var(--game-unit));max-width:none;margin:0}
#game-screen .game-titlebar{
  height:var(--game-unit);min-height:0;max-height:none;
  padding:calc(var(--game-unit)*.06);gap:calc(var(--game-unit)*.04);
  grid-template-columns:var(--game-unit) 6fr var(--game-unit);
  background:var(--outer);
}
#game-screen .game-titlebar .header-button{width:100%;height:100%;border-radius:calc(var(--game-unit)*.16);padding:0}
#game-screen .game-titlebar .brand{width:100%;height:100%;background:var(--button);border-radius:calc(var(--game-unit)*.16);font-size:calc(var(--game-unit)*.48)}
#game-screen .game-statusbar{
  height:calc(.5 * var(--game-unit));min-height:0;max-height:none;
  padding:0 calc(var(--game-unit)*.08);gap:0;
  grid-template-columns:repeat(4,2fr);font-size:calc(var(--game-unit)*.14);
  border-top:1px solid var(--outer);border-bottom:1px solid var(--outer);
}
#game-screen .game-statusbar>*:nth-child(1){justify-self:stretch;text-align:left}
#game-screen .game-statusbar>*:nth-child(2),#game-screen .game-statusbar>*:nth-child(3){justify-self:center;text-align:center}
#game-screen .game-statusbar>*:nth-child(4){justify-self:end;text-align:right}
#game-screen .progress-wrap{max-width:none;width:100%;justify-content:flex-start}
#game-screen .progress-track{max-width:calc(var(--game-unit)*1.25)}
#game-screen .timer-button{font-size:inherit;height:auto}
#game-screen .board-container{border:0}
#game-screen .tool-row{
  height:var(--game-unit);min-height:0;flex:0 0 var(--game-unit);
  grid-template-columns:1fr 2fr 2fr 2fr 1fr;gap:calc(var(--game-unit)*.04);
  padding:calc(var(--game-unit)*.06);border-top:1px solid var(--outer);
  background:var(--outer);
}
#game-screen .number-btn,#game-screen .tool-btn{border-radius:calc(var(--game-unit)*.13)}
#game-screen .number-btn{font-size:calc(var(--game-unit)*.48)}
#game-screen .tool-btn svg{width:calc(var(--game-unit)*.38);height:calc(var(--game-unit)*.38)}
#game-screen .game-tools{display:flex;flex-direction:column;min-height:0;flex:0 0 auto;overflow:hidden}
#game-screen .combinations-panel,
#game-screen .combinations-panel.open{
  display:grid;align-content:start;flex:none;
  /* Remaining viewport height, clamped to 2–4 modular rows. Rim is included. */
  height:clamp(calc(2 * var(--game-unit)), calc(100dvh - 10.5 * var(--game-unit) - 2 * var(--game-rim)), calc(4 * var(--game-unit)));
  min-height:calc(2 * var(--game-unit));max-height:calc(4 * var(--game-unit));
  margin:0;border:0;border-top:1px solid var(--outer);padding:calc(var(--game-unit)*.08);
  overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
}
#game-screen .settings-menu{top:var(--game-unit);max-height:calc(100dvh - var(--game-unit));overflow-y:auto}

/* v16: viewport frame geometry fix */
body.game-active{
  width:100vw;
  height:100dvh;
  min-height:0;
  margin:0;
  padding:0;
  overflow:hidden;
  background:var(--bg);
}
body.game-active .app-shell{
  width:100vw;
  max-width:none;
  height:100dvh;
  min-height:0;
  margin:0;
  padding:0 !important;
}
#game-screen{
  position:fixed;
  inset:0;
  width:100vw;
  height:100dvh;
  min-height:0;
  margin:0;
  padding:0;
  overflow:hidden;
  align-items:center;
  justify-content:flex-start;
  background:var(--bg);
}
#game-screen .game-frame{
  margin:0;
  box-sizing:border-box;
}
\n\n/* v17: visual combination tiles + non-selectable game UI */
#game-screen,
#game-screen *{
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
}
#game-screen .combination-row{
  grid-template-columns:1fr auto;
  gap:calc(var(--game-unit)*.07);
  min-height:calc(var(--game-unit)*.46);
  padding:calc(var(--game-unit)*.035) calc(var(--game-unit)*.055);
}
#game-screen .combination-tiles{
  display:flex;
  align-items:center;
  flex-wrap:nowrap;
  gap:calc(var(--game-unit)*.055);
  min-width:0;
}
#game-screen .combination-tile{
  width:calc(var(--game-unit)*.40);
  height:calc(var(--game-unit)*.40);
  flex:0 0 calc(var(--game-unit)*.40);
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:calc(var(--game-unit)*.07);
  color:#fff;
  font-size:calc(var(--game-unit)*.22);
  line-height:1;
  font-weight:800;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);
}
#game-screen .combination-tile.value-3{background:#b92845}
#game-screen .combination-tile.value-2{background:#2866b9}
#game-screen .combination-tile.value-1{background:#0b7f60}
#game-screen .combination-trash{
  width:calc(var(--game-unit)*.48);
  height:calc(var(--game-unit)*.40);
  align-self:center;
}
#game-screen .combination-trash svg{width:calc(var(--game-unit)*.23);height:calc(var(--game-unit)*.23)}
#game-screen .combination-row.manual-discard .combination-tiles,
#game-screen .combination-row.auto-discard .combination-tiles{opacity:.38}
#game-screen .combination-row.manual-discard .combination-tile,
#game-screen .combination-row.auto-discard .combination-tile{filter:saturate(.35)}
body.light-mode #game-screen .combination-tile{color:#fff}

/* v18: combination tiles sized for three visible alternatives in the 2-row panel */
#game-screen .combinations-panel.open{
  row-gap:calc(var(--game-unit)*.035);
}
#game-screen .combination-row{
  min-height:calc(var(--game-unit)*.54);
  padding:calc(var(--game-unit)*.01) calc(var(--game-unit)*.055);
}
#game-screen .combination-tiles{
  gap:calc(var(--game-unit)*.095);
}
#game-screen .combination-tile{
  width:calc(var(--game-unit)*.52);
  height:calc(var(--game-unit)*.52);
  flex-basis:calc(var(--game-unit)*.52);
  border-radius:calc(var(--game-unit)*.085);
  font-size:calc(var(--game-unit)*.27);
}
#game-screen .combination-trash{
  width:calc(var(--game-unit)*.52);
  height:calc(var(--game-unit)*.52);
}
#game-screen .combination-trash svg{
  width:calc(var(--game-unit)*.25);
  height:calc(var(--game-unit)*.25);
}

/* v19: scale combination rows with the actual 2–4 row status-panel height.
   At the minimum panel height, three alternatives fit comfortably.
   As the panel grows, tiles/spacing grow continuously; at the maximum,
   four alternatives fit across the full panel height. */
#game-screen .combinations-panel,
#game-screen .combinations-panel.open{
  container-type:size;
}
#game-screen .combinations-panel.open{
  row-gap:clamp(calc(var(--game-unit)*.035), 1.1cqh, calc(var(--game-unit)*.07));
}
#game-screen .combination-row{
  min-height:clamp(calc(var(--game-unit)*.54), calc(18cqh + var(--game-unit)*.18), calc(var(--game-unit)*.92));
  padding:clamp(calc(var(--game-unit)*.01), .8cqh, calc(var(--game-unit)*.025)) calc(var(--game-unit)*.055);
}
#game-screen .combination-tiles{
  gap:clamp(calc(var(--game-unit)*.095), calc(2.4cqh + var(--game-unit)*.05), calc(var(--game-unit)*.15));
}
#game-screen .combination-tile{
  width:clamp(calc(var(--game-unit)*.52), calc(18cqh + var(--game-unit)*.16), calc(var(--game-unit)*.88));
  height:clamp(calc(var(--game-unit)*.52), calc(18cqh + var(--game-unit)*.16), calc(var(--game-unit)*.88));
  flex-basis:clamp(calc(var(--game-unit)*.52), calc(18cqh + var(--game-unit)*.16), calc(var(--game-unit)*.88));
  border-radius:clamp(calc(var(--game-unit)*.085), 2.2cqh, calc(var(--game-unit)*.13));
  font-size:clamp(calc(var(--game-unit)*.27), calc(9cqh + var(--game-unit)*.09), calc(var(--game-unit)*.45));
}
#game-screen .combination-trash{
  width:clamp(calc(var(--game-unit)*.52), calc(18cqh + var(--game-unit)*.16), calc(var(--game-unit)*.88));
  height:clamp(calc(var(--game-unit)*.52), calc(18cqh + var(--game-unit)*.16), calc(var(--game-unit)*.88));
}
#game-screen .combination-trash svg{
  width:clamp(calc(var(--game-unit)*.25), calc(9cqh + var(--game-unit)*.07), calc(var(--game-unit)*.43));
  height:clamp(calc(var(--game-unit)*.25), calc(9cqh + var(--game-unit)*.07), calc(var(--game-unit)*.43));
}


/* v20: unified 3-2-1 visual language — title, keys, notes and Delta tiles */
#game-screen .number-btn[data-val="3"]{color:var(--red)}
#game-screen .number-btn[data-val="2"]{color:var(--blue)}
#game-screen .number-btn[data-val="1"]{color:var(--green)}
#game-screen .notes-grid .note-value-3{color:var(--red)}
#game-screen .notes-grid .note-value-2{color:var(--blue)}
#game-screen .notes-grid .note-value-1{color:var(--green)}
body.light-mode #game-screen .notes-grid .note-value-3{color:var(--red)}
body.light-mode #game-screen .notes-grid .note-value-2{color:var(--blue)}
body.light-mode #game-screen .notes-grid .note-value-1{color:var(--green)}

/* v21: mobile UX pass — status readability, green focus, info-before-actions */
#game-screen{
  --game-unit:min(calc(100vw / 8.16), calc(100dvh / 12.76));
}
#game-screen .game-statusbar{
  height:calc(.6 * var(--game-unit));
  font-size:calc(var(--game-unit)*.18);
  font-weight:600;
}
#game-screen .progress-wrap{gap:calc(var(--game-unit)*.07)}
#game-screen .progress-track{max-width:calc(var(--game-unit)*1.62);height:calc(var(--game-unit)*.12)}
#game-screen .progress-wrap small{font-size:calc(var(--game-unit)*.18);font-weight:800}
#game-screen .timer-button{font-size:calc(var(--game-unit)*.18);font-weight:600}
#game-screen .cell.selected{box-shadow:inset 0 0 0 2px var(--green-bright)}
#game-screen .target.selected-line{box-shadow:inset 0 0 0 2px var(--green-bright)}
body.light-mode #game-screen .cell.selected,body.light-mode #game-screen .target.selected-line{box-shadow:inset 0 0 0 2px #087c60}
#game-screen .combinations-panel,#game-screen .combinations-panel.open{
  height:clamp(calc(2 * var(--game-unit)), calc(100dvh - 10.6 * var(--game-unit) - 2 * var(--game-rim)), calc(4 * var(--game-unit)));
  border-top:1px solid var(--outer);
  border-bottom:1px solid var(--outer);
}
#game-screen .tool-row{border-top:0}

/* v22: status typography + balanced top rim */
#game-screen .game-frame{
  padding:calc(var(--game-unit)*.02) var(--game-rim) var(--game-rim);
}
#game-screen .game-statusbar{
  font-size:calc(var(--game-unit)*.28);
}
#game-screen .progress-wrap small{
  font-size:calc(var(--game-unit)*.28);
}
#game-screen .timer-button{
  font-size:calc(var(--game-unit)*.28);
}
#game-screen .timer-button svg{
  width:calc(var(--game-unit)*.30);
  height:calc(var(--game-unit)*.30);
}
#game-screen .game-statusbar>*:nth-child(3){
  color:var(--red);
}
#game-screen #error-count,#game-screen #error-limit{
  color:inherit;
}


/* Debug overlay: enabled only by debug.html via window.DEBUG_MODE. */
#debug-toggle{position:fixed;right:10px;bottom:10px;z-index:10000;background:#20262b;color:#9cffb0;border:1px solid #6c7a82;border-radius:8px;padding:8px 11px;font:700 12px/1 system-ui;letter-spacing:.08em}
.debug-panel{display:none;position:fixed;z-index:10001;inset:12px;max-width:920px;margin:auto;background:#171b1e;color:#edf2f4;border:1px solid #657078;border-radius:12px;padding:14px;overflow:auto;font:13px/1.35 system-ui;box-shadow:0 12px 40px #0009}.debug-panel.open{display:block}.debug-head{display:flex;align-items:center;justify-content:space-between;font-size:16px}.debug-head button{font-size:24px;background:transparent;color:inherit;border:0}.debug-summary{margin:10px 0;padding:10px;background:#213027;color:#9cffb0;border-radius:8px;font-weight:800}.debug-summary.has-errors{background:#3a2020;color:#ff9c9c}.debug-panel h3{margin:14px 0 6px;font-size:13px;color:#aeb9bf;text-transform:uppercase;letter-spacing:.05em}.debug-files>div,.debug-current{display:flex;justify-content:space-between;gap:12px;padding:5px 0;border-bottom:1px solid #30373c}.debug-files pre,.debug-panel pre{white-space:pre-wrap;word-break:break-all;background:#101315;padding:8px;border-radius:6px}.debug-table-wrap{overflow-x:auto}.debug-panel table{width:100%;border-collapse:collapse;min-width:600px}.debug-panel th,.debug-panel td{border:1px solid #394147;padding:6px;text-align:center}.debug-panel td b{display:block;font-size:15px}.debug-panel td small{display:block;color:#aeb9bf;font-size:10px;margin-top:2px}.debug-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.debug-actions button{background:#293137;color:#edf2f4;border:1px solid #59656d;border-radius:7px;padding:8px 10px}.debug-actions button:nth-last-child(-n+2){border-color:#8a5555;color:#ffb0b0}

/* v25: Rush mode */
.rush-rules{margin:0;padding-left:22px;color:var(--text);line-height:1.45}.rush-rules li{margin:9px 0}.rush-info-modal h2,.rush-result-modal h2{color:var(--green-bright)}
.rush-countdown{position:fixed;inset:0;z-index:400;display:flex;align-items:center;justify-content:center;background:rgba(18,21,23,.96);opacity:0;pointer-events:none;transition:opacity .15s}.rush-countdown.open{opacity:1;pointer-events:auto}.rush-countdown strong{font-size:clamp(5rem,28vw,11rem);color:var(--green-bright);line-height:1}
.settings-menu label.setting-locked{opacity:.48}.settings-menu label.setting-locked input+span{cursor:not-allowed}.sum-mode-toggle:disabled{opacity:.8;color:var(--green-bright)}
body.light-mode .rush-countdown{background:rgba(225,224,220,.96)}
body.rush-active #btn-pause svg{display:none}body.rush-active #btn-pause{cursor:default}


/* v26: Rush polish — same minimal home treatment, clock arena, combo feedback */
.rush-home-btn{margin-top:0!important;border-color:var(--green)!important;color:var(--green)!important;background:transparent!important}
#game-screen .combinations-panel.rush-clock-panel{overflow:hidden;align-content:stretch;justify-content:stretch;padding:0}
#game-screen .rush-clock-wrap{position:relative;width:100%;height:100%;min-height:100%;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;overflow:hidden;padding-inline:clamp(10px,3%,22px)}
#game-screen .rush-big-time{grid-column:2;grid-row:1;justify-self:center;font-size:clamp(calc(var(--game-unit)*.78),18cqh,calc(var(--game-unit)*1.5));line-height:.92;font-weight:900;letter-spacing:.025em;color:var(--green-bright);font-variant-numeric:tabular-nums;transition:color .18s,transform .22s}
#game-screen .rush-big-time.danger{color:var(--red);animation:rush-danger-pulse .72s ease-in-out infinite}
#game-screen .rush-big-time.bonus-hit{transform:scale(1.10)}
#game-screen .rush-score-badge{grid-column:1;grid-row:1;justify-self:start;display:grid;place-items:center;min-width:clamp(38px,10cqh,58px);height:clamp(38px,10cqh,58px);padding:0 .22em;border-radius:clamp(8px,2.2cqh,14px);background:var(--green-bright);color:#fff;font-size:clamp(1.15rem,7.5cqh,2rem);line-height:1;font-weight:900;font-variant-numeric:tabular-nums}#game-screen .rush-combo{grid-column:3;grid-row:1;justify-self:end;min-height:1em;font-size:clamp(.68rem,7cqh,1rem);font-weight:900;letter-spacing:.08em;color:var(--green-bright);white-space:nowrap}
#game-screen .rush-panel-bonus{position:absolute;left:50%;top:50%;z-index:3;opacity:0;transform:translate(-50%,-50%) scale(1);font-size:clamp(calc(var(--game-unit)*1.25),42cqh,calc(var(--game-unit)*2.35));line-height:.9;font-weight:900;color:var(--green-bright);pointer-events:none;text-shadow:0 0 20px rgba(24,215,161,.42)}
#game-screen .rush-panel-bonus.show{animation:rush-bonus-flight 1.55s cubic-bezier(.2,.72,.18,1) forwards}
@keyframes rush-bonus-flight{0%{opacity:0;transform:translate(-50%,-50%) scale(.72)}10%{opacity:1;transform:translate(-50%,-50%) scale(1.08)}18%,58%{opacity:1;transform:translate(-50%,-50%) scale(1)}82%{opacity:1;transform:translate(-50%,-50%) scale(.48)}100%{opacity:0;transform:translate(-50%,-50%) scale(.18)}}
@keyframes rush-danger-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.62;transform:scale(1.035)}}
.rush-grid-bonus{position:fixed;z-index:450;opacity:0;transform:translate(-50%,-50%) scale(.2);font-size:118px;line-height:1;font-weight:900;color:var(--green-bright);pointer-events:none;text-shadow:0 0 26px rgba(24,215,161,.55);will-change:transform,opacity}.rush-grid-bonus.show{animation:rush-grid-bonus-flight 1s forwards}.rush-grid-combo{white-space:nowrap}@keyframes rush-grid-bonus-flight{0%{opacity:0;transform:translate(-50%,-50%) scale(.2);animation-timing-function:cubic-bezier(.2,1.5,.45,1)}50%{opacity:1;transform:translate(-50%,-50%) scale(2);animation-timing-function:cubic-bezier(.4,0,.2,1)}100%{opacity:.15;transform:translate(calc(-50% + var(--rush-bonus-dx)),calc(-50% + var(--rush-bonus-dy))) scale(.2)}}
@media (prefers-reduced-motion:reduce){#game-screen .rush-big-time.danger{animation:none}.rush-grid-bonus.show{animation-duration:.8s}}

/* v36: Rush bonus/combo flights use the approved LAB Web Animations implementation. */
.rush-grid-bonus{position:fixed;z-index:450;pointer-events:none;white-space:nowrap;line-height:1;font-weight:900;color:var(--green-bright);text-shadow:0 0 26px rgba(24,215,161,.55);will-change:transform,opacity}.rush-grid-bonus.show{animation:none}

/* v38: startup/menu choreography + Rush feedback */
.startup-loader{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:var(--bg);opacity:1;transition:opacity .35s ease}.startup-loader span{width:42px;height:42px;border:3px solid rgba(39,219,164,.18);border-top-color:var(--green-bright);border-radius:50%;animation:startup-spin .72s linear infinite}.startup-loader.done{opacity:0;pointer-events:none}@keyframes startup-spin{to{transform:rotate(360deg)}}
.app-shell.startup-pending{visibility:hidden}.app-shell.startup-ready{visibility:visible}
/* All three menu screens share the same logo anchor in the first third. */
#home-screen,#language-screen,#profile-screen{position:relative;align-items:center;padding:0 24px 76px;overflow:hidden}
#home-screen>.brand,#language-screen>.simple-header,#profile-screen>.simple-header{position:absolute;top:22vh;left:0;width:100%;height:auto;padding:0;margin:0;transform:none}
#language-screen>.simple-header,#profile-screen>.simple-header{display:flex;justify-content:center}
#language-screen>.simple-header>span,#profile-screen>.simple-header>span{display:none}
#home-screen>.how-to-play{position:absolute;top:32vh;margin:0;transform:none}
#home-screen>.home-actions{position:absolute;top:43vh;width:min(250px,75vw);margin:0;transform:none}
#language-screen>.language-content{position:absolute;top:38vh;width:min(250px,75vw);padding:0;display:grid;gap:10px}
#profile-screen>.profile-content{position:absolute;top:34vh;width:min(420px,calc(100% - 48px));padding:0;max-height:calc(100dvh - 34vh - 84px);overflow:auto}
#home-screen.menu-enter>.brand,#language-screen.menu-enter>.simple-header,#profile-screen.menu-enter>.simple-header{animation:menu-logo-drop .48s cubic-bezier(.2,.85,.25,1) both}
#home-screen.menu-enter>.how-to-play,#home-screen.menu-enter>.home-actions,#language-screen.menu-enter>.language-content,#profile-screen.menu-enter>.profile-content{animation:menu-content-rise .5s .46s cubic-bezier(.2,.8,.25,1) both}
@keyframes menu-logo-drop{from{opacity:0;transform:translateY(-90px)}to{opacity:1;transform:translateY(0)}}
@keyframes menu-content-rise{from{opacity:0;transform:translateY(70px)}to{opacity:1;transform:translateY(0)}}
/* Bottom nav never participates in screen transitions; only the first app reveal fades it in. */
.app-shell.startup-ready .screen .bottom-nav{animation:none;opacity:1}.app-shell.startup-ready .screen.first-menu-enter .bottom-nav{animation:startup-nav-in .55s 1.02s ease both}@keyframes startup-nav-in{from{opacity:0}to{opacity:1}}
.language-option{width:100%}
.rush-error-flight{position:fixed;z-index:460;pointer-events:none;white-space:nowrap;line-height:1;font-size:118px;font-weight:900;color:var(--red);text-shadow:0 0 26px rgba(239,62,97,.45);will-change:transform,opacity}
@media(max-width:520px){.rush-error-flight{font-size:22vw}}
@media(prefers-reduced-motion:reduce){#home-screen.menu-enter>.brand,#language-screen.menu-enter>.simple-header,#profile-screen.menu-enter>.simple-header,#home-screen.menu-enter>.how-to-play,#home-screen.menu-enter>.home-actions,#language-screen.menu-enter>.language-content,#profile-screen.menu-enter>.profile-content{animation-duration:.01ms;animation-delay:0ms}}

/* v39: responsive menu geometry + Rush feedback tuning */
.app-shell{container-type:inline-size}
#home-screen>.brand,
#language-screen>.simple-header,
#profile-screen>.simple-header{
  left:15%;
  width:70%;
}
#home-screen>.brand,
#language-screen>.simple-header>.brand,
#profile-screen>.simple-header>.brand{
  font-size:13cqw;
  gap:0;
  justify-content:space-between;
}
#language-screen>.simple-header>.brand,
#profile-screen>.simple-header>.brand{width:100%}
#home-screen>.home-actions,
#language-screen>.language-content{
  width:70%;
  left:15%;
}

/* v41: menu brand geometry + proportional home composition */
/* Home brand itself is 70% wide. Language/Profile use a 70%-wide header whose brand fills it. */
#home-screen>.brand{left:15%;width:70%;}
#language-screen>.simple-header,#profile-screen>.simple-header{left:15%;width:70%;}
#language-screen>.simple-header>.brand,#profile-screen>.simple-header>.brand{width:100%;}
/* COMO JUGAR follows the brand scale/position rather than a fixed pixel gap. */
#home-screen>.how-to-play{
  top:calc(22vh + 18cqw);
  font-size:4cqw;
  line-height:1;
}
/* IMPORTANT: the in-game HUD brand intentionally remains the original v39 component. */

/* v43: Rush arena — fixed 30/40/30 score / clock / combo composition. */
#game-screen .rush-clock-wrap{
  grid-template-columns:30% 40% 30%;
  padding-inline:0;
  column-gap:0;
}
#game-screen .rush-score-badge{
  grid-column:1;
  justify-self:center;
  min-width:clamp(44px,11cqh,64px);
  height:clamp(44px,11cqh,64px);
  padding:0 .28em;
  border-radius:clamp(9px,2.4cqh,14px);
  background:#0b7f60;
  color:#fff;
  font-size:clamp(1.35rem,8.5cqh,2.2rem);
}
#game-screen .rush-big-time{
  grid-column:2;
  justify-self:center;
  max-width:100%;
  font-size:clamp(calc(var(--game-unit)*.78),18cqh,calc(var(--game-unit)*1.5));
  white-space:nowrap;
}
#game-screen .rush-combo{
  grid-column:3;
  justify-self:center;
  max-width:calc(100% - 12px);
  font-size:clamp(.82rem,8cqh,1.22rem);
  letter-spacing:.055em;
  text-align:center;
}

/* v44: first-run interactive tutorial */
.tutorial-link{border:0;background:none;color:var(--green-bright);font-weight:900;font-size:.82rem;letter-spacing:.06em;justify-self:center;margin:-5px 0 2px;padding:7px 12px;cursor:pointer}
.tutorial-mini-brand{display:flex;align-items:center;justify-content:center;gap:10px;font-size:1.65rem;font-weight:900}.tutorial-mini-brand i{width:8px;height:8px;border-radius:50%;background:#d8d8d8}.tutorial-mini-brand .three{color:var(--red)}.tutorial-mini-brand .two{color:var(--blue)}.tutorial-mini-brand .one{color:var(--green-bright)}
.tutorial-overlay{position:fixed;inset:0;z-index:520;background:var(--bg);display:none;align-items:center;justify-content:center;padding:max(12px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom));overflow:auto}.tutorial-overlay.open{display:flex}.tutorial-shell{width:min(460px,100%);min-height:min(760px,calc(100dvh - 24px));display:flex;flex-direction:column;background:var(--panel);border:1px solid #3a4541;border-radius:18px;padding:14px 16px 16px;box-shadow:0 20px 70px #0008}.tutorial-head{display:grid;grid-template-columns:42px 1fr 42px;align-items:center}.tutorial-head .tutorial-mini-brand{grid-column:2}.tutorial-close{grid-column:3;border:0;background:transparent;color:var(--muted);font-size:2rem;line-height:1}.tutorial-progress{height:4px;background:#29312e;border-radius:99px;overflow:hidden;margin:12px 0 16px}.tutorial-progress span{display:block;height:100%;width:0;background:var(--green-bright);transition:width .3s ease}.tutorial-copy{text-align:center;min-height:126px}.tutorial-copy small{color:var(--green-bright);font-weight:900;font-size:.68rem;letter-spacing:.12em}.tutorial-copy h2{font-size:1.25rem;margin:8px 0 7px}.tutorial-copy p{margin:0 auto;color:var(--muted);font-size:.9rem;line-height:1.4;max-width:390px}.tutorial-demo{margin-top:8px}.tutorial-grid{width:min(330px,78vw);aspect-ratio:1;margin:0 auto;display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(5,1fr);border:1px solid var(--line);background:var(--grid)}.tutorial-cell,.tutorial-target{display:flex;align-items:center;justify-content:center;border:.5px solid var(--line);font-weight:850;font-size:clamp(1.1rem,6vw,1.55rem)}.tutorial-cell{background:var(--grid);color:var(--green-bright)}.tutorial-cell.blank{color:transparent}.tutorial-cell.focus{color:var(--text);background:#39413e;box-shadow:inset 0 0 0 2px var(--green-bright);animation:tutorial-focus 1.15s ease-in-out infinite}.tutorial-cell.rule-ok{background:rgba(22,184,137,.16)}.tutorial-target{background:#3b3e40;color:#eee}.tutorial-target.focus{box-shadow:inset 0 0 0 2px var(--green-bright);color:var(--green-bright)}.tutorial-corner{color:var(--green-bright);font-size:1.35rem}.tutorial-help{min-height:54px;margin:10px auto 8px;width:min(330px,78vw);display:flex;align-items:center;justify-content:center;text-align:center;color:var(--green-bright);font-weight:800;font-size:.82rem}.tutorial-combos{display:flex;gap:7px;align-items:center;justify-content:center;flex-wrap:wrap}.tutorial-combo-chip{display:flex;gap:3px;padding:6px 9px;background:#202725;border-radius:8px}.tutorial-combo-chip b:nth-child(1){color:var(--red)}.tutorial-combo-chip b:nth-child(2){color:var(--blue)}.tutorial-combo-chip b:nth-child(3){color:var(--green-bright)}.tutorial-delta{font-size:1rem}.tutorial-delta strong{display:inline-block;margin-left:8px;font-size:1.5rem}.tutorial-numbers{width:min(330px,78vw);margin:0 auto;display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.tutorial-numbers button{height:48px;border:0;border-radius:9px;background:var(--button);font-size:1.45rem;font-weight:900}.tutorial-numbers button:nth-child(1){color:var(--red)}.tutorial-numbers button:nth-child(2){color:var(--blue)}.tutorial-numbers button:nth-child(3){color:var(--green-bright)}.tutorial-numbers button.expected{box-shadow:inset 0 0 0 2px var(--green-bright);animation:tutorial-button 1s ease-in-out infinite}.tutorial-numbers.locked{opacity:.35;pointer-events:none}.tutorial-next{width:min(330px,78vw);min-height:46px;margin:auto auto 0;align-self:center;border-radius:10px}.tutorial-next[hidden]{display:none}@keyframes tutorial-focus{50%{box-shadow:inset 0 0 0 3px var(--green-bright),0 0 18px #18d7a144}}@keyframes tutorial-button{50%{transform:scale(1.04)}}
@media(max-height:700px){.tutorial-shell{min-height:calc(100dvh - 16px);padding:9px 12px}.tutorial-copy{min-height:98px}.tutorial-copy p{font-size:.8rem}.tutorial-grid{width:min(250px,55vh)}.tutorial-help,.tutorial-numbers,.tutorial-next{width:min(300px,75vw)}.tutorial-help{min-height:38px;margin:5px auto}.tutorial-numbers button{height:40px}}
/* v45 tutorial refinements */
.tutorial-cell.sum-row{background:rgba(22,184,137,.12);box-shadow:inset 0 2px 0 rgba(31,255,169,.32),inset 0 -2px 0 rgba(31,255,169,.32)}
button.tutorial-target{font:inherit;cursor:default;padding:0}
button.tutorial-target.tutorial-action{cursor:pointer;animation:tutorial-button 1s ease-in-out infinite}
.tutorial-inline-action{min-width:150px;min-height:40px;border:1px solid var(--green-bright);border-radius:9px;background:#202725;color:var(--green-bright);font-weight:900;letter-spacing:.04em;padding:8px 14px;cursor:pointer;animation:tutorial-button 1s ease-in-out infinite}

/* v49 profile + interaction polish */
.screen,.modal-overlay,.tutorial-overlay{-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
#profile-screen>.profile-content{scrollbar-width:none;-ms-overflow-style:none;padding-bottom:34px}
#profile-screen>.profile-content::-webkit-scrollbar{display:none}
.profile-content h1{margin-bottom:16px}.profile-section{margin-top:18px}.profile-section h2{font-size:.82rem;letter-spacing:.09em;color:var(--green-bright);margin:0 0 8px;text-align:left}.profile-table-wrap{overflow-x:auto;scrollbar-width:none}.profile-table-wrap::-webkit-scrollbar{display:none}.profile-table{width:100%;border-collapse:separate;border-spacing:3px;font-size:.72rem;table-layout:fixed}.profile-table th,.profile-table td{background:var(--panel);padding:8px 3px;text-align:center;border-radius:5px}.profile-table th{color:var(--muted);font-weight:800}.profile-table tr:first-child th{font-size:.61rem}.profile-table td{color:var(--text);font-weight:800}.profile-table th:first-child{color:var(--green-bright);width:44px}.profile-note{font-size:.66rem;color:var(--muted);margin-top:6px;line-height:1.35}.rush-stat-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:5px}.rush-stat-grid article{background:var(--panel);border-radius:9px;padding:14px 5px;text-align:center}.rush-stat-grid strong{display:block;color:var(--green-bright);font-size:1.35rem}.rush-stat-grid span{display:block;color:var(--muted);font-size:.65rem;margin-top:3px}.profile-scroll-cue{position:sticky;bottom:0;margin:12px auto -26px;width:34px;height:24px;display:flex;align-items:center;justify-content:center;color:var(--green-bright);font-size:1.5rem;line-height:1;background:linear-gradient(transparent,var(--bg) 45%);pointer-events:none}.tutorial-help[hidden],.tutorial-numbers[hidden]{display:none!important}
/* v52: explicit light palette — exact green from the value-1 combination tile */
body.light-mode{
  --green:#0b7f60;
  --green-bright:#0b7f60;
  --green-soft:rgba(11,127,96,.13);
  --outer:#d7d9d7;
}
/* All semantic green UI must use the darker light-mode green. */
body.light-mode .action-secondary,
body.light-mode .nav-btn.active,
body.light-mode .profile-grid strong,
body.light-mode .progress-wrap small,
body.light-mode .cell.fixed,
body.light-mode .target.line-solved .val,
body.light-mode .tutorial-mini-brand .one,
body.light-mode .tutorial-progress span,
body.light-mode .tutorial-copy small,
body.light-mode .tutorial-help,
body.light-mode .tutorial-link,
body.light-mode .tutorial-corner,
body.light-mode .tutorial-target.focus,
body.light-mode .tutorial-numbers button:nth-child(3),
body.light-mode .profile-section h2,
body.light-mode .profile-table th:first-child,
body.light-mode .rush-stat-grid strong,
body.light-mode .profile-scroll-cue,
body.light-mode .rush-grid-bonus,
body.light-mode .rush-panel-bonus{color:#0b7f60}
body.light-mode .action-secondary{border-color:#0b7f60}
body.light-mode .action-primary,
body.light-mode .tool-btn.active,
body.light-mode .settings-menu input:checked+span,
body.light-mode .progress-track span,
body.light-mode .tutorial-progress span{background:#0b7f60}
body.light-mode #game-screen .cell.selected,
body.light-mode #game-screen .target.selected-line,
body.light-mode .tutorial-cell.focus,
body.light-mode .tutorial-target.focus,
body.light-mode .tutorial-numbers button.expected{box-shadow:inset 0 0 0 2px #0b7f60}
/* Make the modular game frame visibly light instead of medium gray. */
body.light-mode #game-screen .game-frame,
body.light-mode #game-screen .game-titlebar,
body.light-mode #game-screen .tool-row{background:#d7d9d7}
body.light-mode #game-screen .game-statusbar,
body.light-mode #game-screen .combinations-panel{border-color:#d7d9d7}


/* v53: authoritative LIGHT MODE palette. No bright Matrix green in light mode. */
body.light-mode{
  --green:#0b7f60;
  --green-bright:#0b7f60;
  --green-soft:rgba(11,127,96,.13);
  --outer:#0b7f60;
}
body.light-mode .game-screen{background:#0b7f60}
body.light-mode .game-frame{background:#0b7f60}
body.light-mode .game-header,
body.light-mode .game-tools{background:#0b7f60}
body.light-mode .game-titlebar,
body.light-mode .game-statusbar,
body.light-mode .board-container,
body.light-mode .combinations-panel,
body.light-mode .tool-row{border-color:#0b7f60}

/* Tutorial: every cell/target is explicitly light. */
body.light-mode .tutorial-shell{border-color:#0b7f60;box-shadow:0 20px 55px #0002}
body.light-mode .tutorial-progress{background:#c8cdca}
body.light-mode .tutorial-progress span{background:#0b7f60}
body.light-mode .tutorial-grid{background:#f1f0ec;border-color:#b9b9b5}
body.light-mode .tutorial-cell{background:#f1f0ec!important;color:#0b7f60!important;border-color:#b9b9b5}
body.light-mode .tutorial-cell.blank{color:transparent!important}
body.light-mode .tutorial-cell.focus{background:#dce7e3!important;color:#272a2c!important;box-shadow:inset 0 0 0 2px #0b7f60}
body.light-mode .tutorial-cell.sum-row{background:rgba(11,127,96,.10)!important;box-shadow:inset 0 2px 0 rgba(11,127,96,.28),inset 0 -2px 0 rgba(11,127,96,.28)}
body.light-mode .tutorial-cell.rule-ok{background:rgba(11,127,96,.12)!important}
body.light-mode .tutorial-target,
body.light-mode button.tutorial-target{background:#d0d2cf!important;color:#34393a!important;border-color:#b7bbb9!important}
body.light-mode .tutorial-target.focus,
body.light-mode button.tutorial-target.focus{background:#d0d2cf!important;color:#0b7f60!important;box-shadow:inset 0 0 0 2px #0b7f60}
body.light-mode .tutorial-corner{background:#d0d2cf!important;color:#0b7f60!important}
body.light-mode .tutorial-mini-brand .one,
body.light-mode .tutorial-copy small,
body.light-mode .tutorial-help,
body.light-mode .tutorial-link,
body.light-mode .tutorial-numbers button:nth-child(3),
body.light-mode .tutorial-inline-action{color:#0b7f60!important}
body.light-mode .tutorial-inline-action{background:#d0d2cf!important;border-color:#0b7f60!important}
body.light-mode .tutorial-numbers button.expected{box-shadow:inset 0 0 0 2px #0b7f60!important}

/* Rush + home: force all semantic green to the dark light-mode green. */
body.light-mode #btn-rush,
body.light-mode .rush-info-modal h2,
body.light-mode .rush-result-modal h2,
body.light-mode .rush-countdown strong,
body.light-mode #game-screen .rush-big-time:not(.danger),
body.light-mode #game-screen .rush-combo,
body.light-mode .rush-grid-bonus,
body.light-mode .rush-panel-bonus,
body.light-mode .profile-section h2,
body.light-mode .profile-table th:first-child,
body.light-mode .rush-stat-grid strong,
body.light-mode .profile-scroll-cue,
body.light-mode .victory-stars .earned,
body.light-mode .victory-record,
body.light-mode .sum-mode-toggle{color:#0b7f60!important}
body.light-mode #game-screen .rush-score-badge{background:#0b7f60!important;color:#fff!important}
body.light-mode .rush-grid-bonus,
body.light-mode .rush-panel-bonus{text-shadow:0 0 18px rgba(11,127,96,.20)!important}

/* Remaining generic semantic-green surfaces. */
body.light-mode .action-secondary,
body.light-mode .nav-btn.active,
body.light-mode .profile-grid strong,
body.light-mode .progress-wrap small,
body.light-mode .cell.fixed,
body.light-mode .target.line-solved .val,
body.light-mode .how-to-play{color:#0b7f60!important}
body.light-mode .action-secondary{border-color:#0b7f60!important}
body.light-mode .action-primary,
body.light-mode .tool-btn.active,
body.light-mode .settings-menu input:checked+span,
body.light-mode .progress-track span{background:#0b7f60!important}
body.light-mode #game-screen .cell.selected,
body.light-mode #game-screen .target.selected-line{box-shadow:inset 0 0 0 2px #0b7f60!important}

/* Light-mode animation keyframes cannot inherit CSS variables reliably from old hardcoded colors. */
@keyframes tutorial-focus-light{50%{box-shadow:inset 0 0 0 3px #0b7f60,0 0 18px rgba(11,127,96,.25)}}
body.light-mode .tutorial-cell.focus{animation-name:tutorial-focus-light}

/* v54: light-mode gameplay frame uses the same dark green as the light palette. */
body.light-mode #game-screen .game-frame,
body.light-mode #game-screen .game-titlebar,
body.light-mode #game-screen .tool-row{
  background:#0b7f60;
}
body.light-mode #game-screen .game-statusbar,
body.light-mode #game-screen .combinations-panel{
  border-color:#0b7f60;
}
