:root{--ink:#22213d;--cream:#fff0d5;--peach:#eea98e;--mint:#8fdfcf;--line:rgba(242,226,209,.22);--gold:#f8d598;--bg:#151729;--strong:#fff6e4}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;background:#101322;color:var(--cream);font-family:'DM Sans',Segoe UI,Arial,sans-serif}button{font:inherit;color:inherit;cursor:pointer;transition:transform .18s,border-color .18s,background .18s}button:hover:not(:disabled){transform:translateY(-2px)}button:disabled{opacity:.35;cursor:not-allowed}#app{min-height:100vh;position:relative;overflow:hidden;background:#151729}
.topline{position:absolute;z-index:40;left:0;right:0;top:0;height:61px;display:flex;align-items:center;justify-content:space-between;padding:10px max(23px,calc((100vw - 1440px)/2));background:linear-gradient(180deg,rgba(13,15,33,.7),rgba(15,15,29,0));pointer-events:none}.topline>*{pointer-events:auto}.brand{font-size:15px;letter-spacing:.14em;font-weight:800;text-shadow:0 2px 10px #142034}.brand i{font-style:normal;color:#ffc798}.brand-emblem{font-size:22px;color:#ffd49a;margin-right:5px}.top-actions{display:flex;gap:8px}.flat{background:rgba(31,33,54,.57);backdrop-filter:blur(15px);border:1px solid rgba(255,245,210,.2);border-radius:20px;padding:8px 12px;font-size:13px;font-weight:700;min-width:38px}.flat:hover{background:rgba(52,56,77,.8)}
.menu{min-height:100vh;display:flex;position:relative;align-items:center;background:radial-gradient(circle at 65% 30%,rgba(249,193,135,.2),transparent 40%),url('assets/roof.webp') center/cover no-repeat;padding:100px 7.5% 90px}.menu:before{content:'';position:absolute;inset:0;background:linear-gradient(90deg,rgba(18,17,38,.96),rgba(24,25,46,.83) 44%,rgba(21,23,42,.06) 100%),linear-gradient(0deg,rgba(18,17,36,.75),transparent 42%)}.menu:after{content:'';position:absolute;top:0;right:0;bottom:0;width:48%;background:radial-gradient(ellipse at center,rgba(255,246,202,.12),transparent 60%);pointer-events:none}.menu-copy{position:relative;z-index:3;width:min(570px,70vw)}.eyebrow{letter-spacing:.21em;font-size:11px;font-weight:800;color:#f8d29e}.menu h1{font-family:Fraunces,Georgia,serif;font-weight:700;line-height:.82;font-size:clamp(72px,10.5vw,172px);margin:18px 0 0;letter-spacing:-.085em;text-shadow:0 8px 5px rgba(18,17,33,.14)}.menu h1 span{display:block}.menu h1 em{color:#f0bc9b;font-size:.82em;font-style:italic;margin-left:.16em}.scribble-line{width:120px;height:3px;margin:29px 0 20px;background:#f1b5a5;border-radius:50%;transform:rotate(-3deg)}.menu-copy>p{font-size:clamp(16px,1.7vw,22px);line-height:1.58;max-width:490px;color:#fcecd7}.menu-buttons{display:flex;gap:10px;flex-wrap:wrap;margin-top:30px}.menu-buttons button,.overlay-card button{border:1px solid rgba(252,229,199,.31);border-radius:999px;padding:14px 20px;background:rgba(20,26,50,.64);box-shadow:0 4px 16px rgba(9,11,20,.15);font-size:14px;font-weight:700}.menu-buttons .primary,.overlay-card .primary{background:#f4c48f;border:1px solid #fce4b3;color:#32243a;box-shadow:0 7px 25px rgba(236,166,113,.15)}.menu-foot{margin-top:29px;color:#e3cdbf;font-size:12px;letter-spacing:.03em;line-height:1.7}.menu-fox{position:absolute;right:12%;bottom:10%;height:min(65vh,600px);max-width:45vw;object-fit:contain;filter:drop-shadow(0 24px 7px rgba(13,17,39,.34));z-index:2;animation:heroFloat 5s ease-in-out infinite;transform-origin:center bottom}.menu-note{position:absolute;z-index:3;right:8%;top:15%;max-width:260px;text-align:right;font-family:Georgia,serif;font-size:17px;font-style:italic;color:rgba(255,239,218,.92);line-height:1.5}.menu-note>span:first-child{font-size:30px;color:#ffe3b8}@keyframes heroFloat{0%,100%{transform:translateY(0) rotate(-1deg)}50%{transform:translateY(-10px) rotate(1deg)}}
.game{height:100vh;min-height:590px;display:flex;flex-direction:column;padding:62px 18px 14px;align-items:center;gap:11px;background:radial-gradient(circle at 50% 0,rgba(155,132,178,.2),transparent 45%),linear-gradient(180deg,#15182c,#111422)}.game[hidden],.menu[hidden],.overlay[hidden]{display:none!important}.game-top{width:min(1400px,100%);display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:51px}.level-label{display:flex;flex-direction:column;gap:4px}.level-label small{color:#d4b7be;text-transform:uppercase;letter-spacing:.2em;font-size:11px;font-weight:700}.level-label strong{font-family:Fraunces,Georgia,serif;font-size:23px;font-weight:600}.game-info{display:flex;gap:12px;flex-wrap:wrap}.game-info span{padding:8px 11px;border-radius:20px;background:rgba(255,255,255,.06);border:1px solid var(--line);font-size:13px;font-weight:700}.game-actions .round{width:40px;height:40px;border-radius:50%;background:rgba(255,255,255,.08);border:1px solid var(--line)}.canvas-frame{width:min(1400px,100%);position:relative;min-height:0;flex:1;background:rgba(7,9,21,.28);border:2px solid rgba(255,230,200,.23);border-radius:24px;overflow:hidden;box-shadow:0 24px 72px rgba(2,3,14,.5)}canvas{display:block;width:100%;height:100%;object-fit:contain;touch-action:none}.game-message{position:absolute;top:15px;left:50%;transform:translateX(-50%);pointer-events:none;max-width:75%;text-align:center;padding:11px 22px;background:rgba(22,27,46,.73);border:1px solid rgba(255,229,194,.18);border-radius:20px;font-size:13px;color:#fff1da;backdrop-filter:blur(8px);opacity:0;transition:opacity .4s}.game-message.show{opacity:1}.game-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;color:#ddd3c5;font-size:12px;max-width:1400px;width:100%;min-height:32px}.hints{display:flex;gap:18px}.touch-controls{display:none;position:absolute;inset:auto 12px 12px 12px;justify-content:space-between;pointer-events:none}.touch-left,.touch-right{display:flex;gap:9px}.touch-controls button{pointer-events:auto;width:64px;height:64px;border-radius:20px;background:rgba(25,35,57,.45);border:2px solid rgba(250,237,203,.28);color:#fff4d0;font-size:23px;font-weight:800;backdrop-filter:blur(8px);touch-action:none;user-select:none}.touch-controls button:active{background:rgba(124,182,166,.48)}
.overlay{position:fixed;inset:0;z-index:70;display:grid;place-items:center;background:rgba(8,11,25,.77);backdrop-filter:blur(9px);padding:18px}.overlay-card{border-radius:28px;max-width:720px;width:100%;padding:34px 36px;background:linear-gradient(130deg,#31324d,#24233f 48%,#1a263c);border:1px solid rgba(255,231,207,.26);box-shadow:0 26px 80px rgba(0,0,0,.35);position:relative;overflow:hidden}.overlay-card:after{content:'✦';position:absolute;right:-30px;top:-60px;color:rgba(255,255,255,.05);font-size:320px;pointer-events:none}.overlay-card h2{font-family:Fraunces,Georgia,serif;font-size:clamp(29px,4.8vw,54px);font-weight:600;margin:10px 0 16px;line-height:1.08}.overlay-card p{font-size:16px;line-height:1.7;color:#f3e5d7;max-width:570px}.overlay-card .eyebrow{color:#f3c698}.overlay-card .controls{display:flex;gap:10px;flex-wrap:wrap;margin-top:27px;position:relative;z-index:3}.chapter-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:25px}.chapter-grid button{display:flex;flex-direction:column;text-align:left;gap:5px;min-height:95px;background:rgba(255,255,255,.06);border-radius:17px}.chapter-grid button small{color:#cdbfbc}.chapter-grid button b{font-size:16px}.chapter-grid button.current{background:rgba(247,197,139,.23)}.toast{position:fixed;bottom:25px;left:50%;transform:translate(-50%,20px);z-index:99;padding:12px 20px;border-radius:18px;border:1px solid rgba(255,245,211,.29);background:rgba(22,29,44,.95);box-shadow:0 12px 35px rgba(0,0,0,.25);opacity:0;pointer-events:none;transition:.28s}.toast.show{opacity:1;transform:translate(-50%,0)}
@media(max-width:840px){.menu{padding:90px 6% 60px;align-items:flex-start}.menu-copy{width:min(520px,95%)}.menu:before{background:linear-gradient(180deg,rgba(17,20,38,.88),rgba(24,26,49,.75) 65%,rgba(20,23,39,.36))}.menu-fox{right:-10%;bottom:-5%;height:52vh;opacity:.75}.menu-note{display:none}.menu h1{font-size:clamp(72px,13vw,120px)}.game{padding:59px 7px 9px;min-height:540px}.level-label strong{font-size:16px}.level-label small{font-size:9px}.game-info{gap:4px}.game-info span{padding:6px 7px;font-size:11px}.game-footer{font-size:10px}.right-hints{display:none}.touch-controls{display:flex}.canvas-frame{border-radius:18px}.chapter-grid{grid-template-columns:repeat(2,1fr)}.overlay-card{padding:26px 21px}}
@media(max-width:560px){.menu h1{font-size:72px}.menu-buttons{flex-direction:column;align-items:flex-start}.menu-copy>p{font-size:16px}.menu-fox{opacity:.55;height:45vh}.game-message{max-width:88%;font-size:11px}.game-footer .hints{display:none}.touch-controls button{width:56px;height:56px;border-radius:16px}.overlay-card h2{font-size:32px}.chapter-grid{grid-template-columns:repeat(2,1fr)}.topline{padding-inline:12px}.brand{font-size:11px}}
/* Portrait phones: preserve the game's original 16:9 field and keep the touch
   buttons below it instead of letterboxing the entire tall viewport. */
@media (max-width:720px) and (orientation:portrait){
 .game{justify-content:flex-start;padding-bottom:22px;height:100dvh;min-height:540px}
 .canvas-frame{height:auto;aspect-ratio:1000/560;flex:0 0 auto;overflow:visible}
 .canvas-frame canvas{height:100%;width:100%;border-radius:16px;overflow:hidden}
 .canvas-frame .touch-controls{bottom:-91px;left:4px;right:4px}
 .game-footer{margin-top:94px;min-height:16px}
 .game-message{top:7px}
}
