html, body { height: 100%; margin: 0; overflow: hidden; background: #1b1030; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff3e3;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#wrap { position: relative; width: 100%; height: 100%; overflow: hidden; background: #1b1030; }
canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: inherit; touch-action: manipulation; cursor: pointer; }
.hidden { display: none !important; }
/* home / splash screen: full-bleed splash art, the two logo halves on top, Play at the bottom */
/* The splash art is portrait (1081x1920). #home is a dark purple (baingani) field at 80% opacity and .homeStage is the art, kept
   centred at its own aspect ratio, so landscape screens show blue on either side instead of a cropped image. */
#home { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(52, 14, 78, 0.8); transition: opacity 0.4s; }
.homeStage { height: 100%; aspect-ratio: 1081 / 1920; max-width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 25px 12px 3vh; box-sizing: border-box; background: #3a14c8 url('assets/img/splash.png') center/cover no-repeat; }
#home.gone { opacity: 0; pointer-events: none; }
.homeLogos { display: flex; flex-direction: column; align-items: center; width: 100%; }
.homeLogos .logo { width: 82%; max-width: 360px; height: auto; filter: drop-shadow(0 8px 14px rgba(20,0,60,0.55)); }
.homeLogos .logo1 { transform: rotate(-2deg); position: relative; z-index: 1; }
.homeStage { container-type: inline-size; }
#playBtn { position: relative; top: -50px; border: 0; background: none; padding: 0; width: 32.2cqw; max-width: 133px; animation: playPulse 1.6s ease-in-out infinite; filter: drop-shadow(0 10px 16px rgba(10,0,50,0.6)); }
#playBtn img { display: block; width: 100%; height: auto; }
#playBtn:active { transform: scale(0.92); }
@keyframes playPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* home screen animation + effects (sparkle canvas is drawn by src/home.js) */
.homeStage { position: relative; overflow: hidden; }
.homeFx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.homeLogos, #playBtn { z-index: 2; }
.homeLogos { position: relative; }
/* diagonal light sweep that glides across the art every few seconds */
.homeStage::after { content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 40%; pointer-events: none; z-index: 1;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.28), transparent); transform: skewX(-18deg); animation: homeSweep 5.5s ease-in-out 1.6s infinite; }
@keyframes homeSweep { 0% { left: -60%; } 38%, 100% { left: 140%; } }
/* logos drop in with a bounce, then bob gently (translate is separate from transform, so both can run) */
.homeLogos .logo1 { animation: logoDrop1 0.9s cubic-bezier(.2,1.5,.35,1) both, logoFloat 3.4s ease-in-out 0.9s infinite; }
@keyframes logoDrop1 { from { transform: translateY(-160%) rotate(-14deg) scale(0.6); opacity: 0; } 55% { opacity: 1; } to { transform: translateY(0) rotate(-3deg) scale(1); opacity: 1; } }
@keyframes logoFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
/* Play pops in after the logos and has a soft pulsing halo */
#playBtn { animation: playPulse 1.6s ease-in-out 1.4s infinite, playPop 0.7s cubic-bezier(.2,1.6,.4,1) 0.7s both; }
@keyframes playPop { from { scale: 0; opacity: 0; } to { scale: 1; opacity: 1; } }
#playBtn::before { content: ""; position: absolute; inset: -38%; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(120,220,255,0.75), rgba(120,220,255,0) 62%); animation: playGlow 1.6s ease-in-out 1.4s infinite; }
@keyframes playGlow { 0%, 100% { opacity: 0.45; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  .homeLogos .logo1, #playBtn, #playBtn::before, .homeStage::after { animation: none; }
  .homeStage::after { display: none; }
}
#hud { position: absolute; left: 0; right: 44px; top: 0; height: 52px; display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 10px; box-sizing: border-box; z-index: 3; pointer-events: none; }
#hud > * { pointer-events: auto; }
#lvlBtn { background: #33204f url('assets/img/level-chip.png') center/100% 100% no-repeat; color: #ffffff; text-shadow: 0 1px 2px rgba(60,10,40,0.6); border: 2px solid #5a3d85; border-radius: 12px; height: 36px;
  padding: 0 10px; font-weight: 900; font-size: 15px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#lvlBtn .chip { font-size: 10px; letter-spacing: 1px; text-shadow: none; background: #8a1f55; color: #ffffff; border-radius: 6px; padding: 2px 5px; }
#knives { flex: 1; display: flex; justify-content: center; align-items: center; gap: 3px; min-width: 0; }
#knives i { display: inline-block; width: 17px; height: 34px; background-image: url('assets/img/knife-full.png');
  background-size: contain; background-repeat: no-repeat; background-position: center;
  position: relative; transition: transform 0.2s, opacity 0.2s; }
#knives i.used { background-image: url('assets/img/knife-used.png'); opacity: 0.55; transform: translateY(4px) rotate(-12deg); }
#knives i.bump { animation: kb 0.35s; }
@keyframes kb { 40% { transform: scale(1.5); } }
#count { font-weight: 900; font-size: 15px; color: #0a2f78; text-shadow: 0 1px 0 rgba(255,255,255,0.6); white-space: nowrap; background-image: url('assets/img/counter-pill.png');
  background-size: 100% 100%; border-radius: 10px; padding: 5px 10px; border: 2px solid #5a3d85; }
#count.bump { animation: cb 0.18s; }
@keyframes cb { 50% { transform: scale(1.2); } }
#restartBtn { width: 36px; height: 36px; border-radius: 12px; border: 2px solid #5a3d85; background: #33204f
  url('assets/img/restart-icon.png') center/70% no-repeat; color: transparent; font-size: 18px; font-weight: 900; padding: 0; }
#tip { position: absolute; left: 12px; right: 12px; top: 56px; text-align: center; font-size: 14px; font-weight: 700;
  color: #e0c9ff; z-index: 2; pointer-events: none; line-height: 1.3; min-height: 18px; }
#tip b { color: #ffd23f; }
.ov { position: absolute; left: 0; top: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; text-align: center; padding: 16px; box-sizing: border-box; z-index: 6; }
#title { background: rgba(27, 16, 48, 0.35); pointer-events: none; justify-content: flex-start; padding-top: 8%; transition: opacity 0.35s; }
#title h1 { font-size: 44px; line-height: 1; margin: 0 0 12px; color: #ffd23f; letter-spacing: 1px;
  text-shadow: 0 4px 0 #b8325a, 0 12px 28px rgba(0,0,0,0.6); }
#title .hint { font-size: 19px; font-weight: 900; color: #ffffff; max-width: 320px; margin: 4px 0; text-shadow: 0 2px 6px #000000; }
#title .sub { font-size: 15px; font-weight: 800; color: #ffe45c; max-width: 300px; margin: 4px 0;
  text-shadow: 0 0 3px #000000, 0 0 3px #000000, 0 2px 4px #000000, 0 3px 10px rgba(0,0,0,0.9); }
#title.gone { opacity: 0; }
.dim { background: rgba(14, 8, 28, 0.76); }
/* modal-card.png is 9-sliced as a border image so the rounded corners stay crisp at any card height */
/* modal-card.png is a ribbon panel (1007x847): sliced so the ribbon header and the panel edges keep their size and only the middle stretches */
.card { width: min(400px, 97%); background: linear-gradient(#ffa9c1, #ffcf86) no-repeat 46px 92px / calc(100% - 92px) calc(100% - 114px); border: solid transparent; border-width: 112px 46px 26px; border-image: url('assets/img/modal-card.png') 340 170 70 fill / 112px 46px 26px stretch; border-radius: 0; padding: 2px 22px 22px;
  box-sizing: border-box; filter: drop-shadow(0 14px 22px rgba(0,0,0,0.55)); }
#winCard { animation: winGlow 2.2s ease-in-out infinite; }
@keyframes winGlow { 0%, 100% { filter: drop-shadow(0 14px 22px rgba(0,0,0,0.55)) drop-shadow(0 0 10px rgba(255,210,63,0.3)); } 50% { filter: drop-shadow(0 14px 22px rgba(0,0,0,0.55)) drop-shadow(0 0 22px rgba(255,210,63,0.6)); } }
.btn:active, .shop button:active, #lvGrid button:active, #restartBtn:active, #lvlBtn:active { transform: scale(0.94); }
.btn, .shop button, #lvGrid button, #restartBtn, #lvlBtn { transition: transform 0.12s; }
#title h1 { animation: titlePulse 2.4s ease-in-out infinite; }
@keyframes titlePulse { 0%, 100% { text-shadow: 0 4px 0 #b8325a, 0 12px 28px rgba(0,0,0,0.6); } 50% { text-shadow: 0 4px 0 #b8325a, 0 12px 36px rgba(255,210,63,0.55); } }
.card h2 { margin: 0 0 2px; font-size: 34px; font-weight: 900; color: #ffffff; text-shadow: 0 3px 0 #c2417a, 0 0 6px rgba(150,30,90,0.6); }
.card h3 { margin: 0 0 6px; font-size: 28px; font-weight: 900; color: #ffffff; text-shadow: 0 3px 0 #c2417a, 0 0 6px rgba(150,30,90,0.6); }
#failHead { text-transform: capitalize; }
/* titles sit on the card's ribbon; the negative bottom margin pulls the content up into the space they leave */
#winHead, #failHead, #pauseHead { position: relative; top: -104px; margin-bottom: -78px; text-transform: uppercase; color: #b70000; text-shadow: 0 2px 0 rgba(255,255,255,0.55), 0 0 6px rgba(255,255,255,0.6); white-space: nowrap; }
.failFx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.line.tapRetry { color: #b70000; text-shadow: 0 1px 0 rgba(255,255,255,0.55), 0 0 6px rgba(255,255,255,0.6); margin-top: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.pop { animation: popIn 0.45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#winLine, #winCoins { display: none; }
#stars { font-size: 58px; letter-spacing: 6px; margin: 4px 0 14px; white-space: nowrap; }
#stars span { display: inline-block; width: 70px; height: 70px; color: transparent; background: url('assets/img/star-off.png') center/contain no-repeat; }
#stars span.on { background-image: url('assets/img/star-on.png'); animation: popIn 0.4s cubic-bezier(.2,1.8,.4,1) both; filter: drop-shadow(0 0 10px rgba(255,210,63,0.7)); }
.line { font-size: 16px; font-weight: 900; color: #b70000; text-shadow: 0 1px 0 rgba(255,255,255,0.55), 0 0 6px rgba(255,255,255,0.6); margin: 3px 0; line-height: 1.3; }
.line b { color: #ffe45c; text-shadow: 0 1px 3px rgba(32, 6, 76, 0.95), 0 0 2px rgba(32, 6, 76, 0.7); }
.big { font-size: 22px; font-weight: 900; color: #0a3d91; text-shadow: 0 1px 0 rgba(255,255,255,0.7), 0 0 6px rgba(255,255,255,0.7); }
.bar { position: relative; height: 20px; background: #1b1030; border-radius: 10px; margin: 10px 0 6px; overflow: visible; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #5ee08a url('assets/img/progress-fill.png') center/100% 100% no-repeat; border-radius: 10px; transition: width 0.6s; }
.bar u { position: absolute; top: -4px; bottom: -4px; width: 3px; background: #ffd23f; border-radius: 2px; }
.btn { display: block; width: 100%; height: 44px; border-radius: 12px; border: 0; margin-top: 8px; font-size: 17px; font-weight: 900; }
.btn.go { background: #3fb4ff url('assets/img/btn-go.png') center/100% 100% no-repeat; color: #ffffff; text-shadow: 0 2px 3px rgba(10,40,120,0.75); box-shadow: 0 4px 0 #3a7fd0; }
.btn.fix { background: #26dcc4 url('assets/img/btn-fix.png') center/100% 100% no-repeat; color: #04403a; box-shadow: 0 4px 0 #14907f; font-size: 14px; height: 48px; line-height: 1.15; }
.btn.fix small { display: block; font-size: 11px; font-weight: 700; opacity: 0.75; }
.btn.fix:disabled { background: #4f3a70; color: #9c89c0; box-shadow: none; }
.btn.ghost { background: transparent; color: #ffffff; text-shadow: 0 1px 3px rgba(32, 6, 76, 0.9); border: 2px solid #4a2a85; height: 40px; font-size: 14px; }
#winRetry { background: #2a2af0 url('assets/img/counter-pill.png') center/100% 100% no-repeat; color: #ffffff; text-shadow: 0 2px 2px rgba(10,10,90,0.6); border: 0; box-shadow: 0 4px 0 #1a1a9a; }
.row2 { display: flex; gap: 8px; }
.row2 .btn { height: 40px; font-size: 15px; }
.row2 .btn { flex: 1; }
.shop { display: flex; gap: 5px; margin-top: 6px; }
.shop button { flex: 1; min-width: 0; height: 42px; border-radius: 10px; border: 2px solid #5a3d85; background: #33204f; color: #fff3e3; font-weight: 800; font-size: 10px; line-height: 1.2; padding: 0 1px 0 19px; position: relative; letter-spacing: -0.2px; }
.shop button::before { content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 13px; height: 26px;
  background: url('assets/img/blade-shop-thumb.png') center/contain no-repeat; }
.shop button.on { border-color: #ffd23f; background: #4a3170; }
.shop button:disabled { opacity: 0.45; }
.coinIcon { width: 15px; height: 15px; vertical-align: -3px; margin: 0 1px; }
#lvGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; max-height: 50vh; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
#levels .card { max-height: 88vh; display: flex; flex-direction: column; }
#lvGrid button { height: 58px; border-radius: 12px; border: 2px solid #5a3d85; background: #33204f url('assets/img/level-node.png') center/100% 100%; color: #fff3e3;
  font-weight: 900; font-size: 18px; padding: 0; line-height: 1.1; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
#lvGrid button small { display: block; font-size: 10px; color: #ffd23f; letter-spacing: 1px; }
#lvGrid button.hard { border-color: #ff4f7b; }
#lvGrid button:disabled { opacity: 0.35; }
#lvGrid button .lockIcon { display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  background: url('assets/img/lock-icon.png') center/contain no-repeat; }
#peelBar { position: absolute; left: 12px; right: 12px; bottom: 16px; z-index: 5; display: flex; gap: 8px; align-items: center;
  background: #3fe0c8 url('assets/img/peel-banner.png') center/100% 100% no-repeat; color: #04403a; border-radius: 14px; padding: 10px 14px; font-weight: 900; font-size: 15px; }
#peelBar span { flex: 1; }
#peelBar button { background: #3a2a00; color: #ffd23f; border: 0; border-radius: 10px; height: 34px; padding: 0 12px; font-weight: 900; }
#dbgBtn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 10px; z-index: 8;
  border: 1px solid #5a3d85; background: rgba(42, 26, 71, 0.85); color: #e0c9ff; font: 700 13px system-ui, sans-serif; padding: 0; }
#dbg { position: absolute; top: 46px; right: 8px; z-index: 8; background: rgba(0,0,0,0.82); color: #9ff3ff;
  font: 11px ui-monospace, Menlo, Consolas, monospace; padding: 8px; border-radius: 8px; white-space: pre; text-align: left; max-width: 250px; }
#dbg button { margin: 6px 4px 0 0; font: 700 11px system-ui; background: #33204f; color: #fff3e3; border: 1px solid #5a3d85; border-radius: 6px; padding: 4px 6px; }

/* win card buttons at 88% size, centred; Next box has 11px extra space above */
#nextBtn { width: 88%; height: 39px; font-size: 15px; margin: 19px auto 0; }
#winCard .row2 { width: 88%; margin: 8px auto 0; }
#winCard .row2 .btn { height: 35px; font-size: 13px; margin-top: 0; }

/* game-over card: only the title, progress, Retry and the two fix buttons are shown */
#failLine, #failWhy, #fail .tapRetry { display: none; }
.failPct { color: #0a3d91; text-shadow: 0 1px 0 rgba(255,255,255,0.7), 0 0 6px rgba(255,255,255,0.7); }

/* game-over card buttons: 90% width, centred; Retry sits 10px lower under the progress bar */
#fail .btn { width: 90%; margin-left: auto; margin-right: auto; }
#retryBtn { margin-top: 18px; }
#failHead { top: -99px; }

/* ---- settings, pause popup and sound buttons (UI button art: assets/img/ui-*.png) ---- */
#settingsBtn { flex: none; width: 38px; height: 38px; border: 0; padding: 0; background: url('assets/img/ui-settings.png') center/contain no-repeat; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5)); }
#settingsBtn:active { transform: scale(0.92); }
#knives i { flex: 0 1 17px; min-width: 9px; }
#homeSound { position: absolute; top: 10px; right: 10px; z-index: 3; width: 46px; height: 46px; border: 0; padding: 0; background: url('assets/img/ui-sound-on.png') center/contain no-repeat; filter: drop-shadow(0 3px 5px rgba(10,0,50,0.55)); }
#homeSound.off, #pauseSound.off { background-image: url('assets/img/ui-sound-off.png'); }
#homeSound:active { transform: scale(0.92); }
#pause { z-index: 9; }
#pauseHead { text-align: center; }
.pRow { display: flex; justify-content: center; gap: 8px; padding: 8px 0 6px; }
.pItem { flex: 1; max-width: 70px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pBtn { width: 100%; aspect-ratio: 1; border: 0; padding: 0; background: center/contain no-repeat; filter: drop-shadow(0 3px 4px rgba(120,20,60,0.4)); transition: transform 0.12s; }
.pBtn:active { transform: scale(0.9); }
#pauseSound { background-image: url('assets/img/ui-sound-on.png'); }
#pauseHome { background-image: url('assets/img/ui-home.png'); }
#pauseRestart { background-image: url('assets/img/ui-restart.png'); }
#pausePlay { background-image: url('assets/img/ui-play.png'); }
.pItem span { font-size: 11px; font-weight: 900; color: #b70000; text-shadow: 0 1px 0 rgba(255,255,255,0.6); letter-spacing: 0.3px; }
#pauseCard { padding-bottom: 0; }

/* narrow phones: the extra gear button needs room, so the HUD goes compact (Restart is also in the pause popup) */
@media (max-width: 400px) {
  #hud { gap: 5px; padding-left: 8px; }
  #restartBtn { display: none; }
  #settingsBtn { width: 34px; height: 34px; }
  #knives { gap: 1px; }
  #knives i { min-width: 7px; }
  #count { padding: 5px 6px; }
}

/* the level list is gone, so the Lv chip is just a label */
#hud > #lvlBtn { pointer-events: none; cursor: default; }
