@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900;1000&display=swap');
:root{color-scheme:dark;--ink:#f8f5ff;--muted:#aaa4c8;--violet:#a78bfa;--cyan:#67e8f9}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Nunito,system-ui,sans-serif;background:radial-gradient(ellipse at 50% 0%,#282052 0%,#100d27 55%,#090817 100%);color:var(--ink)}
body{display:flex;justify-content:center;align-items:center;padding:22px}
.game-shell{width:min(100%,1000px)}
.topbar{height:58px;display:flex;align-items:center;justify-content:space-between;padding:0 5px 14px}
.brand{display:flex;align-items:center;gap:11px;font-weight:1000;letter-spacing:2px;font-size:15px}
.brand-mark{display:grid;place-items:center;width:32px;height:32px;border-radius:11px;background:linear-gradient(135deg,#8b5cf6,#4f46e5);box-shadow:0 5px 20px #8b5cf655;font-size:19px}
.brand small{display:block;font-size:8px;letter-spacing:4px;color:#aaa4c8;margin-top:1px}
.score-pill{display:flex;align-items:center;gap:10px;background:#ffffff0c;border:1px solid #ffffff17;border-radius:30px;padding:7px 13px}
.score-pill span{font-size:9px;letter-spacing:2px;color:var(--muted);font-weight:900}.score-pill b{font-size:13px;letter-spacing:1px}
.game-frame{position:relative;overflow:hidden;border-radius:24px;border:1px solid #ffffff20;box-shadow:0 28px 90px #0008,0 0 0 5px #ffffff05;background:#15112f}
canvas{display:block;width:100%;height:auto;aspect-ratio:8/5;touch-action:none; -webkit-user-select:none;user-select:none}
.hud{position:absolute;inset:18px 20px auto;display:flex;justify-content:space-between;align-items:flex-start;pointer-events:none}
.score small{display:block;color:#c4bde2;font-size:9px;font-weight:900;letter-spacing:2px}.score strong{font-size:27px;letter-spacing:1px;text-shadow:0 2px 15px #0008}
.sound{pointer-events:auto;display:grid;place-items:center;width:36px;height:36px;border:1px solid #ffffff25;border-radius:12px;background:#17132f99;color:#e9ddff;cursor:pointer;font-size:17px}
.overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:25px;background:linear-gradient(180deg,#110e28b8,#100d27e8);backdrop-filter:blur(5px)}
.hidden{display:none}
.eyebrow{font-size:9px;font-weight:1000;letter-spacing:3px;color:#c4b5fd}
.ghost-logo{font-size:66px;line-height:1;margin:13px 0 4px;filter:drop-shadow(0 9px 20px #a78bfa66);animation:bob 2s ease-in-out infinite}
.ghost-logo.sad{filter:grayscale(.2)}
h1,h2{font-size:clamp(36px,7vw,62px);line-height:1;margin:5px 0 0;font-weight:1000;letter-spacing:-2px}
.subtitle{font-size:12px;font-weight:1000;letter-spacing:8px;color:#a78bfa;margin:9px 0 12px 8px}
.overlay p{font-size:13px;color:#c4bfd9;margin:7px 0 20px}
.primary{border:0;border-radius:14px;padding:14px 25px;background:linear-gradient(110deg,#a78bfa,#7c3aed);color:white;font:1000 12px Nunito,sans-serif;letter-spacing:2px;box-shadow:0 8px 28px #8b5cf655;cursor:pointer;transition:transform .15s,filter .15s}
.primary:hover{transform:translateY(-2px);filter:brightness(1.1)}.primary span{margin-left:12px;font-size:17px}
.hint{margin-top:20px;font-size:8px;letter-spacing:1.5px;color:#928bab;font-weight:900}.hint i{font-style:normal;color:#a78bfa;padding:0 7px}
.result{margin:12px 0!important}.result b{color:#fff;font-size:20px}.best-line{font-size:9px;letter-spacing:2px;color:#aaa4c8;margin:-4px 0 20px}.best-line b{color:#fff;margin-left:8px}
footer{display:flex;justify-content:space-between;padding:14px 5px;color:#716b8e;font-size:8px;font-weight:900;letter-spacing:1.6px}
@keyframes bob{0%,100%{transform:translateY(0) rotate(-4deg)}50%{transform:translateY(-9px) rotate(4deg)}}
@media(max-width:600px){body{padding:10px}.topbar{height:49px}.game-frame{border-radius:16px}.hud{inset:12px 13px auto}.score strong{font-size:22px}.overlay{padding:12px}.ghost-logo{font-size:52px}footer{font-size:7px;letter-spacing:.8px}}

.hud-right{display:flex;align-items:center;gap:8px;pointer-events:auto}
.shard-count{display:flex;align-items:center;gap:6px;padding:8px 12px;border:1px solid #f0abfc38;border-radius:12px;background:#25183fbb;color:#f0abfc;font-size:14px;font-weight:1000}
.shard-count b{color:#fff;font-size:12px}
.sound{font-family:Nunito,system-ui,sans-serif}
button.sound{appearance:none}
@media(max-width:600px){.hud-right{gap:5px}.shard-count{padding:7px 9px;font-size:12px}.sound{width:32px;height:32px}}

.gameover-stamp{margin:10px 0 2px;color:#c4b5fd;font-size:9px;font-weight:1000;letter-spacing:2px;animation:stampIn .55s cubic-bezier(.2,1.5,.4,1) both}
.shard-result{font-size:9px;letter-spacing:1.6px;color:#aaa4c8;margin:-10px 0 18px}
.shard-result b{color:#f0abfc;margin-left:7px;font-size:13px}
#gameOverScreen .ghost-logo{animation:gameoverFloat 1.7s ease-in-out infinite}
#gameOverScreen h2{animation:titlePop .45s ease-out both}
@keyframes stampIn{from{opacity:0;transform:scale(.55) rotate(-8deg)}to{opacity:1;transform:scale(1) rotate(0)}}
@keyframes titlePop{from{opacity:0;transform:translateY(12px) scale(.92)}to{opacity:1;transform:translateY(0) scale(1)}}
@keyframes gameoverFloat{0%,100%{transform:translateY(0) rotate(-5deg)}50%{transform:translateY(-8px) rotate(5deg)}}

/* V6 hero refresh: original chubby, rosy-cheeked Little Ghost */
.hero-preview{width:104px;height:112px;margin:12px 0 5px;background-image:url('ghost-sprites.png');background-size:400% 100%;background-repeat:no-repeat;background-position:0 50%;font-size:0;filter:drop-shadow(0 8px 18px #a78bfa75);animation:ghostPreview 1.05s steps(4) infinite}
.hero-preview.sad{filter:grayscale(.15) drop-shadow(0 8px 18px #a78bfa55)}
@keyframes ghostPreview{from{background-position:0 50%}to{background-position:100% 50%}}
@media(max-width:600px){.hero-preview{width:82px;height:90px}}

/* Full-screen arcade mode: show only the game frame. */
html,body{width:100%;height:100%;min-height:100%;margin:0;padding:0;overflow:hidden}
body{display:block;background:#100d27}
.game-shell{position:fixed;inset:0;width:100vw;height:100vh;height:100dvh;max-width:none;margin:0;padding:0}
.topbar,footer{display:none!important}
.game-frame{position:absolute;inset:0;width:100%;height:100%;border:0;border-radius:0;box-shadow:none}
canvas{width:100%;height:100%;aspect-ratio:auto;display:block;touch-action:none}
.hud{inset:clamp(10px,2.2vh,20px) clamp(12px,2vw,24px) auto}
.score-pill.in-game-best{padding:8px 12px;border:1px solid #ffffff25;background:#17132fbb;border-radius:12px;display:flex;align-items:center;gap:8px}
.score-pill.in-game-best span{font-size:9px;letter-spacing:1.7px;color:#c4bde2;font-weight:1000}
.score-pill.in-game-best b{font-size:13px;color:#fff;letter-spacing:1px}
.hud-right{gap:8px}
@media(max-width:600px){
 .hud{inset:9px 10px auto}
 .score strong{font-size:21px}
 .score-pill.in-game-best{padding:7px 9px}
 .hud-right{gap:5px}
 .overlay{padding:12px}
 .hero-preview{width:76px;height:82px;margin:7px 0 2px}
 .overlay p{margin:5px 0 12px}
 .hint{margin-top:12px}
}
@media(max-height:520px){
 .hero-preview{width:68px;height:72px;margin:4px 0 0}
 h1,h2{font-size:clamp(28px,6vh,42px)}
 .subtitle{margin:5px 0 7px}
 .overlay p{margin:4px 0 9px}
 .hint{margin-top:8px}
 .primary{padding:10px 20px}
}

/* Start screen: show one cheerful idle ghost, no sprite-sheet sliding. */
#startScreen .hero-preview{
  animation:none!important;
  background-position:0 50%!important;
}

/* Match the start-screen ghost's floating motion to the game-over ghost. */
#startScreen .hero-preview{
  animation:gameoverFloat 1.7s ease-in-out infinite!important;
  background-position:0 50%!important;
}

/* Mobile-first play comfort */
html,body{overscroll-behavior:none}
@media(max-width:600px){
 body{padding:6px;min-height:100dvh;align-items:center}
 .game-shell{width:100%;max-width:1000px}
 .game-frame{width:100%;border-radius:13px;touch-action:none}
 canvas{width:100%;height:auto;aspect-ratio:8/5;touch-action:none}
 .hud{inset:8px 9px auto}
 .score small{font-size:8px;letter-spacing:1.3px}
 .score strong{font-size:clamp(17px,5vw,22px)}
 .hud-right{gap:4px}
 .score-pill{gap:5px;padding:5px 7px}
 .score-pill span{font-size:7px}
 .score-pill b{font-size:10px}
 .shard-count{padding:5px 7px;border-radius:9px;font-size:11px}
 .shard-count b{font-size:10px}
 .sound{width:29px;height:29px;border-radius:9px;font-size:14px}
 .overlay{padding:10px}
 .overlay p{font-size:11px;margin:5px 0 12px}
 .hint{font-size:8px;line-height:1.6;margin-top:12px}
 .primary{padding:11px 20px}
}
@media(max-width:380px){
 .hud{inset:7px 7px auto}
 .hud-right{gap:3px}
 .score-pill{padding:4px 5px}
 .shard-count{padding:4px 5px}
 .sound{width:26px;height:26px}
}

/* Portrait mobile: keep the 8:5 game stage centered instead of pinning it to the top. */
.game-frame{position:absolute;inset:0;display:block;background:#100d27}
.game-frame>canvas{
 position:absolute;left:50%;top:50%;
 width:min(100vw,160dvh);height:auto;max-width:100%;max-height:100%;
 aspect-ratio:8/5;transform:translate(-50%,-50%);
}
.hud{
 top:calc(50% - min(31.25vw,50dvh));
 left:clamp(9px,2vw,20px);right:clamp(9px,2vw,20px);
}
@media(max-width:600px){
 .game-frame{border-radius:0}
 .game-frame>canvas{width:min(100vw,160dvh);height:auto;max-width:100%;max-height:100%;aspect-ratio:8/5}
 .hud{top:calc(50% - min(31.25vw,50dvh));left:9px;right:9px}
}

/* Desktop/tablet landscape: restore full-width game stage (mobile keeps centered 8:5 stage). */
@media(min-width:601px){
 .game-frame{position:absolute;inset:0;width:100%;height:100%;overflow:hidden}
 .game-frame>canvas{
   position:absolute;inset:0;left:0;top:0;
   width:100%;height:100%;max-width:none;max-height:none;
   aspect-ratio:auto;transform:none;
 }
 .hud{top:clamp(10px,2.2vh,20px);left:clamp(12px,2vw,24px);right:clamp(12px,2vw,24px)}
}
