@import url('assets/fonts.css');

/* Stable game framing while mobile browser chrome expands or collapses. */
.arcade{touch-action:none;container:game / size}
body[data-touch=true] .arcade{bottom:auto;height:var(--game-height,100%)}
@supports(height:100svh){body[data-touch=true] .arcade{height:var(--game-height,100svh)}}

/* Safari selection suppression is limited to the game and its controls. */
:is(.arcade,#world-dialog,#help-dialog,#settings-dialog),
:is(.arcade,#world-dialog,#help-dialog,#settings-dialog) *{
  -webkit-user-select:none;user-select:none;
  -webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;
}
:is(.arcade,#world-dialog,#help-dialog,#settings-dialog) :is(a,input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"]),
:is(.arcade,#world-dialog,#help-dialog,#settings-dialog) :is(a,[contenteditable]:not([contenteditable="false"]),[role="textbox"]) *{
  -webkit-user-select:text;user-select:text;-webkit-touch-callout:default;
}

:root{
  --ink:#faf5d6;--yellow:#f5d689;--green:#143b40;--card:#1d464d;--muted:#b8d4cf;
  --line:#b8d4cf2b;--font:'DM Sans',Arial,sans-serif;--display:'Space Grotesk',Arial,sans-serif;
  --title:var(--display);--radius:19px;
}
*{box-sizing:border-box}
h1,h2,h3{font-family:var(--display);font-weight:700;font-synthesis:none}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#172d30;color:var(--ink);font-family:var(--font);overscroll-behavior:none}
button{font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation;color:inherit}
button:disabled{opacity:.45;cursor:default}
button,a,input{-webkit-tap-highlight-color:transparent}
button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid var(--yellow);outline-offset:3px}
button:not(:disabled){transition:transform .13s ease-out,background-color .13s ease-out,opacity .13s ease-out}
button:not(:disabled):active{transform:scale(.97);opacity:.86}
button svg{flex:none;pointer-events:none}
.arcade,.screen{position:absolute;inset:0;overflow:hidden}
.arcade{isolation:isolate}
.screen{background:#142d30}
canvas{display:block;width:100%;height:100%;object-fit:contain;image-rendering:auto;outline:none;touch-action:none}
[hidden]{display:none!important}
.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* The native layout: a location at left, status and Pause at right. */
.console-top{
  position:absolute;z-index:3;top:calc(env(safe-area-inset-top) + 10px);
  left:calc(env(safe-area-inset-left) + 16px);right:calc(env(safe-area-inset-right) + 16px);
  display:flex;align-items:flex-start;gap:10px;pointer-events:none;
}
.hud-place,.hud-stats,.console-actions{pointer-events:auto}
.hud-place{
  display:flex;flex:0 1 310px;min-width:0;flex-direction:column;gap:3px;
  padding:9px 12px;border-radius:17px;background:#143b40ed;
}
.hud-label{font-size:11px;font-weight:600;line-height:1.3;color:var(--muted)}
.hud-label span{margin-left:8px}
.hud-place strong{font-size:13px;font-weight:700;line-height:1.35}
.hud-label,.hud-place strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hud-stats{
  display:flex;align-items:center;gap:13px;flex:none;min-height:44px;
  margin-left:auto;padding:12px;border-radius:17px;background:#143b40ed;
}
.hud-stat{display:flex;align-items:center;gap:5px;font-size:12px;line-height:1;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap}
.hud-stat svg{display:block;flex:none;width:16px;height:16px}
.coin-icon{display:block;flex:none;width:11px;height:14px;background:linear-gradient(135deg,#f2dfa8,#d3b377 55%,#99734e);border:1px solid #f7ebbd;clip-path:polygon(20% 0,80% 14%,100% 63%,50% 100%,0 75%,5% 25%)}
.hud-stat:first-child,.star-stat{color:var(--yellow)}
.lives-stat{color:#ff8585}
.timer-stat{color:var(--ink)}
.timer-stat>span:first-child{font-size:18px;line-height:14px}
.console-actions{display:flex;align-items:center;flex:none;gap:8px;margin-left:auto}
body:is([data-mode=playing],[data-mode=dead]) .console-actions{margin-left:0}
.icon-button{
  display:inline-flex;align-items:center;justify-content:center;position:relative;flex:none;
  width:44px;height:44px;min-width:44px;min-height:44px;padding:0;
  -webkit-appearance:none;appearance:none;border:0;border-radius:15px;
  background:var(--card);color:var(--ink);font-size:25px;line-height:1;
}
.icon-button svg{display:block;flex:none;width:22px;height:22px}
.console-actions svg{fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#pause-button{background:var(--yellow);color:var(--green)}
.sound-waves,.resume-symbol{display:none}
.sound-on .sound-waves,.is-paused .resume-symbol{display:block}
.sound-on .sound-muted,.is-paused .pause-symbol{display:none}
.pause-symbol,.resume-symbol{fill:currentColor;stroke:none}
body:not(:is([data-mode=playing],[data-mode=dead])) :is(.hud-place,.hud-stats,#pause-button){display:none}
body:is([data-mode=playing],[data-mode=dead]) .console-actions :is(#looks-button,#worlds-button,#settings-button){display:none}
@container game (max-width:649px){
  .console-top{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 10px}
  .hud-place{width:100%;max-width:230px}
  .hud-stats{grid-column:1/-1;grid-row:2;justify-self:end;margin-left:0;gap:12px;min-height:38px;padding:10px 12px}
  .console-actions{grid-column:2;grid-row:1}
}

/* Shared buttons keep the same rounded shape and press response as iOS. */
.play-button{
  display:flex;align-items:center;justify-content:center;gap:12px;min-width:190px;min-height:48px;
  margin:0 auto;padding:12px 20px;border:0;border-radius:var(--radius);
  background:var(--yellow);color:var(--green);font-size:15px;font-weight:700;line-height:1.4;
}
.play-button svg{display:block;width:16px;height:16px}
.overlay-secondary,.quiet-button{
  display:flex;align-items:center;justify-content:center;gap:6px;min-height:44px;
  border:1px solid var(--line);border-radius:15px;background:var(--card);color:var(--ink);
  padding:10px 15px;font-size:12px;font-weight:600;line-height:1.4;text-decoration:none;
}
.menu-choices{display:flex;justify-content:center;gap:8px;width:100%}
.overlay-secondary{flex:1;min-width:0}
.special-button,.menu-progress,.home-place{display:none}
#overlay-copy,#start-hint{display:none}
.overlay-eyebrow:empty{display:none}
.game-overlay{
  position:absolute;inset:0;z-index:2;display:grid;place-items:center;
  grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);
  padding:calc(env(safe-area-inset-top) + 70px) calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + 20px);
  background:#031d286e;
}
.overlay-card{
  width:460px;max-width:100%;max-height:100%;overflow:auto;overscroll-behavior:contain;
  text-align:center;padding:26px;border:1px solid var(--line);border-radius:25px;
  background:var(--green);box-shadow:0 16px 60px #09222866;
}
.overlay-eyebrow{font-size:12px;font-weight:600;line-height:1.5;color:var(--muted);margin:0 0 8px}
.overlay-card h1{font-family:var(--title);font-size:36px;font-weight:700;line-height:1.1;letter-spacing:-.035em;margin:0 0 16px;font-synthesis:none;color:var(--ink)}
.overlay-card>p:not(.overlay-eyebrow){font-size:13px;line-height:1.6;color:var(--muted);margin:0 0 18px}
.overlay-card>.play-button{width:100%;min-width:0}
.overlay-card>.menu-choices{margin-top:10px}

/* An upright display title leaves the original key art room to breathe. */
body[data-mode=menu] .game-overlay{
  place-items:center start;padding:70px max(6.5%,calc(env(safe-area-inset-left) + 28px)) 30px;
  background:#8298a0 url('assets/quest-key-art.webp?v=gecko-1') center/cover no-repeat;isolation:isolate;
}
body[data-mode=menu] .game-overlay::before{
  content:'';position:absolute;inset:0;z-index:-1;
  background:linear-gradient(90deg,#143b40e6 0,#143b40b3 34%,#143b4038 62%,transparent 100%);
}
body[data-mode=menu] .overlay-card{
  width:43%;max-width:380px;max-height:100%;padding:0;border:0;border-radius:0;
  background:none;box-shadow:none;text-align:left;scrollbar-width:none;
}
body[data-mode=menu] .overlay-card::-webkit-scrollbar{display:none}
body[data-mode=menu] .overlay-eyebrow,
body[data-mode=menu] .overlay-card h1{
  font-family:var(--title);font-weight:700;font-synthesis:none;line-height:1;
  color:var(--ink);text-shadow:0 2px 14px #092b3b55;
}
body[data-mode=menu] .overlay-eyebrow{font-size:clamp(22px,2.6vw,34px);line-height:1.35;letter-spacing:.22em;color:#e8d298;margin:0 0 3px}
body[data-mode=menu] .overlay-card h1{font-size:clamp(62px,7vw,96px);letter-spacing:-.055em;margin:0 0 24px}
body[data-mode=menu] .home-place{display:flex;flex-direction:column;gap:3px;margin:0 0 22px;line-height:1.35}
#home-world{font-size:16px;font-weight:700}
#home-level{font-size:14px;color:var(--muted)}
body[data-mode=menu] .overlay-card>.play-button{margin:0;font-size:16px;min-height:50px}
body[data-mode=menu] .menu-choices{margin-top:10px;justify-content:flex-start}
body[data-mode=menu] .overlay-secondary{font-size:11px;padding:10px 8px;background:#1d464dec}
body[data-mode=menu] .special-button{display:flex}
body[data-mode=menu] .special-button span{color:var(--yellow)}
body[data-mode=menu] .overlay-card .menu-progress{
  display:flex;align-items:center;flex-wrap:wrap;gap:7px 12px;margin:18px 0 0;
  color:var(--ink);font-size:11px;font-weight:600;line-height:1.5;
}
.menu-progress svg{display:inline-block;vertical-align:middle;width:15px;height:15px;color:var(--yellow)}
@container game (max-height:570px) and (orientation:landscape){
  body[data-mode=menu] .game-overlay{padding-top:58px;padding-bottom:22px}
  body[data-mode=menu] .overlay-card{width:46%;max-width:330px}
  body[data-mode=menu] .overlay-eyebrow{font-size:24px}
  body[data-mode=menu] .overlay-card h1{font-size:64px;margin-bottom:16px}
  body[data-mode=menu] .home-place{margin-bottom:16px}
  #home-world{font-size:14px}#home-level{font-size:12px}
  body[data-mode=menu] .overlay-card>.play-button{min-height:46px;font-size:14px;padding:10px 14px}
  body[data-mode=menu] .overlay-card .menu-progress{margin-top:12px;font-size:10px}
}
@container game (max-height:420px) and (orientation:landscape){
  body[data-mode=menu] .game-overlay{padding-top:58px;padding-bottom:16px}
  body[data-mode=menu] .overlay-eyebrow{font-size:20px}
  body[data-mode=menu] .overlay-card h1{font-size:52px;margin-bottom:13px}
  body[data-mode=menu] .home-place{gap:2px;margin-bottom:12px}
  body[data-mode=menu] .menu-choices{display:none}
  body[data-mode=menu] .overlay-card .menu-progress{margin-top:11px}
}

@container game (max-width:649px) and (orientation:portrait){
  body[data-mode=menu] .game-overlay{
    place-items:end start;
    padding:calc(env(safe-area-inset-top) + 70px) max(32px,env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 32px) max(32px,env(safe-area-inset-left));
    background-color:#143b40;background-position:88% top;background-size:auto 72%;
  }
  body[data-mode=menu] .game-overlay::before{
    background:linear-gradient(0deg,#143b40 0,#143b40f5 38%,#143b40b8 52%,#143b4026 68%,transparent 82%);
  }
  body[data-mode=menu] .overlay-card{width:100%;max-width:330px}
  body[data-mode=menu] .overlay-eyebrow{font-size:24px}
  body[data-mode=menu] .overlay-card h1{font-size:clamp(56px,16vw,80px);margin-bottom:22px}
}
@container game (max-height:340px) and (orientation:landscape){
  body[data-mode=menu] .overlay-eyebrow{font-size:17px}
  body[data-mode=menu] .overlay-card h1{font-size:44px;margin-bottom:10px}
  body[data-mode=menu] .home-place{margin-bottom:10px}
  body[data-mode=menu] .overlay-card .menu-progress{margin-top:8px}
}

/* Results and pause are contained cards, with room for the quick actions. */
body:is([data-mode=complete],[data-mode=gameover]) .toast{display:none}
body:is([data-mode=complete],[data-mode=gameover]) .overlay-card{
  display:grid;grid-template-areas:'eyebrow' 'title' 'stars' 'results' 'context' 'play' 'secondary';
  grid-template-columns:minmax(0,1fr);gap:14px;width:480px;
}
body:is([data-mode=complete],[data-mode=gameover]) .overlay-eyebrow{grid-area:eyebrow;margin:0}
body:is([data-mode=complete],[data-mode=gameover]) .overlay-card h1{grid-area:title;font-size:36px;margin:0}
.overlay-stars{grid-area:stars;display:flex;justify-content:center;align-items:center;gap:12px;margin:0;height:72px;color:var(--yellow)}
.result-star{display:grid;place-items:center;width:54px;height:54px;color:#527172}
.result-star svg{display:block;width:100%;height:100%}
.result-star.earned{color:var(--yellow);filter:drop-shadow(0 3px 0 #a48241)}
.result-star:nth-child(2){width:64px;height:64px;transform:translateY(-3px)}
.run-results{grid-area:results;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;width:100%;padding:0;margin:0}
.run-results>div{min-width:0;padding:12px 7px;background:var(--card);border:1px solid var(--line);border-radius:15px}
.run-results dt{display:flex;flex-direction:column;align-items:center;gap:6px;margin:0 0 7px;color:var(--muted);font-size:10px;line-height:1.2}
.run-results dt svg{display:block;flex:none;width:28px;height:28px}
.run-results dd{margin:0;font-size:11px;font-weight:700;line-height:1.3;white-space:nowrap;color:var(--muted)}
.run-results .is-earned{border-color:#8cd8b848}
.run-results .is-earned dd{color:#bef4d1}
.run-results .result-coin-stat dd{font-family:var(--display);font-size:18px;line-height:1;color:var(--yellow)}
.result-stat:not(.is-earned):not(.result-coin-stat) dt svg{opacity:.45;filter:saturate(.4)}
.overlay-card>p.result-context{grid-area:context;margin:0;color:var(--muted);font-size:12px;line-height:1.5}
body:is([data-mode=complete],[data-mode=gameover]) .overlay-card>.play-button{grid-area:play;margin:0}
body:is([data-mode=complete],[data-mode=gameover]) .menu-choices{grid-area:secondary;margin:0}
.result-retry{grid-area:stars;display:flex;flex-direction:column;align-items:center;gap:5px;padding:0;color:var(--muted);font-size:11px}
.result-retry svg{display:block;width:60px;height:60px}
.retry-hearts{font-size:20px;letter-spacing:4px;line-height:1.3;color:#ff9494}
body[data-mode=gameover] .overlay-card{grid-template-areas:'eyebrow' 'title' 'stars' 'context' 'play' 'secondary'}
body[data-mode=paused] .overlay-card .result-context{margin:0 0 18px}
@container game (max-height:650px) and (orientation:landscape){
  body:is([data-mode=complete],[data-mode=gameover]) .overlay-card{
    width:660px;grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-areas:'eyebrow eyebrow' 'title results' 'stars results' 'context context' 'play secondary';
    gap:12px 20px;padding:20px;align-items:center;
  }
  body:is([data-mode=complete],[data-mode=gameover]) .overlay-card h1{font-size:31px}
  body:is([data-mode=complete],[data-mode=gameover]) .overlay-secondary{height:100%;padding:10px 8px;font-size:11px}
  .overlay-stars{height:64px}
  body[data-mode=gameover] .overlay-card{grid-template-areas:'eyebrow eyebrow' 'title stars' 'context stars' 'play secondary'}
  body[data-mode=paused] .overlay-card{width:500px;padding:22px}
}
@container game (max-height:370px) and (orientation:landscape){
  .game-overlay{padding-bottom:calc(env(safe-area-inset-bottom) + 12px);padding-top:calc(env(safe-area-inset-top) + 64px)}
  body:is([data-mode=complete],[data-mode=gameover]) .overlay-card{gap:9px 16px;padding:16px;border-radius:22px}
  body:is([data-mode=complete],[data-mode=gameover]) .overlay-card h1{font-size:27px}
  .overlay-eyebrow{font-size:10px}
  .overlay-stars{height:52px;gap:9px}.result-star{width:40px;height:40px}.result-star:nth-child(2){width:48px;height:48px}
  .run-results{gap:5px}.run-results>div{padding:10px 4px}.run-results dt{font-size:9px}.run-results dd{font-size:10px}
  .overlay-card .result-context{font-size:10px}
  body:is([data-mode=complete],[data-mode=gameover]) .play-button{min-height:44px;font-size:13px;padding:10px}
  body[data-mode=paused] .overlay-card{padding:18px}
  body[data-mode=paused] .overlay-card h1{font-size:30px;margin-bottom:12px}
}

/* Modal headers stay visible while only their content scrolls. */
dialog{
  --dialog-inset-top:max(16px,calc(env(safe-area-inset-top) + 12px));
  --dialog-inset-bottom:max(16px,calc(env(safe-area-inset-bottom) + 12px));
  position:fixed;top:var(--dialog-inset-top);bottom:var(--dialog-inset-bottom);left:env(safe-area-inset-left);right:env(safe-area-inset-right);margin:auto;width:calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right) - 40px);
  max-width:580px;max-height:calc(100dvh - var(--dialog-inset-top) - var(--dialog-inset-bottom));
  padding:26px;border:1px solid var(--line);border-radius:25px;background:var(--green);color:var(--ink);
  box-shadow:0 22px 80px #051e2973;overflow:auto;overscroll-behavior:contain;
  scrollbar-color:#66897b var(--green);scrollbar-width:thin;
}
dialog::backdrop{background:#061d287d;backdrop-filter:blur(5px)}
dialog h2{font-family:var(--title);font-size:30px;font-weight:700;line-height:1.15;letter-spacing:-.035em;margin:0 44px 22px 0}
.dialog-close{position:absolute;right:12px;top:12px}
.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:14px;flex:none;position:relative;padding:18px 22px;border-bottom:1px solid var(--line);background:var(--green)}
.panel-heading h2{margin:0;font-size:29px;min-width:0}
.panel-heading .dialog-close{position:static}
dialog:has(>.panel-heading){padding:0;overflow:hidden}
dialog[open]:has(>.panel-heading){display:flex;flex-direction:column}
.panel-content,.settings-list{min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:22px;scrollbar-width:thin}
#settings-dialog{max-width:460px}
.settings-list{display:flex;flex-direction:column;gap:8px}
.settings-row{
  display:flex;align-items:center;justify-content:space-between;gap:14px;flex:none;
  width:100%;min-height:54px;padding:13px 16px;border:0;border-radius:15px;
  background:var(--card);color:var(--ink);text-align:left;text-decoration:none;font-size:14px;font-weight:600;line-height:1.4;
}
.settings-row>span:not(.setting-switch){display:flex;flex:1;flex-direction:column;align-items:flex-start;gap:3px;min-width:0}
.settings-row strong{font-size:14px;font-weight:600}
.setting-switch{position:relative;display:block;flex:none;width:42px;height:25px;border-radius:20px;background:#66847f}
.setting-switch::before{content:'';position:absolute;left:3px;top:3px;width:19px;height:19px;border-radius:50%;background:var(--ink);transition:transform .13s ease-out}
[aria-checked=true] .setting-switch{background:var(--yellow)}
[aria-checked=true] .setting-switch::before{background:var(--green);transform:translateX(17px)}
.settings-row svg{display:block;flex:none;width:21px;height:21px}
.settings-row>svg:last-child{width:18px;height:18px;color:var(--muted)}
.settings-row small,.settings-state{font-size:12px;font-weight:500;color:var(--muted);white-space:normal}
.publisher-credit{display:none}
body[data-mode=menu] .overlay-card .publisher-credit{display:block;margin:5px 0 0;font-size:11px;line-height:1.5;color:var(--muted)}
.publisher-credit a,.settings-footer a{display:inline-flex;align-items:center;gap:4px;min-height:32px;color:var(--yellow);text-underline-offset:4px}
.settings-footer{color:var(--muted);font-size:11px;line-height:1.5;text-align:center;margin:10px 0 0}
#transfer-dialog{max-width:520px}
#transfer-dialog p{font-size:14px;line-height:1.6;margin:0 0 16px}
.transfer-sites,.progress-status{color:var(--muted)}
.transfer-sites a{color:var(--yellow);text-underline-offset:3px}
.transfer-actions{display:flex;flex-wrap:wrap;gap:10px}
.transfer-actions button{flex:1;min-height:44px;min-width:145px;margin:0;font-size:14px;white-space:normal}
.progress-preview{margin-top:20px;padding:16px;border:1px solid var(--line);border-radius:16px}
#transfer-dialog .progress-status{margin:16px 0 0;min-height:1.6em}

/* World artwork and course paths retain the existing web navigation. */
#world-dialog{max-width:1000px;height:min(790px,calc(100dvh - var(--dialog-inset-top) - var(--dialog-inset-bottom)));padding:0;overflow:hidden}
#world-dialog[open]{display:flex;flex-direction:column}
.map-header{position:relative;flex:none;padding:22px 24px 16px;border-bottom:1px solid var(--line);background:var(--green);z-index:1}
.map-header .dialog-close{right:16px;top:16px}
.section-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:16px;padding-right:48px}
.section-heading h2{margin:0;font-size:32px}
.eyebrow{font-size:10px;line-height:1.4;letter-spacing:.5px;color:var(--muted);font-weight:600;margin:0 0 5px}
.eyebrow:empty{display:none}
.progress-summary{font-size:11px;color:var(--muted);min-width:112px;text-align:right;white-space:nowrap}
.progress-summary b{color:var(--yellow)}
.progress-track{height:4px;border-radius:4px;background:#ffffff1a;margin-top:8px;overflow:hidden}
.progress-track span{display:block;height:100%;width:0;background:var(--yellow)}
.map-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px}
.map-switch{display:flex;gap:4px;padding:4px;border-radius:16px;background:#082f3570}
.map-switch button{min-height:44px;min-width:90px;padding:10px 16px;border:0;border-radius:13px;background:transparent;color:var(--muted);font-size:12px;font-weight:600}
.map-switch button[aria-pressed=true]{background:var(--yellow);color:var(--green)}
.map-star-total{display:flex;gap:7px;align-items:center;color:var(--yellow);font-size:12px;white-space:nowrap;font-variant-numeric:tabular-nums}
.map-star-total svg{display:block;flex:none;width:20px;height:20px}
.map-content{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:20px 24px 24px;scrollbar-color:#66897b var(--green);scrollbar-width:thin}
.world-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
.world-card{position:relative;overflow:hidden;padding:0 12px 12px;border:1px solid var(--line);border-radius:19px;background:var(--card)}
.world-card.active{border-color:#f5d68980}
.world-card-top{position:relative;display:flex;isolation:isolate;align-items:flex-end;min-height:112px;margin:0 -12px 11px;padding:34px 16px 14px;background:var(--world-art) center 55%/cover}
.world-card-top::before{content:'';position:absolute;inset:0;z-index:-1;background:linear-gradient(0deg,#173e46,transparent)}
.world-symbol{display:none}
.world-card h3{font-family:var(--title);font-size:24px;font-weight:700;line-height:1.15;letter-spacing:-.035em;margin:0 0 5px;color:var(--ink)}
.world-caption{font-size:10px;line-height:1.4;color:#d0e0d8}
.world-levels{position:relative;display:grid;grid-template-columns:minmax(0,1fr);gap:6px;isolation:isolate}
.world-levels::before{content:'';position:absolute;z-index:-1;left:25px;top:23px;bottom:23px;border-left:2px dashed #b8d4cf40}
.level-button{display:flex;align-items:center;gap:10px;width:100%;min-width:0;min-height:50px;height:auto;padding:7px 9px;border:1px solid transparent;border-radius:13px;background:#14383edb;color:#d4e3d7;font-size:12px;line-height:1.35;text-align:left}
.course-node{display:grid;place-items:center;flex:none;width:32px;height:32px;border:1.5px solid #769b98;border-radius:50%;color:#91b6ad;background:#214d53}
.course-node svg{display:block;width:17px;height:17px}
.course-name{flex:1;min-width:0;overflow-wrap:anywhere;font-weight:600}
.course-mechanic{display:block;margin-top:3px;color:var(--muted);font-size:10px;line-height:1.45;font-weight:400}
#recovery-dialog{max-width:460px}
#recovery-dialog p{margin:0 0 20px;line-height:1.6}
#recovery-dialog .play-button{width:100%;margin:0}
.course-badge{flex:none;font-size:8px;letter-spacing:.3px;text-transform:uppercase;color:var(--yellow);white-space:nowrap}
.level-button.current{border-color:#f5d6898c;background:#f5d68915;color:var(--ink)}
.level-button.current .course-node{border-color:#f5d689;background:var(--yellow);color:var(--green)}
.level-button.cleared:not(.current) .course-node{border-color:#95c2a6;background:#3f6e60;color:#e0f3cf}
.level-button.mastered:not(.current){background:#315b5766;border-color:#80bcb445}
.level-button.mastered:not(.current) .course-node{border-color:#8cdfc7;color:#a8f0d4;background:#386c67}
.mini-star{display:flex;flex:none;align-items:center;gap:3px;color:var(--yellow);font-size:10px;white-space:nowrap}
.mini-star svg{display:block;width:12px;height:12px}
.level-button.bonus-level{border-color:#f5d6892b}
.level-button.bonus-level .course-node{border-radius:10px}
.bonus-name,.bonus-hint{display:none}
.special-map .world-levels::before,.special-map .level-button:not(.bonus-level){display:none}
.special-map .bonus-level{min-height:88px;flex-wrap:wrap;align-content:center;padding:12px 9px}
.special-map .course-name{font-size:14px}
.special-map .bonus-name{display:block;font-weight:700;font-size:14px}
.special-map .bonus-hint{display:block;flex-basis:100%;padding-left:42px;font-size:11px;line-height:1.5;color:var(--muted)}
.save-note{text-align:center;font-size:10px;color:var(--muted);line-height:1.5;margin:20px 0 0}
.wardrobe-heading{text-align:center;margin:8px 0 22px}
.wardrobe-heading h3{font-family:var(--title);font-size:26px;font-weight:700;letter-spacing:-.035em;color:var(--ink);margin:0 0 7px}
.wardrobe-heading p{font-size:12px;line-height:1.5;color:var(--muted);margin:0}
.wardrobe-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:11px;margin:0 0 22px}
.cosmetic-card{display:flex;position:relative;flex-direction:column;align-items:center;gap:6px;min-width:0;padding:16px 8px;border:1px solid var(--line);border-radius:19px;background:var(--card);color:var(--ink)}
.cosmetic-card.selected{border-color:var(--yellow);background:#365b56}
.cosmetic-card.locked{border-style:dashed;cursor:default;opacity:1;color:var(--muted);background:#17393f}
.cosmetic-card.locked .cosmetic-portrait{filter:saturate(.4);opacity:.8}
.cosmetic-card strong{font-family:var(--title);font-size:18px;font-weight:700;letter-spacing:-.025em;line-height:1.2;overflow-wrap:anywhere}
.cosmetic-card.selected strong{color:var(--yellow)}
.cosmetic-portrait{display:grid;place-items:center;width:100%;min-height:120px;margin-bottom:4px}
.cosmetic-portrait img{display:block;width:120px;height:120px;max-width:100%;object-fit:contain}
.cosmetic-status{font-size:10px;line-height:1.4;color:var(--muted);margin-top:2px}
.cosmetic-card.selected .cosmetic-status{color:var(--yellow)}
.reward-progress{text-align:center;font-size:12px;font-weight:600;line-height:1.5;color:var(--yellow);margin:0 0 9px}
.wardrobe-note{font-size:11px;text-align:center;line-height:1.6;color:var(--muted);margin:0}

/* Instructions and optional services use the same panel vocabulary. */
.help-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px 24px}
.help-grid h3{font-size:13px;line-height:1.4;margin:9px 0 0}
.help-grid p{font-size:12px;line-height:1.6;color:var(--muted);margin:5px 0 0}
kbd{display:inline-block;padding:7px 12px;font-family:var(--display);font-size:13px;background:var(--card);border:1px solid #b8d4cf70;border-bottom-width:3px;border-radius:9px}
.help-symbol{font-size:30px;color:var(--yellow)}
.help-bottom{font-size:11px;line-height:1.9;text-align:center;color:var(--muted);margin:23px 0}
.help-privacy{display:flex;justify-content:center;gap:10px;flex-wrap:wrap;border-top:1px solid var(--line);padding-top:16px}
#privacy-dialog{max-width:480px}
.privacy-intro{font-size:13px;line-height:1.6;color:var(--muted);margin:0 0 18px}
.privacy-option{display:flex;align-items:center;justify-content:space-between;gap:18px;border-top:1px solid var(--line);padding:16px 0;cursor:pointer;min-height:44px}
.privacy-option strong{display:block;font-size:14px;font-weight:600}
.privacy-option small{display:block;color:var(--muted);font-size:11px;line-height:1.6;margin-top:5px}
.privacy-option input{width:23px;height:23px;accent-color:var(--yellow);flex:none;cursor:pointer}
.privacy-option input:disabled{opacity:.4;cursor:default}
.privacy-unavailable{font-size:11px;color:var(--muted);line-height:1.5;margin:-5px 0 12px}
.privacy-link{font-size:11px;line-height:1.6;margin:0 0 20px}
.privacy-link a{color:var(--yellow);text-underline-offset:3px}
.privacy-actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.privacy-actions .play-button,.privacy-actions .quiet-button{min-width:0;flex:1;font-size:12px;padding:12px;min-height:46px}
body:is([data-ad-pending=true],[data-travelling=true]) .touch-controls,
body:has(#rotate-screen:not([hidden])) .touch-controls{visibility:hidden!important}
body[data-panel-open=true] :is(.console-top,.touch-controls,.overlay-card,.adventure-hud){visibility:hidden!important}
body[data-ad-pending=true] .play-button{cursor:wait}

@media(max-width:700px){
  dialog{width:calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right) - 24px);border-radius:22px}
  .map-header{padding:18px 18px 14px}.map-content{padding:16px 18px 20px}
  .section-heading{gap:12px}.section-heading h2{font-size:27px}.progress-summary{font-size:10px;min-width:94px}
  .world-grid{gap:12px}.world-card h3{font-size:22px}.course-badge{font-size:7px}
  .wardrobe-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
  .cosmetic-card{padding:13px 7px}.cosmetic-card strong{font-size:17px}
  .map-switch button{min-width:80px;padding:10px 12px}
}
@media(max-width:480px){
  .panel-heading{padding:14px 16px}.panel-heading h2{font-size:27px}.panel-content,.settings-list{padding:16px}
  .section-heading{display:block;margin-bottom:12px}.section-heading h2{font-size:27px}.progress-summary{display:none}
  .map-star-total{gap:4px;font-size:10px}.map-star-total svg{width:17px;height:17px}
  .map-switch{gap:2px;padding:3px}.map-switch button{min-width:73px;padding:10px;font-size:11px}
  .world-grid{grid-template-columns:minmax(0,1fr)}
  .map-header{padding:18px 14px 12px}.map-content{padding:14px}
  .world-card-top{min-height:100px}
  .help-grid{gap:18px}.help-grid h3{font-size:12px}
  .settings-row{font-size:13px;padding:12px}
  .wardrobe-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-height:570px) and (orientation:landscape){
  dialog{--dialog-inset-top:max(10px,calc(env(safe-area-inset-top) + 8px));--dialog-inset-bottom:max(10px,calc(env(safe-area-inset-bottom) + 8px));border-radius:22px}
  .panel-heading{padding:12px 18px}.panel-heading h2{font-size:27px}.panel-content,.settings-list{padding:18px}
  .map-header{padding:14px 18px 12px}.map-header .dialog-close{top:10px;right:12px}
  .section-heading{margin-bottom:10px}.section-heading h2{font-size:28px}.eyebrow{font-size:9px}
  .map-content{padding:15px 18px 20px}.world-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  .world-card-top{min-height:87px;padding-top:26px}.world-card h3{font-size:21px}.world-caption{font-size:9px}
  .level-button{min-height:48px;font-size:11px;padding:7px}.course-node{width:30px;height:30px}.world-levels::before{left:22px}
  .wardrobe-heading{margin:0 0 16px}.wardrobe-heading h3{font-size:24px}
  .wardrobe-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:9px}.cosmetic-card{padding:12px 6px}.cosmetic-card strong{font-size:16px}
  .cosmetic-portrait{min-height:84px}.cosmetic-portrait img{width:84px;height:84px}
}

/* Optional adventure goals appear only during the current run. */
.adventure-hud{position:absolute;z-index:3;top:calc(env(safe-area-inset-top) + 77px);left:50%;transform:translateX(-50%);display:none;align-items:center;gap:10px;pointer-events:none;max-width:calc(100% - 32px)}
body[data-mode=playing] .adventure-hud{display:flex}
.trial-hud,.boss-hud{display:flex;align-items:center;gap:9px;background:#143b40ed;border:1px solid var(--line);border-radius:15px;padding:8px 12px;white-space:nowrap;font-size:11px;font-variant-numeric:tabular-nums}
.blue-coin-icon{width:12px;height:18px;display:block;clip-path:polygon(50% 0,100% 28%,80% 84%,45% 100%,0 65%,12% 20%);background:linear-gradient(135deg,#defbff,#75d6e5 50%,#32849e);border:1px solid #e1fcff}
.trial-time{color:#c7f4ff;border-left:1px solid var(--line);padding-left:9px}
.boss-hud{flex-direction:column;gap:5px;min-width:160px;padding:7px 12px}
.boss-hud b{font-size:10px;letter-spacing:.3px}
.boss-gauge{height:6px;width:100%;border-radius:5px;background:#082c33;overflow:hidden}
.boss-gauge>span{display:block;height:100%;background:linear-gradient(90deg,#ff835e,#f5d689);transition:width .18s}
.toast{position:absolute;z-index:5;left:50%;top:85px;transform:translate(-50%,-6px);max-width:calc(100% - 32px);padding:11px 17px;border:1px solid #fff9e970;border-radius:14px;background:#faf5d6f2;color:var(--green);font-weight:600;font-size:12px;line-height:1.45;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;text-align:center}
.toast.visible{opacity:1;transform:translate(-50%,0)}
body[data-challenge=true] .toast{top:138px}
@container game (max-width:649px){.adventure-hud{top:calc(env(safe-area-inset-top) + 116px)}.toast{top:126px;font-size:11px}body[data-challenge=true] .toast{top:162px}}

/* Thumb hit areas and movement are unchanged from the established controls. */
.touch-controls{position:absolute;z-index:4;display:none;justify-content:space-between;pointer-events:none;visibility:hidden;user-select:none;touch-action:none}
body[data-mode=playing] .touch-controls{visibility:visible}
.touch-controls>div{display:flex}
.touch-controls button{pointer-events:auto;touch-action:none;user-select:none;-webkit-appearance:none;appearance:none;line-height:1}
/* Thumb controls are enabled by device capabilities, not viewport width. */
.touch-controls{display:none!important;align-items:flex-end;left:max(28px,calc(env(safe-area-inset-left) + 17px));right:max(28px,calc(env(safe-area-inset-right) + 17px));bottom:max(22px,calc(env(safe-area-inset-bottom) + 15px))}body[data-touch=true] .touch-controls{display:flex!important}.touch-controls .joystick{position:relative;display:block;flex:none;width:118px;height:118px;border-radius:50%;pointer-events:auto;touch-action:none;background:radial-gradient(circle at 40% 30%,#e7f1d51f,#0b292942);border:1px solid #e6efdb50;box-shadow:inset 0 2px 10px #ffffff10,0 5px 25px #0e292b24;backdrop-filter:blur(3px)}.joystick-ring{position:absolute;inset:15px;border:1px solid #e3edda2a;border-radius:50%;pointer-events:none}.joystick-thumb{position:absolute;left:50%;top:50%;width:57px;height:57px;margin:-28.5px 0 0 -28.5px;transform:translate(var(--stick-x,0px),var(--stick-y,0px));border-radius:50%;background:radial-gradient(circle at 35% 25%,#dce9c8d9,#8aaf8ebd 60%,#5f8b79d6);border:2px solid #e8efd494;box-shadow:0 5px 0 #153e3c48,0 6px 18px #0c302d40;pointer-events:none;transition:transform .11s ease-out,background .1s}.joystick.active .joystick-thumb{transition:none;background:radial-gradient(circle at 35% 25%,#f5edc6ed,#c5d7a5da 62%,#85a58fda)}.joystick.running{border-color:#f5d994a6;box-shadow:inset 0 0 22px #f5d99412,0 0 20px #f5d9940b}.touch-controls .touch-actions{display:flex;align-items:flex-end;gap:19px;padding-bottom:9px}.touch-controls .touch-actions button{display:flex;align-items:center;justify-content:center;width:66px;height:66px;border-radius:50%;padding:0;border:2px solid #fff2c26b;border-bottom-width:2px;background:radial-gradient(circle at 36% 27%,#ffe4a5ed,#e6bc6fe0);color:#395749;box-shadow:0 5px 0 #173d345b,0 5px 20px #18362f29}.touch-controls .touch-actions button svg{display:block;flex:none;width:31px;height:31px;pointer-events:none}.touch-controls .touch-actions button.pressed{transform:translateY(3px) scale(.97);background:#fff0b5;box-shadow:0 2px 0 #173d345b}.touch-controls .touch-actions .touch-fire{display:none;width:57px;height:57px;color:#b66145;background:radial-gradient(circle at 35% 25%,#fcd3a3e8,#e2a26ee3);margin-bottom:8px}body[data-form=fire] .touch-controls .touch-actions .touch-fire{display:flex}
@container game (min-height:650px){.touch-controls .joystick{width:142px;height:142px}.joystick-thumb{width:65px;height:65px;margin:-32.5px 0 0 -32.5px}.touch-controls .touch-actions button{width:80px;height:80px}.touch-controls .touch-actions .touch-fire{width:68px;height:68px}.touch-controls .touch-actions{gap:25px;padding-bottom:14px}.touch-controls .touch-actions button svg{width:35px;height:35px}.touch-controls{bottom:max(37px,calc(env(safe-area-inset-bottom) + 23px));left:max(42px,calc(env(safe-area-inset-left) + 24px));right:max(42px,calc(env(safe-area-inset-right) + 24px))}}
@container game (max-height:440px) and (orientation:landscape){.touch-controls .joystick{width:103px;height:103px}.joystick-thumb{width:51px;height:51px;margin:-25.5px 0 0 -25.5px}.joystick-ring{inset:13px}.touch-controls .touch-actions button{width:61px;height:61px}.touch-controls .touch-actions .touch-fire{width:53px;height:53px}.touch-controls .touch-actions{gap:16px;padding-bottom:6px}.touch-controls{bottom:max(16px,calc(env(safe-area-inset-bottom) + 9px))}}


.rotate-screen{position:absolute;inset:0;z-index:20;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;padding:calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px);background:var(--green);color:var(--ink);text-align:center}
.rotate-screen h2{font-family:var(--title);font-weight:700;letter-spacing:-.035em;font-size:30px;line-height:1.2;margin:0}
.rotate-phone{width:114px;height:65px;border:4px solid var(--muted);border-radius:13px;position:relative;display:grid;place-items:center;color:var(--yellow);font-size:47px;transform:rotate(-12deg)}
.rotate-phone::after{content:'';position:absolute;right:5px;top:25px;width:4px;height:12px;background:var(--muted);border-radius:2px}
.rotate-screen .play-button{min-width:190px;margin:6px 0 0;font-size:14px}
@media(hover:hover){
  .icon-button:hover,.overlay-secondary:hover,.quiet-button:hover,.settings-row:hover{background:#2a5860}
  .play-button:hover,#pause-button:hover{background:#ffe3a1}
  .level-button:hover{background:#2d5356;border-color:#bedbc161}
  .cosmetic-card:hover:not(:disabled){background-color:#2b5057;border-color:#d4d5a9}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important}button:not(:disabled):active{transform:none}.touch-controls .touch-actions button.pressed{transform:none}}

/* Sharing stays a secondary result action; its preview uses the existing dialog. */
body:is([data-mode=complete],[data-mode=gameover]) .result-share-button{flex:2.3;color:var(--yellow)}
#share-dialog{padding:0;overflow:hidden}
#share-dialog[open]{display:flex;flex-direction:column}
#share-dialog .panel-content{overflow:auto;min-height:0}
.share-content>p:first-child{margin:0 0 14px;color:var(--muted)}
.share-preview{display:block;width:100%;resize:none;padding:14px;border:1px solid #8cb3a95c;border-radius:14px;background:#102e34;color:var(--ink);font:14px/1.6 var(--font);-webkit-user-select:text;user-select:text;touch-action:auto}
.share-preview:focus-visible{outline:3px solid var(--yellow);outline-offset:3px}
.share-actions,.share-services{display:flex;gap:10px;margin-top:14px}
.share-actions>*{flex:1;min-width:0}
.share-actions .play-button{margin:0;min-height:46px;font-size:13px;padding:10px 14px}
.share-services a{display:flex;align-items:center;justify-content:center;flex:1;gap:6px;text-decoration:none;min-height:44px}
.share-status{margin:12px 0 0;min-height:1.5em;color:var(--muted);font-size:12px;line-height:1.5}
@media(max-height:400px) and (orientation:landscape){
  #share-dialog .panel-heading{padding:12px 20px}
  #share-dialog .panel-content{padding:14px 20px}
  .share-content{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}
  .share-content>p:first-child,.share-preview,.share-status{grid-column:1/-1}
  #share-dialog .share-preview{height:76px;font-size:12px;line-height:1.45;padding:10px}
  .share-content>p:first-child{margin:0;font-size:12px}
  .share-actions,.share-services{margin:0;gap:6px}
  .share-actions .play-button,.share-actions .quiet-button,.share-services a{min-height:44px;padding:8px 6px;font-size:11px}
  .share-status{margin:0}
}
