/* ZARIO v5 — side-view voxel platformer */
@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/press-start-2p.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --ink: #0e1520;
  --accent: #ffb400;
  --accent2: #ff7a2a;
  --panel: rgba(10, 16, 26, 0.78);
  --text: #eaf2ff;
  --muted: #9fb4cf;
  --hud-gap: clamp(10px, 1.4vw, 20px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0e1520;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; overscroll-behavior: none;
}

#game-container { position: fixed; inset: 0; }
#zario-canvas { position: absolute; inset: 0; display: block; cursor: default; }

/* soft screen vignette: pulls the eye to the lane */
#vignette {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 42% 46%, rgba(0,0,0,0) 42%, rgba(0,0,0,0.34) 100%);
}

/* powered / star glow */
#powerVignette {
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none; opacity: 0;
  transition: opacity 0.4s ease;
  box-shadow: inset 0 0 150px 55px rgba(255, 110, 30, 0.34);
}
#game-container.powered #powerVignette { opacity: 1; }
#game-container.hurry #vignette {
  background: radial-gradient(ellipse at 42% 46%, rgba(0,0,0,0) 38%, rgba(80,0,0,0.42) 100%);
  animation: hurryPulse 0.9s infinite;
}
@keyframes hurryPulse { 50% { opacity: 0.55; } }

/* hit / power / star flashes */
#hitFlash {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none; opacity: 0;
  background: rgba(255, 48, 32, 0.42);
  transition: opacity 0.35s ease;
}
#hitFlash.flash { opacity: 1; transition-duration: 0.04s; }
#hitFlash.flashWarm { background: rgba(255, 170, 60, 0.4); opacity: 1; transition-duration: 0.05s; }
#hitFlash.flashStar {
  background: linear-gradient(120deg, rgba(255,80,80,0.35), rgba(255,220,80,0.35), rgba(80,255,180,0.35), rgba(120,140,255,0.35));
  opacity: 1; transition-duration: 0.05s;
}

#bootmsg {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--muted); font-size: 14px; z-index: 5;
}
#bootmsg.fail { color: #ff6b6b; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; z-index: 4;
  display: flex; gap: var(--hud-gap);
  background: var(--panel);
  border: 1px solid rgba(255, 180, 0, 0.25);
  border-radius: 12px;
  padding: 9px 14px;
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.stat { display: flex; flex-direction: column; min-width: 46px; }
.stat .label { font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 2px; white-space: nowrap; }
.stat .value.big { font-size: 20px; color: var(--accent); }
.stat .value.lives { color: #ff6b8a; font-size: 15px; letter-spacing: 1px; }
#coinIcon { color: #ffd23e; transition: transform 0.12s ease; display: inline-block; }
#time.danger { color: #ff5b5b; animation: pulse 0.6s infinite; }
#powerWrap .value { font-size: 12px; }
#powerWrap .value.on { color: #ff7a2a; text-shadow: 0 0 8px rgba(255, 122, 42, 0.8); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* progress-to-flag bar */
#progress {
  position: absolute; top: max(80px, calc(env(safe-area-inset-top) + 74px)); left: 16px; z-index: 4;
  width: min(360px, 42vw); height: 8px;
  background: rgba(10, 16, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  pointer-events: none;
}
#progFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff7a2a, #ffd23e);
  border-radius: 99px;
  box-shadow: 0 0 10px rgba(255, 160, 40, 0.55);
  transition: width 0.18s linear;
}
#progPin {
  position: absolute; top: -12px; left: 0%; transform: translateX(-50%);
  font-size: 13px; color: #ffd23e; text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  transition: left 0.18s linear;
}

#topRight {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 18px; z-index: 4;
  text-align: right; pointer-events: none;
}
#muteState { font-size: 18px; display: block; line-height: 1.15; margin-bottom: 7px; }
#topRight .tiny { font-size: 10px; color: var(--muted); display: block; margin-top: 4px; }

/* combo counter */
#combo {
  position: absolute; top: 26%; left: 50%; transform: translate(-50%, -50%);
  z-index: 5; font-size: 54px; font-weight: 900; letter-spacing: 2px;
  color: #ffd23e; text-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 26px rgba(255,160,40,0.8);
  opacity: 0; pointer-events: none;
}
#combo.visible { opacity: 1; }
#combo.pop { animation: comboPop 0.45s cubic-bezier(0.2, 1.6, 0.35, 1); }
@keyframes comboPop {
  0% { transform: translate(-50%,-50%) scale(2.1) rotate(-6deg); opacity: 0.2; }
  60% { transform: translate(-50%,-50%) scale(0.94) rotate(2deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}

/* transient centre message */
#toast {
  position: absolute; top: 17%; left: 50%; transform: translateX(-50%);
  z-index: 5; font-size: 22px; font-weight: 800; letter-spacing: 4px;
  color: var(--accent); text-shadow: 0 3px 0 rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; text-align: center;
}
#toast.show { animation: toastIn 1.8s ease forwards; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  22% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
}

/* floating world-space score popups */
#popups { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.pop3d {
  position: absolute; top: 0; left: 0;
  font-size: 15px; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap;
  color: #fff2c0; text-shadow: 0 2px 0 rgba(0,0,0,0.6), 0 0 14px rgba(0,0,0,0.4);
  will-change: transform, opacity;
}

/* boss health */
#bossBar {
  position: absolute; top: max(92px, calc(env(safe-area-inset-top) + 86px)); left: 50%;
  transform: translateX(-50%);
  width: min(520px, 78vw); z-index: 4;
  opacity: 0; transition: opacity 0.35s ease; pointer-events: none;
  text-align: center;
}
#bossBar.visible { opacity: 1; }
#bossName { font-size: 11px; letter-spacing: 4px; color: #e2ccff; text-shadow: 0 2px 6px #000; }
#bossTrack {
  margin-top: 4px; height: 12px; border-radius: 99px;
  background: rgba(10,8,18,0.75); border: 1px solid rgba(200,160,255,0.45);
  overflow: hidden;
}
#bossFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #b06cf0, #ff5b8a);
  box-shadow: 0 0 14px rgba(180,110,255,0.7);
  transition: width 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}

/* ---------------- touch ---------------- */
#touch { display: none; }
#game-container.touch #touch {
  display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  justify-content: space-between; align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.tpad-left, .tpad-right { display: flex; gap: 14px; align-items: flex-end; pointer-events: auto; }
.tpad {
  width: 78px; height: 78px; border-radius: 50%;
  font-size: 26px; font-weight: 800; color: #fff;
  background: rgba(18, 26, 40, 0.6);
  border: 2px solid rgba(255, 210, 120, 0.5);
  backdrop-filter: blur(3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  transition: transform 0.07s ease, background 0.1s ease;
  touch-action: none;
}
.tpad.small { width: 62px; height: 62px; font-size: 20px; }
.tpad.jump { width: 96px; height: 96px; background: rgba(255, 140, 40, 0.34); border-color: rgba(255, 220, 140, 0.8); }
.tpad.down { transform: scale(0.9); background: rgba(255, 180, 60, 0.45); }
#game-container.touch #hint { display: none; }
#game-container.touch #progress { width: min(300px, 58vw); }

/* ---------------- hint ---------------- */
#hint {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 3; text-align: center;
  font-size: 11px; line-height: 1.7; color: rgba(234, 242, 255, 0.92);
  background: var(--panel); border-radius: 10px; padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
  pointer-events: auto; cursor: pointer;
  transition: opacity 0.6s ease;
}
#hint b { color: var(--accent); }
#hint.fade { opacity: 0; pointer-events: none; }

/* ---------------- overlays ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(14, 21, 32, 0.55), rgba(8, 12, 20, 0.86));
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
  overflow: auto;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

#levelCard {
  z-index: 12;
  background: radial-gradient(ellipse at center, rgba(8, 12, 22, 0.82), rgba(4, 6, 12, 0.95));
}
#levelCard .level-card-box { max-width: 640px; padding: 38px 46px; }
#levelCard .card-title {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: clamp(15px, 2.6vw, 26px);
  line-height: 1.65;
  color: var(--accent2);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.55), 0 0 28px rgba(255, 180, 0, 0.3);
  margin: 4px 0 0;
}
#levelCard .card-tag { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 14px; letter-spacing: 0.5px; }
#levelCard .card-skip { margin-top: 24px; letter-spacing: 2px; }
#levelCard .card-title.card-pop { animation: cardPop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
#levelCard .card-tag, #levelCard .card-skip { animation: cardFade 0.5s ease 0.25s both; }
@keyframes cardPop {
  0%   { transform: scale(0.35); opacity: 0; }
  70%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes cardFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(255, 180, 0, 0.3);
  border-radius: 16px;
  padding: 30px 38px;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}
.card.wide { max-width: 720px; }
.card.small { max-width: 320px; padding: 26px 34px; }
.card .kicker { font-size: 11px; letter-spacing: 3px; color: var(--accent); text-transform: uppercase; margin-bottom: 10px; }
.card h1 {
  font-size: 52px; font-weight: 900; letter-spacing: 4px; line-height: 1;
  background: linear-gradient(180deg, #ffd23e, #ff7a2a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 14px; text-shadow: 0 4px 30px rgba(255, 122, 42, 0.3);
}
.card h1.sm { font-size: 30px; letter-spacing: 2px; }
#winTitle { font-size: 36px; letter-spacing: 2px; }

.card .sub { font-size: 12.5px; color: var(--muted); line-height: 1.65; margin-bottom: 16px; }
.card .sub b { color: var(--accent2); }

.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px;
  margin-bottom: 20px; font-size: 11.5px; color: var(--text); text-align: left;
}
.controls span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls b { color: var(--accent); }

button {
  font-family: inherit; font-size: 15px; font-weight: 700; letter-spacing: 1px;
  color: #1a1400; background: linear-gradient(180deg, #ffd23e, #ff9a2a);
  border: none; border-radius: 10px; padding: 12px 26px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 150, 40, 0.35);
  transition: transform 0.08s ease, filter 0.15s ease;
  margin: 4px;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(2px); }
button.ghost { background: transparent; color: var(--text); border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: none; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

.card .fine { font-size: 11px; color: var(--muted); margin-top: 14px; }
.card .fine b { color: var(--accent); }

.results { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.results div { display: flex; flex-direction: column; min-width: 62px; }
.results span { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.results b { font-size: 24px; color: var(--accent); margin-top: 4px; }
#winStats b { font-size: 18px; color: var(--text); }

/* world map tiles */
#mapGrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 6px 0 18px;
}
.mapTile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  background: rgba(20, 30, 46, 0.8);
  border: 1px solid rgba(255, 180, 0, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text); font-size: 11px; text-align: left;
  box-shadow: none;
}
.mapTile .mt-short { font-size: 16px; font-weight: 900; color: var(--accent); }
.mapTile .mt-name { color: var(--text); font-weight: 600; }
.mapTile .mt-time { color: var(--muted); font-size: 10px; }
.mapTile.locked { border-color: rgba(255,255,255,0.12); }
.mapTile.current { border-color: #ffd23e; box-shadow: 0 0 0 1px #ffd23e inset; }

@media (max-width: 760px) {
  #hud { gap: 10px; padding: 7px 10px; }
  .stat { min-width: 38px; }
  .stat .value { font-size: 12px; }
  .stat .value.big { font-size: 15px; }
  #progress { width: 46vw; }
  .card { padding: 22px 20px; }
  .card h1 { font-size: 38px; }
  .controls { grid-template-columns: 1fr; }
  #mapGrid { grid-template-columns: repeat(2, 1fr); }
  .tpad { width: 66px; height: 66px; font-size: 22px; }
  .tpad.jump { width: 82px; height: 82px; }
}

@media (max-height: 520px) {
  #hint { display: none; }
  .card { padding: 16px 20px; }
  .card .sub { display: none; }
  .controls { margin-bottom: 10px; font-size: 10.5px; }
  .card h1 { font-size: 32px; margin-bottom: 8px; }
}
