:root {
  --ink: #1b1424;
  --cream: #fff6e2;
  --green: #8fd14a;
  --green-d: #4f8f23;
  --red: #e2473a;
  --gold: #ffcc33;
  --panel: rgba(27, 20, 36, .88);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; color: var(--cream); font-family: Nunito, system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hidden { display: none !important; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, transparent 62%, rgba(60, 34, 14, .22) 90%, rgba(40, 22, 10, .42)); }
button { font: inherit; cursor: pointer; border: 0; }

/* ---------------------------------------------------------------- logo */
.logo { font-family: Bangers, Impact, sans-serif; font-size: clamp(64px, 13vw, 150px); line-height: .9; letter-spacing: .03em; display: flex; gap: .08em; transform: rotate(-4deg); }
.logo span { color: var(--green); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink), 0 14px 24px rgba(0, 0, 0, .45); }
.logo span + span { color: #f6a0b2; }
.logo.small { font-size: 56px; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; background: radial-gradient(ellipse at center, rgba(20, 14, 30, .25), rgba(20, 14, 30, .78)); }
.tag { margin: 0; font-weight: 800; font-size: clamp(15px, 2.4vw, 22px); text-shadow: 0 2px 0 var(--ink); text-align: center; }
.how { margin: 0; opacity: .85; font-weight: 700; font-size: 14px; text-align: center; text-shadow: 0 1px 0 var(--ink); }
.big { font-family: Bangers, Impact, sans-serif; font-size: 40px; letter-spacing: .06em; padding: 10px 56px 6px; border-radius: 18px; color: var(--ink); background: linear-gradient(#b4ee6c, var(--green)); box-shadow: 0 6px 0 var(--green-d), 0 10px 22px rgba(0, 0, 0, .4); transition: transform .08s; }
.big:hover { transform: translateY(-2px) scale(1.03); }
.big:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--green-d); }

#levels { justify-content: flex-start; overflow-y: auto; background: rgba(20, 14, 30, .82); padding-top: 12px; }
#levels .bar { width: min(980px, 100%); display: flex; align-items: center; gap: 16px; }
#levels h2 { font-family: Bangers, Impact, sans-serif; font-size: 38px; letter-spacing: .04em; margin: 0; }
#btnBack { padding: 8px 16px; border-radius: 12px; background: rgba(255, 255, 255, .12); color: var(--cream); font-weight: 800; }
#worlds { width: min(980px, 100%); display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.world { border-radius: 18px; padding: 14px 16px 16px; border: 3px solid rgba(0, 0, 0, .35); box-shadow: 0 6px 0 rgba(0, 0, 0, .3); }
.world.w0 { background: linear-gradient(135deg, #3b86c4, #6fb4e0); }
.world.w1 { background: linear-gradient(135deg, #4a525e, #78818d); }
.world.w2 { background: linear-gradient(135deg, #2b2050, #5a3d86); }
.world.w3 { background: linear-gradient(135deg, #7a3a24, #c0703e); }
.world header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
.world h3 { font-family: Bangers, Impact, sans-serif; font-size: 30px; letter-spacing: .04em; margin: 0; text-shadow: 0 2px 0 var(--ink); }
.world .tally { font-weight: 900; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.world p { margin: 0; flex-basis: 100%; font-weight: 700; opacity: .9; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; }
.lvl { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; border-radius: 14px; background: var(--cream); color: var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); transition: transform .08s; }
.lvl:hover { transform: translateY(-2px); }
.lvl .n { font-family: Bangers, Impact, sans-serif; font-size: 30px; line-height: 1; }
.lvl .name { font-weight: 800; font-size: 13px; text-align: center; }
.lvl .st { color: #f0a800; font-size: 18px; letter-spacing: 2px; -webkit-text-stroke: 1px #a06a00; }
.lvl .st i { font-style: normal; color: #d9cdb4; -webkit-text-stroke: 1px #b3a68c; }
.lvl.locked { background: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .7); cursor: default; box-shadow: none; }
.lvl.locked:hover { transform: none; }

/* ---------------------------------------------------------------- hud */
#hud { position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud .chip { display: flex; flex-direction: column; background: var(--panel); padding: 6px 14px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, .12); }
#hud .chip span { font-size: 12px; font-weight: 800; opacity: .75; text-transform: uppercase; letter-spacing: .06em; }
#hud .chip b { font-family: Bangers, Impact, sans-serif; font-size: 24px; letter-spacing: .04em; font-weight: 400; }
#shells { display: flex; align-items: center; gap: 2px; background: var(--panel); padding: 4px 12px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, .12); min-height: 48px; }
.shell { width: 34px; height: 34px; transition: opacity .2s, transform .2s; }
.shell.spent { opacity: .22; filter: grayscale(1); transform: scale(.8); }
.par { margin-left: 8px; font-size: 12px; font-weight: 900; color: var(--gold); white-space: nowrap; }
.btns { display: flex; gap: 6px; }
.btns button { width: 46px; height: 46px; border-radius: 14px; background: var(--panel); color: var(--cream); font-size: 22px; border: 2px solid rgba(255, 255, 255, .12); }
.btns button:hover { background: rgba(60, 44, 80, .95); }
#hint { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; transition: opacity .35s, transform .35s; background: var(--panel); padding: 10px 20px; border-radius: 999px; font-weight: 800; pointer-events: none; text-align: center; max-width: calc(100% - 32px); }
#hint.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- result */
#result { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 10, 22, .45); animation: fade .3s; }
#result .card { width: min(420px, 100%); background: var(--cream); color: var(--ink); border-radius: 24px; padding: 20px 22px 22px; text-align: center; border: 4px solid var(--ink); box-shadow: 0 10px 0 var(--ink), 0 20px 40px rgba(0, 0, 0, .5); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
#result h2 { font-family: Bangers, Impact, sans-serif; font-size: 40px; letter-spacing: .04em; margin: 0 0 6px; font-weight: 400; }
#result.fail h2 { color: var(--red); }
#result.win h2 { color: var(--green-d); }
#resStars { font-size: 64px; line-height: 1; height: 70px; }
#resStars:empty { height: 0; }
.star { display: inline-block; color: #d9cdb4; -webkit-text-stroke: 2px #b3a68c; }
.star.got { color: var(--gold); -webkit-text-stroke: 2px #a06a00; animation: star .45s cubic-bezier(.2, 1.8, .4, 1) both; }
#resText { font-weight: 700; margin: 8px 0 16px; }
.row { display: flex; gap: 8px; justify-content: center; }
.row button { flex: 1; padding: 10px 6px; border-radius: 14px; font-weight: 900; font-size: 16px; background: #e6dcc6; color: var(--ink); box-shadow: 0 4px 0 #b3a68c; }
.row button.go { background: linear-gradient(#b4ee6c, var(--green)); box-shadow: 0 4px 0 var(--green-d); }
.row button:active { transform: translateY(2px); box-shadow: 0 2px 0 #b3a68c; }

/* ---------------------------------------------------------------- loading */
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; background: #1b1424; }
.track { width: min(320px, 70vw); height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; }
#loadBar { width: 0; height: 100%; background: var(--green); transition: width .2s; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 640px) {
  #hud:not(.hidden) ~ #rotate { display: block; position: fixed; left: 16px; right: 16px; bottom: 16px; text-align: center; background: var(--panel); padding: 10px 14px; border-radius: 14px; font-weight: 800; font-size: 14px; pointer-events: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes star { from { transform: scale(0) rotate(-90deg); } }

@media (max-width: 640px) {
  #hud { flex-wrap: wrap; padding: 8px; }
  #hud .chip b { font-size: 18px; }
  #hud .lvl { padding: 4px 10px; }
  .shell { width: 24px; height: 24px; }
  #shells { min-height: 38px; padding: 2px 8px; order: 3; }
  .btns button { width: 40px; height: 40px; font-size: 18px; }
  .par { display: none; }
}

/* ---------------------------------------------------------------- title screen */
#title { background: radial-gradient(ellipse at 50% 40%, rgba(20, 12, 8, .05), rgba(20, 12, 8, .55)); gap: 14px; justify-content: flex-start; padding-top: 11vh; }
.bar-top, .bar-bottom { position: absolute; left: 0; right: 0; height: 7vh; background: #0b0806; animation: bars .8s ease-out both; }
.bar-top { top: 0; } .bar-bottom { bottom: 0; transform-origin: bottom; }
#logo { font-size: clamp(70px, 14vw, 190px); transform: rotate(-4deg); gap: 0; margin-bottom: 4px; }
#logo .l { position: relative; display: inline-block; color: var(--green); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 9px 0 var(--ink), 0 16px 30px rgba(0, 0, 0, .55);
  animation: drop .7s cubic-bezier(.3, 1.6, .5, 1) both, wobble 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * .07s), calc(.9s + var(--i) * .13s); }
#logo .l.less { color: #f6a0b2; }
#logo .l:nth-child(5) { margin-right: .1em; }
.drip { position: absolute; top: 80%; left: var(--x); width: .045em; border-radius: 0 0 .03em .03em; background: linear-gradient(#7a0c0a, #b0140f); box-shadow: 0 0 0 2px var(--ink);
  height: 0; animation: drip 3.2s ease-in infinite; animation-delay: calc(1.2s + var(--d)); }
.drip::after { content: ''; position: absolute; left: 50%; bottom: -.04em; width: .07em; height: .08em; margin-left: -.035em; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #b0140f; }
#tagline { transition: opacity .35s, transform .35s; min-height: 1.4em; font-size: clamp(16px, 2.5vw, 24px); }
#tagline.swap { opacity: 0; transform: translateY(8px); }
.menu { display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
#btnPlay { animation: pulse 1.6s ease-in-out infinite; display: flex; flex-direction: column; align-items: center; line-height: 1; }
#btnPlay small { font-family: Nunito, sans-serif; font-size: 13px; letter-spacing: 0; font-weight: 900; opacity: .75; margin-top: 4px; }
.ghost { font-family: Bangers, Impact, sans-serif; font-size: 28px; letter-spacing: .06em; padding: 10px 30px 6px; border-radius: 16px; color: var(--cream);
  background: rgba(27, 20, 36, .7); border: 3px solid rgba(255, 246, 226, .5); box-shadow: 0 5px 0 rgba(0, 0, 0, .4); transition: transform .08s; }
.ghost:hover { transform: translateY(-2px); background: rgba(40, 30, 50, .85); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.stats span { background: rgba(27, 20, 36, .72); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 14px; }
.stats b { color: var(--gold); }
#title .how { position: absolute; bottom: calc(7vh + 12px); }
#fade { position: fixed; inset: 0; background: #0b0806; opacity: 0; pointer-events: none; transition: opacity .35s; }
#fade.on { opacity: 1; }
@keyframes drop { from { transform: translateY(-120%) scale(1, 1.4); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-6px) rotate(-3deg); } 75% { transform: translateY(3px) rotate(2deg); } }
@keyframes drip { 0% { height: 0; opacity: 1; } 60% { height: .22em; opacity: 1; } 85% { height: .26em; opacity: 1; } 100% { height: .26em; opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bars { from { transform: scaleY(0); } }
@media (max-width: 640px) { #title { padding-top: 9vh; } .bar-top, .bar-bottom { height: 4vh; } .ghost { font-size: 22px; } #title .how { display: none; } }

/* ---------------------------------------------------------------- hint */
#btnHint { position: relative; }
#btnHint i { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold); color: var(--ink);
  font: 900 12px/18px Nunito, sans-serif; font-style: normal; text-align: center; box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
#btnHint.spent { opacity: .5; }
#btnHint.spent i { background: #8a8091; }
#hintTip { position: fixed; left: 50%; top: 78px; transform: translate(-50%, -10px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  background: var(--panel); padding: 8px 18px; border-radius: 999px; font-weight: 900; text-align: center; max-width: calc(100% - 32px); border: 2px solid transparent; }
#hintTip.on { opacity: 1; transform: translate(-50%, 0); }
#hintTip.show { border-color: var(--gold); }
#hintTip.think::after { content: ''; display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 3px solid var(--gold); border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: spin .7s linear infinite; }
#hintTip.fire { background: var(--gold); color: var(--ink); font-family: Bangers, Impact, sans-serif; font-size: 30px; letter-spacing: .08em; padding: 4px 28px; }
.lvl .walk { font-style: normal; font-size: .85em; }
@keyframes spin { to { transform: rotate(360deg); } }

#usedHint, #resHint { font: 900 14px/1 Nunito, sans-serif; color: var(--ink); background: var(--gold); border-radius: 999px; padding: 6px 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35); white-space: nowrap; }
#usedHint { position: fixed; left: 16px; top: 74px; animation: pulse 1.6s ease-in-out 2; }
#usedHint.hidden, #resHint.hidden { display: none; }
#resHint { display: inline-block; margin: 2px auto 8px; }

#result.finale .card { border-color: var(--gold); box-shadow: 0 10px 0 var(--ink), 0 0 0 6px rgba(255, 204, 51, .35), 0 20px 40px rgba(0, 0, 0, .5); }
#result.finale h2 { color: #c07a00; }
#result .trophy { display: block; font-size: 56px; line-height: 1; margin: 4px 0 8px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) .3s both; }
