:root {
  --navy: #0f2742; --navy2: #17385e; --orange: #ff7a1a; --yellow: #ffc928; --teal: #18b3a4; --grey: #6b7684;
  --font: "Arial Black", "Segoe UI Black", Impact, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f2742; font-family: system-ui, "Segoe UI", Roboto, sans-serif; color: #fff; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- logo ---------- */
.logo { display: flex; flex-direction: column; line-height: .86; transform: rotate(-4deg); filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
.logo span { font-family: var(--font); letter-spacing: .02em; }
.logo .l1 { font-size: clamp(54px, 9vw, 116px); color: var(--yellow); -webkit-text-stroke: 3px var(--navy);
  text-shadow: 0 5px 0 #c77a00, 0 9px 0 var(--navy); }
.logo .l2 { font-size: clamp(54px, 9vw, 116px); color: #fff; -webkit-text-stroke: 3px var(--navy); margin-left: .35em;
  text-shadow: 0 5px 0 var(--orange), 0 9px 0 var(--navy); }
.logo .tag { font-size: clamp(12px, 1.6vw, 18px); color: var(--navy); background: var(--yellow); padding: 6px 12px; margin-top: 14px;
  align-self: flex-start; border-radius: 4px; letter-spacing: .25em; box-shadow: 0 4px 0 #c77a00;
  background-image: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(0,0,0,.08) 14px 28px); }
.logo.small .l1, .logo.small .l2 { font-size: 64px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.show { display: block; }
#loading { background: radial-gradient(ellipse at 50% 35%, #1d4f86 0%, #0f2742 70%); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 34px; }
#loading.show { display: flex; }
.track { width: min(360px, 70vw); height: 14px; border-radius: 10px; background: rgba(255,255,255,.12); overflow: hidden; border: 2px solid rgba(255,255,255,.25); }
.track i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--yellow) 0 12px, #1b1b1b 12px 24px); transition: width .2s; }
#loadText { font-family: var(--font); color: #cfe2ff; letter-spacing: .12em; font-size: 14px; }

#menu { pointer-events: none; }
#menu.show { display: block; }
#menu::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,28,50,.78) 0%, rgba(10,28,50,.35) 38%, rgba(10,28,50,0) 60%); }
.menuLeft { position: absolute; left: max(4vw, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 16px; pointer-events: auto; width: min(440px, 90vw); }
.menuLeft .logo { margin-bottom: 26px; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }
.menuStats { position: absolute; top: max(18px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); display: flex; gap: 10px; pointer-events: auto; }
.stat { background: rgba(15,39,66,.82); border: 2px solid rgba(255,255,255,.18); border-radius: 14px; padding: 8px 16px; text-align: center; min-width: 92px; backdrop-filter: blur(6px); }
.stat b { display: block; font-family: var(--font); font-size: 22px; }
.stat small { font-size: 10px; letter-spacing: .16em; color: #9fc0e8; }
.stat.coin b { color: var(--yellow); }
.nameplate { position: absolute; right: 7vw; bottom: 9vh; text-align: right; }
.nameplate b { display: block; font-family: var(--font); font-size: clamp(30px, 4vw, 52px); color: #fff; -webkit-text-stroke: 2px var(--navy); text-shadow: 0 4px 0 var(--orange); }
.nameplate small { color: #fff; opacity: .9; font-weight: 600; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.hint { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); font-size: 13px; color: rgba(255,255,255,.75); text-shadow: 0 1px 4px #000; }
kbd { display: inline-block; background: #fff; color: var(--navy); border-radius: 5px; padding: 1px 7px; font: 700 12px system-ui; box-shadow: 0 2px 0 #9aa9bb; margin: 0 2px; }

/* ---------- buttons ---------- */
.btn { font-family: var(--font); font-size: 15px; letter-spacing: .08em; color: #fff; background: var(--navy2); border: 2px solid rgba(255,255,255,.22);
  border-radius: 14px; padding: 13px 18px; cursor: pointer; box-shadow: 0 5px 0 #08182b, 0 8px 18px rgba(0,0,0,.3); transition: transform .08s, filter .15s; pointer-events: auto; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #08182b; }
.btn.big { font-size: 26px; padding: 18px 22px; }
.btn.primary { background: linear-gradient(180deg, #ffa33a, var(--orange)); color: #fff; border-color: #ffd29a; box-shadow: 0 6px 0 #b04a00, 0 10px 24px rgba(255,122,26,.35); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.primary span { display: inline-block; margin-right: 8px; }
.btn.danger { background: #7a1f24; }
.btn:disabled { opacity: .45; filter: grayscale(.6); cursor: default; }
#playBtn { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.035); } }

/* ---------- panels ---------- */
.panel { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 30; background: rgba(6,16,30,.55); backdrop-filter: blur(5px); }
.panel.show { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.pbox { width: min(560px, 92vw); max-height: 90vh; overflow: auto; background: linear-gradient(180deg, #1b3f69, #102a49); border: 3px solid rgba(255,255,255,.2);
  border-radius: 22px; padding: 22px 24px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; animation: pop .25s cubic-bezier(.3,1.6,.6,1); position: relative; }
.pbox::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px; border-radius: 18px 18px 0 0; background: repeating-linear-gradient(-45deg, var(--yellow) 0 14px, #1b1b1b 14px 28px); }
.pbox.narrow { width: min(400px, 92vw); text-align: center; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.pbox h2 { font-family: var(--font); margin: 8px 0 2px; font-size: 30px; letter-spacing: .04em; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.pbox.narrow h2 { justify-content: center; }
.sub { color: #bcd3ee; font-size: 14px; margin: 0; line-height: 1.45; }
.close { margin-top: 6px; }
.coinTag, .multTag { font-family: var(--font); font-size: 16px; background: rgba(0,0,0,.3); border-radius: 30px; padding: 4px 12px 4px 30px; position: relative; color: var(--yellow); }
.coinTag::before { content: ""; position: absolute; left: 6px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff6b0, #ffc928 55%, #c98a06); box-shadow: inset 0 0 0 2px #a86f00; }
.multTag { color: #fff; padding-left: 12px; background: var(--teal); }

.up { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; background: rgba(0,0,0,.22); border-radius: 14px; padding: 10px 12px; }
.up b { font-family: var(--font); font-size: 15px; }
.up small { display: block; color: #a9c3e3; font-size: 12px; margin-top: 2px; }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 22px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); }
.pips i.on { background: var(--yellow); box-shadow: 0 0 8px rgba(255,201,40,.6); }
.up .btn { padding: 9px 12px; font-size: 13px; }

.ms { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; background: rgba(0,0,0,.22); border-radius: 14px; padding: 12px 14px; align-items: center; }
.ms b { font-size: 15px; }
.ms .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.ms .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #5ff0d8); }
.ms em { font-style: normal; font-family: var(--font); font-size: 13px; color: #9fe8de; }
.ms.done { outline: 2px solid var(--yellow); }

.how { display: grid; gap: 8px; }
.how div { background: rgba(0,0,0,.2); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.how span { margin-left: auto; color: #cfe2ff; font-weight: 600; }
.pus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pus div { background: rgba(0,0,0,.2); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.pus i { grid-row: 1 / 3; }
.pus span { font-size: 12px; color: #bcd3ee; }

.tog { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,.2); padding: 12px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; }
.tog input { width: 22px; height: 22px; accent-color: var(--orange); }

/* power-up icons (drawn in CSS so they need no image files) */
.pu { width: 42px; height: 42px; border-radius: 12px; display: inline-block; position: relative; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); }
.pu::after { content: ""; position: absolute; inset: 0; background-repeat: no-repeat; background-position: center; background-size: 70%; }
.pu.magnet { background: #e0302a; } .pu.magnet::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h4v8a3 3 0 006 0V3h4v8a7 7 0 01-14 0z' fill='%23fff'/%3E%3Cpath d='M5 3h4v3H5zM15 3h4v3h-4z' fill='%23cfd8e0'/%3E%3C/svg%3E"); }
.pu.hardhat { background: #ff8a1a; } .pu.hardhat::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17h18v2H3zM5 16a7 7 0 0114 0z' fill='%23fff'/%3E%3Cpath d='M11 6h2v6h-2z' fill='%23ffb35c'/%3E%3C/svg%3E"); }
.pu.turbo { background: #11a9d9; } .pu.turbo::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 15l6-7 4 3 4-1 4 4v3H3z' fill='%23fff'/%3E%3Cpath d='M1 9h5M0 12h4' stroke='%23fff' stroke-width='1.6'/%3E%3C/svg%3E"); }
.pu.hook { background: #e6a90f; } .pu.hook::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 1h2v6h-2z M8 6h8v4H8z' fill='%23fff'/%3E%3Cpath d='M12 10v5a3 3 0 11-6 0' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 20; }
#hud.show { display: block; }
.hudTop { position: absolute; left: 0; right: 0; top: 0; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); display: flex; justify-content: space-between; align-items: flex-start; }
#pauseBtn { pointer-events: auto; width: 48px; height: 48px; border-radius: 14px; border: 2px solid rgba(255,255,255,.3); background: rgba(15,39,66,.75); color: #fff; font-size: 16px; cursor: pointer; }
.hudRight { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#score { font-family: var(--font); font-size: clamp(30px, 5vw, 46px); color: #fff; -webkit-text-stroke: 2px var(--navy); text-shadow: 0 4px 0 var(--navy); font-variant-numeric: tabular-nums; }
.hudRow { display: flex; gap: 8px; }
#coins { font-size: 20px; background: rgba(15,39,66,.75); }
#mult { font-size: 16px; }
#dist { font-family: var(--font); font-size: 13px; color: #dfeaf7; text-shadow: 0 2px 3px rgba(0,0,0,.6); }
#coins.bump { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.18); } }
#pubars { position: absolute; left: max(16px, env(safe-area-inset-left)); top: 80px; display: flex; flex-direction: column; gap: 8px; }
.pubar { display: flex; align-items: center; gap: 8px; background: rgba(15,39,66,.75); border-radius: 14px; padding: 5px 10px 5px 5px; }
.pubar .pu { width: 34px; height: 34px; border-radius: 10px; }
.pubar .t { width: 90px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
.pubar .t i { display: block; height: 100%; background: #fff; }
#banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%,-50%); font-family: var(--font); font-size: clamp(44px, 8vw, 96px); color: var(--yellow);
  -webkit-text-stroke: 3px var(--navy); text-shadow: 0 6px 0 var(--navy); opacity: 0; white-space: nowrap; }
#banner.go { animation: banner .9s ease-out; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%,-50%) scale(2); } 25% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-60%) scale(1); } }
#patrolWarn { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); font-family: var(--font); background: #d22d2d; padding: 8px 18px; border-radius: 30px; letter-spacing: .1em; display: none; box-shadow: 0 0 0 4px rgba(255,255,255,.25); animation: flash .4s infinite alternate; }
@keyframes flash { to { background: #2a6bff; } }
#toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -140%); z-index: 40; background: linear-gradient(180deg, #24c4b4, #138a7e); border: 2px solid #b7fff5; border-radius: 16px; padding: 10px 18px; font-weight: 800; transition: transform .35s cubic-bezier(.3,1.5,.6,1); box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 90vw; text-align: center; }
#toast.show { transform: translate(-50%, 0); }
#toast small { display: block; font-weight: 600; opacity: .85; }

/* ---------- game over ---------- */
#overTitle { font-size: 42px; color: var(--yellow); -webkit-text-stroke: 2px var(--navy); text-shadow: 0 4px 0 var(--orange); }
.newBest { display: none; align-self: center; font-family: var(--font); background: var(--orange); padding: 5px 14px; border-radius: 30px; animation: pulse 1s infinite; }
.overStats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.overStats div { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px; }
.overStats small { display: block; font-size: 11px; letter-spacing: .16em; color: #9fc0e8; }
.overStats b { font-family: var(--font); font-size: 24px; }
.gold { color: var(--yellow); }
#oMissions { display: flex; flex-direction: column; gap: 6px; text-align: left; }

@media (max-width: 720px) {
  #menu::before { background: linear-gradient(0deg, rgba(10,28,50,.85) 0%, rgba(10,28,50,.4) 45%, rgba(10,28,50,0) 70%); }
  .menuLeft { top: auto; bottom: 26px; transform: none; left: 50%; transform: translateX(-50%); }
  .menuLeft .logo { margin-bottom: 8px; }
  .logo .l1, .logo .l2 { font-size: 58px; }
  .nameplate { display: none; }
  .hint { display: none; }
  .menuStats { left: 12px; right: 12px; justify-content: center; }
  .stat { min-width: 0; flex: 1; padding: 6px; }
  .btn.big { font-size: 22px; }
  .pus { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  .menuLeft .logo { margin-bottom: 4px; }
  .logo .l1, .logo .l2 { font-size: 48px; }
  .btn { padding: 9px 14px; }
  .btn.big { padding: 11px 18px; font-size: 20px; }
  .menuLeft { gap: 9px; }
}
