/* Layout: full-screen canvas; in portrait the touch pad sits in its own panel under the game,
   in landscape the pad floats over the bottom corners. One committed dark "workshop" look. */
:root {
  --ink: #14182b;
  --ink-2: #0b0e1c;
  --panel: #1d2340;
  --panel-2: #283062;
  --line: rgba(255, 255, 255, .14);
  --text: #f4f1e8;
  --muted: #aab1cf;
  --gold: #ffc727;
  --gold-d: #a87400;
  --red: #e0302a;
  --green: #4cd964;
  --pipe: #3fae4a;
  --display: "Russo One", "Arial Black", Impact, system-ui, sans-serif;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sat: max(env(safe-area-inset-top, 0px), var(--tgs-top, 0px));
  --sab: max(env(safe-area-inset-bottom, 0px), var(--tgs-bottom, 0px));
  --sal: max(env(safe-area-inset-left, 0px), var(--tgs-left, 0px));
  --sar: max(env(safe-area-inset-right, 0px), var(--tgs-right, 0px));
  --ctrl-h: calc(178px + var(--sab));
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%; overflow: hidden;
  background: var(--ink); color: var(--text);
  font-family: var(--body); font-size: 15px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: none;
}
#app { position: fixed; inset: 0; overflow: hidden; background: var(--ink); }
#game { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ touch pad */
#controls { position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 5; }
.cluster { position: absolute; bottom: calc(14px + var(--sab)); display: flex; gap: 14px; align-items: flex-end; }
.cluster.left { left: calc(16px + var(--sal)); }
.cluster.right { right: calc(16px + var(--sar)); }
.pad {
  pointer-events: auto; touch-action: none;
  width: 76px; height: 76px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, rgba(70, 86, 150, .78), rgba(20, 26, 52, .82));
  border: 3px solid rgba(225, 232, 255, .72);
  box-shadow: 0 5px 0 rgba(5, 8, 20, .7), inset 0 2px 0 rgba(255, 255, 255, .25);
  transition: transform .06s, box-shadow .06s, background .06s;
}
.pad svg { width: 52%; height: 52%; fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.pad .fillw { fill: #fff; stroke: none; }
.pad.on { transform: translateY(3px) scale(.95); box-shadow: 0 2px 0 rgba(5, 8, 20, .7), 0 0 0 5px rgba(255, 199, 39, .35); background: radial-gradient(circle at 50% 35%, rgba(255, 199, 39, .9), rgba(190, 120, 10, .9)); border-color: #fff3c4; }
.pad.jmp { width: 86px; height: 86px; }
.pad.atk { margin-bottom: 34px; }
body:not(.in-game) .pad, body:not(.in-game) #stick-zone { visibility: hidden; }
/* Mobile-Legends style floating joystick: touch anywhere in the left zone */
#stick-zone { position: absolute; left: 0; bottom: 0; width: 50%; height: 100%; pointer-events: auto; touch-action: none; }
body.landscape #controls { top: 30%; }
body.landscape #stick-zone { width: 46%; }
#stick-base {
  position: absolute; left: 0; top: 0; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .05) 40%, rgba(255, 255, 255, .14) 70%, rgba(255, 255, 255, .06));
  border: 2px solid rgba(255, 255, 255, .38); box-shadow: 0 0 0 1px rgba(0, 0, 0, .18), inset 0 0 18px rgba(120, 190, 255, .18);
  opacity: .55; transition: opacity .15s; pointer-events: none;
}
#stick-base::before { content: ""; position: absolute; inset: 26%; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .22); }
#stick-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, .7), rgba(170, 210, 255, .38) 60%, rgba(90, 140, 220, .3));
  border: 2px solid rgba(255, 255, 255, .7); box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
#stick-base.active { opacity: 1; transition: none; }
.pad { background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .26), rgba(120, 170, 255, .12)) !important; border: 2px solid rgba(255, 255, 255, .55) !important; box-shadow: 0 2px 10px rgba(0, 0, 0, .3) !important; }
.pad.on { background: radial-gradient(circle at 50% 35%, rgba(255, 220, 120, .75), rgba(255, 170, 40, .45)) !important; border-color: #fff3c4 !important; }
body.portrait #stick-base { width: 120px; height: 120px; margin: -60px 0 0 -60px; }

body.portrait #controls {
  height: var(--ctrl-h);
  background:
    radial-gradient(circle at 12px 12px, rgba(255,255,255,.08) 2px, transparent 2.5px) 0 0 / 46px 46px,
    linear-gradient(180deg, #232a4d, #12162a);
  border-top: 3px solid #0a0d1a;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .08);
}
body.portrait .cluster { bottom: calc(26px + var(--sab)); }
body.portrait .pad { width: 80px; height: 80px; }
body.portrait .pad.jmp { width: 92px; height: 92px; }
body.landscape .pad { opacity: .92; }
@media (max-height: 380px) { body.landscape .pad { width: 66px; height: 66px; } body.landscape .pad.jmp { width: 76px; height: 76px; } body.landscape .pad.atk { margin-bottom: 26px; } }

/* ------------------------------------------------------------ HUD */
#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4; pointer-events: none;
  padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal));
}
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-group.end { gap: 10px; }
.lives, .nuts, .score, .keys, .hearts {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(14, 18, 38, .72); border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 999px; padding: 3px 9px 3px 4px; font-family: var(--display); font-size: 15px;
  text-shadow: 0 2px 0 #000; font-variant-numeric: tabular-nums;
}
.hearts, .keys { padding: 3px 7px; gap: 2px; }
.score { padding: 4px 10px; letter-spacing: .04em; }
.face { width: 28px; height: 28px; border-radius: 50%; background: #2a3a60 url("assets/face.webp") center 18% / 118% no-repeat; background-image: image-set(url("assets/face.webp") type("image/webp"), url("assets/face.webp") type("image/png")); border: 2px solid #1c1726; flex: none; }
.nut { width: 20px; height: 20px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='12,1 22,6.5 22,17.5 12,23 2,17.5 2,6.5' fill='%23ffc727' stroke='%231c1726' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='4.2' fill='%237a5410' stroke='%231c1726' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat; }
.hh, .hs { width: 20px; height: 18px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 20.5C2.5 13 .5 8.5 3 4.5 5.8.3 10 1.2 12 5c2-3.8 6.2-4.7 9-.5 2.5 4 .5 8.5-9 16z' fill='%23ff3b4e' stroke='%231c1726' stroke-width='2'/%3E%3C/svg%3E") center/contain no-repeat; }
.hh.empty { filter: grayscale(1) brightness(.45); }
.hs { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5 21.5 5l-1 8.5c-1.5 4.5-5 7-8.5 8.5-3.5-1.5-7-4-8.5-8.5L2.5 5z' fill='%234fb8ff' stroke='%231c1726' stroke-width='2'/%3E%3C/svg%3E"); }
.kc { width: 22px; height: 14px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 16'%3E%3Ccircle cx='7' cy='8' r='5.5' fill='%23454b66' stroke='%231c1726' stroke-width='2'/%3E%3Cpath d='M12 6.5h13v3h-2v3h-3v-3h-2v2h-3v-2h-3z' fill='%23454b66' stroke='%231c1726' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat; display: inline-block; }
.kc.got { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 16'%3E%3Ccircle cx='7' cy='8' r='5.5' fill='%23ffc727' stroke='%231c1726' stroke-width='2'/%3E%3Ccircle cx='7' cy='8' r='2' fill='%237a5410'/%3E%3Cpath d='M12 6.5h13v3h-2v3h-3v-3h-2v2h-3v-2h-3z' fill='%23ffc727' stroke='%231c1726' stroke-width='1.5'/%3E%3C/svg%3E"); }
.pausebtn {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(14, 18, 38, .78); border: 2px solid rgba(255, 255, 255, .35);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0;
}
.pausebtn i { width: 6px; height: 18px; background: #fff; border-radius: 2px; }
.power { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px 3px 4px; border-radius: 999px; background: rgba(14, 18, 38, .78); border: 2px solid rgba(120, 210, 255, .55); font-family: var(--display); font-size: 13px; text-shadow: 0 1px 0 #000; }
.chip i, .ic { width: 20px; height: 20px; display: inline-block; background: center/contain no-repeat; flex: none; }
.wrench i, .ic.wrench { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M27.5 5.5a8 8 0 0 0-8.6 10.7L7.6 27.5a3.2 3.2 0 0 0 4.5 4.5l11.3-11.3A8 8 0 0 0 34 12.3l-4.9 4.9-4.4-1.2-1.2-4.4 4.9-4.9z' fill='%23ffd23f' stroke='%231c1726' stroke-width='2.5'/%3E%3C/svg%3E"); }
.chip.wrench { border-color: rgba(255, 210, 63, .7); }
.hydro i, .ic.hydro { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='7' y='2' width='10' height='16' rx='4' fill='%233aa0e6' stroke='%231c1726' stroke-width='2'/%3E%3Cpath d='M7 12l-4 6h4zM17 12l4 6h-4z' fill='%23ff6b4a' stroke='%231c1726' stroke-width='1.5'/%3E%3Ccircle cx='12' cy='21' r='2' fill='%237fd3ff'/%3E%3C/svg%3E"); }
.plunger i, .ic.plunger { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='10.5' y='1' width='3' height='13' rx='1' fill='%23c58a3f' stroke='%231c1726' stroke-width='1.5'/%3E%3Cpath d='M4 22c0-6 3-8 8-8s8 2 8 8z' fill='%23e0302a' stroke='%231c1726' stroke-width='2'/%3E%3C/svg%3E"); }
.chip.plunger { border-color: rgba(255, 110, 90, .7); }
.goldpipe i, .ic.goldpipe { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4' y='8' width='16' height='9' rx='2' fill='%23ffc727' stroke='%231c1726' stroke-width='2'/%3E%3Crect x='2' y='6' width='5' height='13' rx='1.5' fill='%23ffe680' stroke='%231c1726' stroke-width='2'/%3E%3Crect x='17' y='6' width='5' height='13' rx='1.5' fill='%23ffe680' stroke='%231c1726' stroke-width='2'/%3E%3C/svg%3E"); }
.chip.goldpipe { border-color: rgba(255, 199, 39, .7); padding-right: 4px; }
.ic.gloves { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5 21.5 5l-1 8.5c-1.5 4.5-5 7-8.5 8.5-3.5-1.5-7-4-8.5-8.5L2.5 5z' fill='%232f8ef0' stroke='%231c1726' stroke-width='2'/%3E%3Crect x='8' y='7' width='8' height='9' rx='3' fill='%23f08c2a' stroke='%231c1726' stroke-width='1.5'/%3E%3C/svg%3E"); }

#bossbar {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(64px + var(--sat)); z-index: 4;
  width: min(320px, 70vw); text-align: center; pointer-events: none;
  font-family: var(--display); font-size: 13px; text-shadow: 0 2px 0 #000; letter-spacing: .05em; text-transform: uppercase;
}
#bossbar .track { height: 12px; margin-top: 3px; border-radius: 999px; background: rgba(0, 0, 0, .6); border: 2px solid #fff; overflow: hidden; }
#bossfill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3b4e, #ff8a3a); transition: width .25s; }

#banner {
  position: absolute; left: 0; right: 0; top: 34%; z-index: 4; text-align: center; pointer-events: none;
  opacity: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#banner .bn { font-family: var(--body); font-weight: 700; letter-spacing: .3em; text-transform: uppercase; font-size: 13px; color: var(--gold); text-shadow: 0 2px 0 #000; }
#banner .bt { font-family: var(--display); font-size: clamp(30px, 8vw, 54px); text-shadow: 0 4px 0 #1c1726, 0 0 24px rgba(0, 0, 0, .5); -webkit-text-stroke: 2px #1c1726; }
#banner.show { animation: banner 2.4s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(.8); } 12% { opacity: 1; transform: scale(1.04); } 20% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

#toast {
  position: absolute; left: 50%; top: calc(100px + var(--sat)); z-index: 6; transform: translate(-50%, -12px);
  max-width: min(92vw, 460px); padding: 8px 16px; border-radius: 999px; text-align: center;
  background: rgba(14, 18, 38, .92); border: 2px solid rgba(120, 210, 255, .7);
  font-weight: 500; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.gold { border-color: var(--gold); color: #fff3c4; }

/* ------------------------------------------------------------ screens */
.screen {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: calc(14px + var(--sat)) calc(16px + var(--sar)) calc(14px + var(--sab)) calc(16px + var(--sal));
  background: linear-gradient(180deg, rgba(10, 14, 32, .25), rgba(10, 14, 32, .7));
}
.screen.dim { background: rgba(8, 10, 24, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.card {
  width: min(420px, 100%); max-height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 3px solid #0a0d1a; border-radius: 22px;
  box-shadow: 0 8px 0 #0a0d1a, inset 0 2px 0 rgba(255, 255, 255, .12), 0 24px 60px rgba(0, 0, 0, .5);
  padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  animation: pop .22s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.small-card { width: min(360px, 100%); }
h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; font-size: 26px; text-align: center; text-wrap: balance; text-shadow: 0 3px 0 #0a0d1a; }
h2 small { font-family: var(--body); font-size: 14px; color: var(--muted); font-weight: 500; }
h2.win { color: var(--gold); }
h2.lose { color: #ff8a7b; }
h3 { margin: 6px 0 0; font-family: var(--display); font-weight: 400; font-size: 16px; color: var(--gold); letter-spacing: .03em; }
p { margin: 0; line-height: 1.45; }
p.sub { text-align: center; color: var(--muted); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  border: 3px solid #0a0d1a; border-radius: 14px; padding: 11px 14px;
  background: linear-gradient(180deg, #3a4686, #2b356c); color: var(--text);
  font-family: var(--display); font-size: 16px; letter-spacing: .02em;
  box-shadow: 0 5px 0 #0a0d1a, inset 0 2px 0 rgba(255, 255, 255, .18);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #0a0d1a, inset 0 2px 0 rgba(255, 255, 255, .18); }
.btn.big {
  background: linear-gradient(180deg, #ffd45c, #ffb21f); color: #2a1a00; font-size: 24px; padding: 13px 14px 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 6px 0 var(--gold-d), 0 6px 0 3px #0a0d1a, inset 0 3px 0 rgba(255, 255, 255, .5);
  text-transform: uppercase;
}
.btn.big:active { box-shadow: 0 3px 0 var(--gold-d), inset 0 3px 0 rgba(255, 255, 255, .5); }
.btn.big .sub { font-family: var(--body); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: none; opacity: .75; }
.btn.ghost { background: transparent; box-shadow: none; border-color: rgba(255, 255, 255, .22); font-family: var(--body); font-weight: 500; }
.btn.tgl { font-family: var(--body); font-weight: 500; font-size: 14px; }
.btn.tgl.off { opacity: .55; text-decoration: line-through; }

.title-card { gap: 10px; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; margin-top: 2px; }
.logo .l0 { font-family: var(--body); font-weight: 700; text-transform: uppercase; letter-spacing: .32em; font-size: 12px; color: var(--gold); }
.logo .l1 {
  font-family: var(--display); font-size: clamp(30px, 9.5vw, 50px); line-height: 1.12; padding-top: 2px;
  text-transform: uppercase; color: #fff; letter-spacing: .01em;
  -webkit-text-stroke: 2px #0a0d1a; paint-order: stroke fill;
  text-shadow: 0 4px 0 #0a0d1a, 0 0 18px rgba(76, 217, 100, .35);
}
#title-hero { width: 120px; height: 120px; align-self: center; margin: -6px 0 -10px; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pickb { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 14px; border: 3px solid #0a0d1a; background: rgba(0, 0, 0, .28); color: var(--muted); font-family: var(--display); font-size: 15px; }
.pickb.on { background: linear-gradient(180deg, #ffd45c, #ffb21f); color: #2a1a00; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45); }
.pf { width: 38px; height: 38px; border-radius: 50%; flex: none; border: 2px solid #0a0d1a; background: #2a3a60 center 22% / 125% no-repeat; }
.pf.beka { background-image: url("assets/face.webp"); }
.pf.ed { background-image: url("assets/face_ed.webp"); }
body.hero-ed .face { background-image: url("assets/face_ed.webp"); }
.diff { display: flex; flex-direction: column; gap: 4px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(0, 0, 0, .3); border: 3px solid #0a0d1a; border-radius: 14px; padding: 3px; gap: 3px; }
.segb { border: 0; border-radius: 10px; padding: 8px 4px; background: transparent; color: var(--muted); font-family: var(--body); font-weight: 700; font-size: 14px; }
.segb.on { background: linear-gradient(180deg, #4cd964, #2f9e45); color: #06210d; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35); }
.segb[data-diff="0"].on { background: linear-gradient(180deg, #6ad1ff, #2f8ef0); color: #04213d; }
.segb[data-diff="2"].on { background: linear-gradient(180deg, #ff8a7b, #e0302a); color: #2a0503; }
.diff small { text-align: center; color: var(--muted); font-size: 12px; min-height: 1em; }
.credits { margin: 2px 0 0; text-align: center; font-size: 12px; line-height: 1.5; color: var(--muted); letter-spacing: .02em; }
.credits b { color: var(--text); font-weight: 700; }
.credits .tel { -webkit-user-select: text; user-select: text; font-variant-numeric: tabular-nums; }
.record { text-align: center; color: var(--muted); font-size: 14px; }
.record b { color: var(--gold); font-family: var(--display); font-weight: 400; font-variant-numeric: tabular-nums; }

.levels { display: grid; gap: 10px; flex-shrink: 0; }
.lvl {
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left;
  border: 3px solid #0a0d1a; border-radius: 16px; padding: 10px 12px; box-shadow: 0 5px 0 #0a0d1a; color: #fff;
  min-height: 70px;
}
.lvl:active { transform: translateY(3px); box-shadow: 0 2px 0 #0a0d1a; }
.lvl .lnum { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-size: 22px; background: rgba(0, 0, 0, .35); border: 2px solid rgba(255, 255, 255, .3); }
.lvl .lname { font-family: var(--display); font-size: 18px; text-shadow: 0 2px 0 rgba(0, 0, 0, .6); }
.lvl .lmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.lvl .kchips { display: flex; gap: 2px; }
.lvl .lbest { font-family: var(--display); font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 #000; }
.lvl .lbest.new { font-family: var(--body); font-weight: 700; color: #fff3c4; }
.lvl.t0 { background: linear-gradient(120deg, #4c9be6, #3a78b8 60%, #c97a2e); }
.lvl.t1 { background: linear-gradient(120deg, #1e4b4c, #123236 60%, #4c9a58); }
.lvl.t2 { background: linear-gradient(120deg, #26406b, #16264a 60%, #3aa0e6); }
.lvl.t3 { background: linear-gradient(120deg, #a2471f, #5a2414 60%, #d8382e); }
.lvl.t4 { background: linear-gradient(120deg, #3a1648, #1e0b28 60%, #7fe04a); }
.lvl.t5 { background: linear-gradient(120deg, #6fb3e6, #3a6f9e 60%, #e9f6ff); }
.lvl.t6 { background: linear-gradient(120deg, #d99550, #8a5a2a 60%, #3aa0e6); }
.lvl.t7 { background: linear-gradient(120deg, #2fa3e0, #1a6ca8 60%, #ffcf3a); }
.lvl.tc1 { background: linear-gradient(120deg, #3b8fd8, #2a5e9a 60%, #e9d6a8); }
.lvl.tc2 { background: linear-gradient(120deg, #e08a3c, #9a4f1e 60%, #3ea38a); }
.lvl.tc3 { background: linear-gradient(120deg, #c0392b, #7a1f16 60%, #e9b949); }
.lvl.tc4 { background: linear-gradient(120deg, #e3a44a, #9a5a20 60%, #5a8a3a); }
.lvl.tc5 { background: linear-gradient(120deg, #5a6d86, #2c3646 60%, #ffcf3a); }
.lvl .hatchmark { font-style: normal; font-size: 13px; color: #ffd23f; vertical-align: middle; }
.chtabs { flex-shrink: 0; display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.chtab { flex: 0 0 auto; scroll-snap-align: start; display: grid; gap: 2px; min-width: 104px; min-height: 52px; padding: 8px 12px; border-radius: 14px;
  border: 3px solid #0a0d1a; box-shadow: 0 4px 0 #0a0d1a; color: #fff; text-align: left; background: var(--panel-2); }
.chtab .cn { font-family: var(--display); font-size: 15px; }
.chtab .cp { font-size: 12px; color: #d6dbef; font-variant-numeric: tabular-nums; }
.chtab.on { background: linear-gradient(180deg, #ffd45c, #f2a91f); color: #2a1a00; }
.chtab.on .cp { color: #5a3a00; }
.chtab.locked { filter: grayscale(.8) brightness(.65); }
.chtab:active { transform: translateY(3px); box-shadow: 0 1px 0 #0a0d1a; }
.chlock { text-align: center; color: var(--muted); padding: 24px 8px; line-height: 1.5; }
#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 60; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 14px; background: rgba(12, 15, 30, .88); border: 2px solid var(--line); color: var(--text); font-weight: 700; }
#loading[hidden] { display: none; }
#loading .spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lvl.boss .lname::after { content: '  БОСС'; font-size: 11px; letter-spacing: .12em; color: #ff8a7b; vertical-align: middle; }
.lvl.locked { filter: grayscale(.85) brightness(.6); cursor: not-allowed; }
.lvl.locked .lnum::after { content: ""; }
.lvl .lock { color: #d6dbef; }

.achs { display: grid; gap: 8px; }
.ach { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 2px solid rgba(255, 255, 255, .08); }
.ach b { display: block; font-family: var(--display); font-weight: 400; font-size: 15px; }
.ach small { color: var(--muted); font-size: 13px; }
.ach .medal { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #3a4060; border: 3px solid #0a0d1a; box-shadow: inset 0 0 0 3px #555c7c; }
.ach.got { border-color: rgba(255, 199, 39, .45); }
.ach.got .medal { background: radial-gradient(circle at 40% 35%, #fff3a8, #ffc727 55%, #d99a14); box-shadow: inset 0 0 0 3px #ffe680; }
.ach:not(.got) b { color: #c5cbe2; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 4px 0; padding: 12px 14px; background: rgba(0, 0, 0, .25); border-radius: 14px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-family: var(--display); font-variant-numeric: tabular-nums; }
.stats .tot { color: var(--gold); font-size: 18px; }
dt.tot { font-family: var(--display); }

.help p, .help li, .help dd { font-size: 14px; }
.keys-help { margin: 0; display: grid; gap: 4px; }
.keys-help dt { font-weight: 700; color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.keys-help dd { margin: 0 0 6px; color: var(--text); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.legend li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.35; }
.legend .ic { width: 24px; height: 24px; margin-top: -2px; }
.legend.plain li { display: block; }

@media (max-width: 600px) {
  .hud-row { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; }
  .hud-group.mid { grid-column: 1 / -1; grid-row: 2; }
  #bossbar { top: calc(100px + var(--sat)); }
  #toast { top: calc(136px + var(--sat)); }
}
@media (max-width: 440px) {
  body.portrait .pad { width: 70px; height: 70px; }
  body.portrait .pad.jmp { width: 86px; height: 86px; }
  body.portrait .cluster { gap: 10px; }
  body.portrait .cluster.right { right: calc(12px + var(--sar)); }
  body.portrait .pad.atk { margin-bottom: 52px; }
}
@media (max-height: 520px) {
  .card { padding: 14px 16px; gap: 8px; }
  #title-hero { display: none; }
  .logo .l1 { font-size: 34px; }
  .btn.big { font-size: 20px; padding: 9px; }
  .title-card { width: min(560px, 100%); }
  h2 { font-size: 22px; }
  .stats { padding: 8px 12px; gap: 2px 12px; font-size: 14px; }
  p.sub { font-size: 13px; }
  .small-card { width: min(440px, 100%); }
}
@media (max-height: 470px) and (min-aspect-ratio: 5/4) {
  .title-card {
    width: min(660px, 100%); display: grid; grid-template-columns: 1fr 1.25fr; column-gap: 18px; row-gap: 9px;
    grid-template-areas: "logo play" "hero diff" "hero r1" "pick r2" "rec help" "cred help"; align-items: center;
  }
  .title-card .logo { grid-area: logo; }
  .title-card #title-hero { grid-area: hero; display: block; width: 84px; height: 84px; margin: 0 auto; }
  .title-card #btn-play { grid-area: play; }
  .title-card .r1 { grid-area: r1; }
  .title-card .r2 { grid-area: r2; }
  .title-card #btn-help { grid-area: help; padding: 8px; }
  .title-card .record { grid-area: rec; }
  .title-card .diff { grid-area: diff; }
  .title-card .pick { grid-area: pick; }
  .pickb { padding: 3px 8px 3px 3px; font-size: 13px; }
  .pf { width: 30px; height: 30px; }
  .title-card .credits { grid-area: cred; font-size: 11px; margin: 0; }
  .segb { padding: 6px 4px; font-size: 13px; }
  .diff small { display: none; }
  .title-card .btn.big { font-size: 20px; padding: 9px; }
  .title-card .btn { padding: 8px 10px; }
  .logo .l1 { font-size: 32px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 5/4) {
  #screen-levels .card { width: min(720px, 100%); }
  .levels { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .lvl { min-height: 56px; padding: 7px 10px; grid-template-columns: 36px 1fr; }
  .lvl .lnum { width: 36px; height: 36px; font-size: 18px; }
  .lvl .lname { font-size: 15px; }
  .chtab { min-height: 44px; min-width: 96px; padding: 5px 10px; }
  .chtab .cn { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}
.lock-card a.btn { text-decoration: none; text-align: center; display: block; }
