/* Escape Road remake - pixel UI */
:root {
  --navy: #1d2532;
  --navy-d: #10151f;
  --green: #2e8f4e;
  --cash-bg: #2e9e5b;
  --score-bg: #e8862e;
  --parchment: #f2e3c0;
  --red: #d83a3a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  background: #000;
  font-family: 'Press Start 2P', monospace;
  user-select: none;
  -webkit-user-select: none;
}
#c {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0;
}
#c.gray { filter: grayscale(1) contrast(1.06) brightness(0.92); }
#vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(18, 26, 18, 0.30) 100%);
}

/* ---------- generic buttons ---------- */
.hbtn {
  font-family: inherit;
  width: 46px; height: 46px;
  background: #4a6fe8;
  color: #fff;
  border: 3px solid var(--navy-d);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.35);
}
.hbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.hbtn.big { width: 58px; height: 58px; font-size: 24px; background: #3f63d8; }
.hbtn.back { position: absolute; top: 14px; left: 14px; z-index: 5; }

.pixel-btn {
  font-family: inherit;
  display: block;
  background: var(--navy);
  color: #fff;
  border: 3px solid var(--navy-d);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.14);
  text-align: center;
}
.pixel-btn:hover { background: #273044; }
.pixel-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.pixel-btn.wide { width: 100%; margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.pixel-btn.play { background: #4a6fe8; }
.pixel-btn.big-btn { font-size: 14px; padding: 16px 26px; }
.pixel-btn .mini { font-size: 10px; background: var(--cash-bg); border: 2px solid var(--navy-d); border-radius: 6px; padding: 5px 7px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
body.in-run #hud, body.in-menu #hud { display: block; }
body.in-menu #hud .hud-left { display: none; }
body.in-menu #hud #hud-stars { display: none; }
.hud-left { position: absolute; top: 14px; left: 14px; pointer-events: auto; }
.hud-right { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.badge {
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 3px solid var(--navy-d);
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,.5);
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
  min-width: 150px;
  text-align: right;
}
.badge.cash { background: var(--cash-bg); }
.badge.score { background: var(--score-bg); }
.badge .dollar {
  background: #eaf6ee; color: #1d7a43; border: 2px solid #1d5f36; border-radius: 4px;
  padding: 2px 6px; margin-right: 10px; font-size: 12px;
}
#hud-stars {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
#hud-stars .star { width: 34px; height: 34px; color: rgba(0,0,0,.28); }
#hud-stars .star.on { color: #f2c230; filter: drop-shadow(1px 2px 0 rgba(0,0,0,.45)); }
#hud-stars .star.pop { animation: starpop .45s cubic-bezier(.2,2.4,.4,1); }
@keyframes starpop { 0% { transform: scale(0.2); } 100% { transform: scale(1); } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 10; display: none; pointer-events: none; }
.screen.show { display: block; }
.screen > * { pointer-events: auto; }

/* ---------- menu ---------- */
.menu-top-left { position: absolute; top: 14px; left: 14px; }
.adcard {
  position: absolute; top: 76px; left: 14px;
  width: 150px;
  background: #57c7f2;
  border: 3px solid var(--navy-d);
  border-radius: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
  overflow: hidden;
}
.ad-title { background: var(--red); color: #fff; font-size: 10px; padding: 8px; text-align: center; }
.ad-body { font-size: 8px; line-height: 1.9; padding: 10px; color: #123; }
#menu-car-card {
  position: absolute; top: 250px; left: 14px;
  display: flex; gap: 10px; align-items: center;
  background: rgba(16,21,31,.82);
  border: 3px solid var(--navy-d);
  border-radius: 10px;
  padding: 10px 12px;
}
#menu-car-chip { width: 40px; height: 26px; border-radius: 5px; border: 2px solid rgba(255,255,255,.4); }
.mc-meta { color: #fff; font-size: 9px; }
#menu-car-rar { font-size: 8px; margin-top: 6px; }
#press-start {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 15px; text-shadow: 2px 2px 0 rgba(0,0,0,.6);
  white-space: nowrap;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
.menu-bottom {
  position: absolute; bottom: 18px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.plate {
  background: var(--navy);
  border: 3px solid #fff;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  padding: 10px 22px;
  box-shadow: 0 4px 0 rgba(0,0,0,.4);
}
.more {
  position: absolute; right: 14px; bottom: 0;
  font-family: inherit;
  background: #f2a03c;
  border: 3px solid var(--navy-d);
  border-radius: 8px;
  color: #fff; font-size: 9px; line-height: 1.6;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}

/* ---------- poster (arrest + gameover) ---------- */
.poster {
  position: absolute; top: 50%; left: 50%;
  width: 300px;
  transform: translate(-50%, -50%) rotate(-4deg);
  background: var(--parchment);
  border: 4px solid #6b5a35;
  border-radius: 4px;
  padding: 22px 18px 26px;
  box-shadow: 0 14px 0 rgba(0,0,0,.35);
  color: #17130a;
}
.poster.drop { animation: posterdrop .6s cubic-bezier(.25,1.6,.4,1) both; }
@keyframes posterdrop {
  0% { transform: translate(-50%, -160vh) rotate(-14deg); }
  100% { transform: translate(-50%, -50%) rotate(-4deg); }
}
.p-title { font-size: 34px; text-align: center; letter-spacing: 2px; }
.p-stars { display: flex; justify-content: center; gap: 6px; margin: 12px 0; }
.p-stars .star { width: 26px; height: 26px; color: #e8b84a; filter: drop-shadow(1px 1px 0 #6b5a35); }
.p-window {
  height: 170px;
  border: 4px solid #6b5a35;
  background: rgba(0,0,0,.12);
}
.stamp {
  position: absolute;
  left: 50%; top: 58%;
  transform: translate(-50%, -50%) rotate(-14deg) scale(3);
  color: var(--red);
  border: 5px solid var(--red);
  border-radius: 6px;
  font-size: 26px;
  padding: 10px 14px;
  opacity: 0;
  mix-blend-mode: multiply;
}
.stamp.small { font-size: 18px; border-width: 4px; }
.poster .stamp.stamped, .over-poster .stamp.stamped { animation: stampin .28s cubic-bezier(.2,2,.4,1) both; }
@keyframes stampin {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(3); }
  100% { opacity: .92; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}

/* ---------- game over ---------- */
#screen-over {
  background:
    repeating-linear-gradient(-52deg, transparent 0 90px, rgba(255,255,255,.09) 90px 180px),
    #c4d979;
}
.over-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 60px;
  padding: 20px;
}
.over-poster {
  position: relative;
  width: 280px;
  background: var(--parchment);
  border: 4px solid #6b5a35;
  padding: 20px 16px 24px;
  transform: rotate(-3deg);
  color: #17130a;
  box-shadow: 0 12px 0 rgba(0,0,0,.25);
}
.over-poster .p-title { font-size: 28px; }
.p-photo { height: 150px; border: 4px solid #6b5a35; background: #555; }
.over-right { width: min(480px, 92vw); text-align: center; color: var(--navy); }
.go-score-wrap { margin-bottom: 8px; }
#go-score { font-size: 44px; color: #2c3a1e; text-shadow: 2px 2px 0 rgba(255,255,255,.4); }
.go-top { font-size: 18px; margin-top: 12px; color: #2c3a1e; }
#go-newtop { font-size: 12px; color: var(--red); margin-top: 12px; display: none; animation: blink .8s steps(2) infinite; }

/* ---------- pause ---------- */
#screen-pause { background: rgba(8, 12, 20, .55); }
.panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--navy);
  border: 4px solid var(--navy-d);
  border-radius: 14px;
  padding: 26px;
  width: min(360px, 92vw);
  text-align: center;
  color: #fff;
  box-shadow: 0 10px 0 rgba(0,0,0,.4);
}
.panel h2 { margin: 0 0 18px; font-size: 20px; letter-spacing: 2px; }
.panel .pixel-btn { width: 100%; margin-top: 12px; }
.about-p { font-size: 9px; line-height: 2; text-align: left; }

/* ---------- gacha ---------- */
#screen-gacha .gacha-cash { z-index: 6; }
.gacha-bottom { position: absolute; bottom: 26px; left: 0; right: 0; display: flex; justify-content: center; }
#gacha-result {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: var(--navy);
  border: 4px solid var(--navy-d);
  border-radius: 14px;
  padding: 24px 30px;
  text-align: center;
  color: #fff;
  box-shadow: 0 12px 0 rgba(0,0,0,.4);
  transition: transform .3s cubic-bezier(.2,2.2,.4,1);
  z-index: 8;
  min-width: 280px;
}
#gacha-result.show { transform: translate(-50%, -50%) scale(1); }
.gr-title { font-size: 14px; color: #f2c230; }
.gr-name { font-size: 18px; margin: 18px 0 10px; }
.gr-rar { font-size: 11px; margin-bottom: 18px; }
.gr-btns { display: flex; gap: 12px; justify-content: center; }

/* ---------- garage ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: none; background: rgba(8,12,20,.6); }
.overlay.show { display: block; }
.garage-box {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(760px, 94vw); max-height: 86vh; overflow: auto;
  background: var(--navy);
  border: 4px solid var(--navy-d);
  border-radius: 14px;
  padding: 18px;
  color: #fff;
}
.garage-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; margin-bottom: 14px; }
#garage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gcard {
  background: #273044;
  border: 3px solid var(--navy-d);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
}
.gcard.sel { border-color: #f2c230; background: #2e3a54; }
.gcard.locked { opacity: .55; }
.gchip { width: 54px; height: 30px; margin: 0 auto 10px; border-radius: 6px; border: 2px solid rgba(255,255,255,.35); }
.gname { font-size: 9px; }
.grar { font-size: 8px; margin: 8px 0; }
.gstats { margin: 10px 0; }
.sbar { display: flex; align-items: center; gap: 6px; margin: 5px 0; font-size: 7px; }
.sbar span { width: 26px; text-align: left; color: #9fb0c8; }
.segs { display: flex; gap: 2px; flex: 1; }
.segs i { flex: 1; height: 8px; background: #4a6fe8; border-radius: 2px; }
.gbtn { font-size: 8px; color: #9fb0c8; margin-top: 6px; }
.gcard.sel .gbtn { color: #f2c230; }

#announce {
  position: absolute; top: 108px; left: 50%; transform: translateX(-50%);
  display: none; font-size: 13px; color: #ffd94a;
  text-shadow: 2px 2px 0 rgba(0,0,0,.55); pointer-events: none; white-space: nowrap;
}
#announce.show { display: block; animation: announcepop 1.6s ease-out both; }
@keyframes announcepop {
  0% { opacity: 0; transform: translateX(-50%) scale(1.8); }
  12% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}
.gimg { width: 100%; height: 56px; object-fit: contain; margin-bottom: 8px; }
#gacha-car-img { width: 180px; height: 90px; object-fit: contain; margin: 6px auto 2px; display: block; }

/* ---------- floating popups ---------- */
#popups { position: fixed; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.pp {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 11px; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.55);
  opacity: 0; white-space: nowrap;
}
.pp.show { animation: pprise .9s ease-out both; }
.pp.good { color: #a4f070; }
.pp.cash { color: #ffd94a; font-size: 13px; }
@keyframes pprise {
  0% { opacity: 0; transform: translate(-50%,-30%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  30% { transform: translate(-50%,-55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-150%) scale(1); }
}
#combo {
  position: absolute; top: 62px; left: 50%; transform: translateX(-50%);
  display: none; font-size: 15px; color: #7fe4ff;
  text-shadow: 2px 2px 0 rgba(0,0,0,.55); pointer-events: none;
}
#combo.show { display: block; animation: combopop .3s cubic-bezier(.2,2.4,.4,1); }
@keyframes combopop { 0% { transform: translateX(-50%) scale(1.7); } 100% { transform: translateX(-50%) scale(1); } }
.badge.score.flash { animation: scoreflash .35s; }
@keyframes scoreflash { 0% { filter: brightness(2); transform: scale(1.1); } 100% { filter: none; transform: none; } }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff;
  border: 3px solid var(--navy-d); border-radius: 10px;
  font-size: 10px; padding: 12px 18px;
  opacity: 0; transition: all .25s; z-index: 30; pointer-events: none;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- touch controls ---------- */
.touch { display: none; position: fixed; bottom: 0; width: 30%; height: 132px; z-index: 6;
  align-items: center; justify-content: center; font-size: 34px; color: rgba(255,255,255,.55);
  background: rgba(16,21,31,.25); border-radius: 18px 18px 0 0; }
#touch-left { left: 8px; }
#touch-right { right: 8px; }
@media (hover: none) and (pointer: coarse) {
  body.in-run .touch { display: flex; }
}

@media (max-width: 760px) {
  .over-wrap { flex-direction: column; gap: 24px; }
  .over-poster { width: 220px; }
  .p-title { font-size: 24px; }
  #go-score { font-size: 32px; }
  .badge { min-width: 110px; font-size: 11px; }
  #hud-stars .star { width: 24px; height: 24px; }
  #press-start { font-size: 10px; }
}
