@font-face { font-family: "Press Start 2P"; src: url("fonts/pressstart2p.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "VT323"; src: url("fonts/vt323.woff2") format("woff2"); font-display: block; }

/* city palette: asphalt, curb white, taxi yellow, street-sign green, stop red */
:root { --ink: #1d1b24; --asphalt: #2b2d33; --curb: #ece8dc; --taxi: #ffcc33; --sign: #1e6b3f; --stop: #c62828; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--asphalt); overflow: hidden; color: var(--curb);
  font-family: "VT323", ui-monospace, monospace; font-size: 20px; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; image-rendering: pixelated; }

.hidden { display: none !important; }
.dim { color: #a9a49a; }
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.hud > * { pointer-events: auto; }
.panel { background: rgba(43,45,51,.94); border: 3px solid var(--curb); border-radius: 6px; box-shadow: 0 3px 0 var(--ink); padding: 6px 12px; }
.sign { background: var(--sign); border: 3px solid var(--curb); border-radius: 5px; box-shadow: 0 0 0 2px var(--sign), 0 4px 0 2px var(--ink); padding: 6px 12px;
  font-family: "Press Start 2P"; font-size: 11px; color: #fff; }
.label { font-family: "Press Start 2P", monospace; font-size: 8px; color: var(--taxi); margin-right: 8px; letter-spacing: 1px; }

#hp { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 8px;
  background: rgba(43,45,51,.94); border: 3px solid var(--curb); border-radius: 6px; box-shadow: 0 3px 0 var(--ink); padding: 4px 10px; width: min(440px, calc(100vw - 16px)); }
#hp .label { margin: 0; }
.hpbar { flex: 1; height: 12px; background: var(--ink); border: 2px solid #55555f; border-radius: 3px; overflow: hidden; }
.hpbar i { display: block; height: 100%; width: 100%; background: #3fbf5a; transition: width .2s linear, background .3s; }
#hp-t { width: 32px; text-align: right; font-size: 22px; }
#drain { font-size: 16px; width: 48px; }
#clock { font-family: "Press Start 2P"; font-size: 9px; color: var(--taxi); }
#hp.low { animation: pulse .6s ease-in-out infinite alternate; border-color: #ff6a6a; }
@keyframes pulse { to { box-shadow: 0 3px 0 var(--ink), 0 0 16px #ff3b3b; } }

.zone { position: absolute; top: 52px; left: 8px; }
.right { position: absolute; top: 52px; right: 8px; display: flex; gap: 6px; align-items: stretch; }
.count { font-family: "Press Start 2P"; font-size: 10px; display: flex; align-items: center; gap: 6px; color: var(--taxi); padding: 4px 10px; }
.count span { color: var(--curb); }
.inv { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.inv span { display: inline-flex; align-items: center; gap: 4px; }
.inv canvas, .caps canvas { width: 20px; height: 20px; image-rendering: pixelated; }

.btn { font-family: "Press Start 2P", monospace; font-size: 10px; color: var(--ink); background: var(--taxi); border: 3px solid var(--ink); border-radius: 5px;
  padding: 7px 10px; cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform .08s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.danger { background: var(--stop); color: #fff; }
.btn.big { font-size: 13px; padding: 14px 22px; }

.banner { position: fixed; top: 24%; left: 0; right: 0; text-align: center; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .4s; }
.banner.on { opacity: 1; }
.banner span { display: inline-block; font-family: "Press Start 2P"; font-size: 16px; color: #fff; background: var(--sign); border: 3px solid #fff;
  border-radius: 6px; padding: 10px 16px; box-shadow: 0 0 0 3px var(--sign), 0 6px 0 3px var(--ink); letter-spacing: 2px; }
.banner small { display: block; font-size: 20px; margin-top: 12px; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 4px var(--ink); }
.toast { position: fixed; bottom: 70px; left: 50%; transform: translate(-50%, 20px); z-index: 8; pointer-events: none; opacity: 0; transition: all .3s;
  background: var(--taxi); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: 6px 14px; white-space: nowrap; font-size: 22px; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

#pad { position: fixed; left: 18px; bottom: 70px; width: 150px; height: 150px; z-index: 6; display: none; }
.pb { position: absolute; width: 50px; height: 50px; font-size: 18px; color: var(--curb); background: rgba(43,45,51,.6); border: 3px solid rgba(236,232,220,.8); border-radius: 10px; }
.pb.up { left: 50px; top: 0 } .pb.down { left: 50px; bottom: 0 } .pb.left { left: 0; top: 50px } .pb.right { right: 0; top: 50px }
.pb.on { background: rgba(255,204,51,.6); }
@media (pointer: coarse) { #pad { display: block; } }

/* battle */
.target { position: absolute; top: 52px; left: 8px; width: min(380px, calc(100vw - 16px)); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 22px; }
.row.small { font-size: 18px; color: #c9c4b8; }
#b-name { font-family: "Press Start 2P"; font-size: 11px; line-height: 1.5; }
.tier { font-family: "Press Start 2P"; font-size: 8px; padding: 4px 6px; color: var(--ink); border-radius: 3px; white-space: nowrap; }
.tier.M { animation: rainbow 2s linear infinite; }
@keyframes rainbow { 0% { background: #ff3df0 } 25% { background: #2ef2ff } 50% { background: #ffe14a } 75% { background: #45e08a } 100% { background: #ff3df0 } }
.meter { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 18px; }
.meter .label { width: 46px; margin: 0; }
.bar { flex: 1; height: 8px; background: var(--ink); border-radius: 2px; }
.bar i { display: block; height: 100%; width: 0; background: #3fbf5a; border-radius: 2px; transition: width .3s; }
.bar.flee i { background: #ff6a6a; }
.meter > span:last-child { width: 48px; text-align: right; }
.log { position: absolute; left: 8px; right: 8px; bottom: calc(118px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; font-size: 22px; min-height: 44px; }
.actions { position: absolute; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.caps, .moves { display: flex; gap: 6px; }
.caps .btn, .moves .btn { flex: 1; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 8px; }
.caps .btn { background: var(--curb); }
.aimhint { position: absolute; bottom: 40px; left: 0; right: 0; text-align: center; font-family: "Press Start 2P"; font-size: 10px; color: #fff; text-shadow: 0 2px 0 var(--ink); animation: blink 1s steps(2) infinite; pointer-events: none; }
@keyframes blink { 50% { opacity: .3 } }

/* modals */
.modal { position: fixed; inset: 0; z-index: 10; background: rgba(29,27,36,.82); display: flex; align-items: center; justify-content: center; }
.modal-in { width: min(760px, 96vw); height: min(92vh, 900px); display: flex; flex-direction: column; background: var(--asphalt); border: 3px solid var(--curb); border-radius: 8px; box-shadow: 0 6px 0 var(--ink); }
.modal-in.small { height: auto; max-height: 92vh; width: min(460px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-family: "Press Start 2P"; font-size: 12px; border-bottom: 3px solid var(--curb); gap: 10px; background: var(--sign); border-radius: 5px 5px 0 0; }
.modal-head span:nth-child(2) { font-family: "VT323"; font-size: 22px; flex: 1; text-align: right; }
.dex-grid { flex: 1; overflow-y: auto; display: grid; align-content: start; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; padding: 10px; touch-action: pan-y; }
.cell { background: #34363d; border: 2px solid #4a4c55; border-radius: 4px; padding: 4px; text-align: center; cursor: pointer; }
.cell canvas { width: 48px; height: 48px; image-rendering: pixelated; display: block; margin: 0 auto; }
.cell .no { font-size: 14px; color: #a9a49a; }
.cell .nm { font-size: 14px; line-height: 1; height: 28px; overflow: hidden; }
.cell:not(.caught) .nm { color: #7d7a72; }
.cell.caught { background: #3a3c44; }
.cell.sel { outline: 3px solid var(--taxi); }
.dex-detail { display: flex; gap: 14px; padding: 12px; border-bottom: 3px solid #4a4c55; min-height: 120px; align-items: center; }
.dex-detail canvas { width: 96px; height: 96px; image-rendering: pixelated; flex: none; }
.dex-detail h3 { margin: 0 0 4px; font-family: "Press Start 2P"; font-size: 11px; line-height: 1.5; }
.dex-detail p { margin: 4px 0; font-size: 19px; line-height: 1.05; }
.shop-hi { margin: 10px 14px 4px; color: #c9c4b8; }
#shop-list { padding: 6px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.shop-row { display: flex; align-items: center; gap: 10px; background: #34363d; border: 2px solid #4a4c55; border-radius: 5px; padding: 8px; }
.shop-row canvas { width: 30px; height: 30px; image-rendering: pixelated; }
.shop-info { flex: 1; line-height: 1.05; }
.shop-info b { font-family: "Press Start 2P"; font-size: 9px; font-weight: normal; }

.title-in { text-align: center; max-width: 560px; padding: 20px; }
.logo { font-family: "Press Start 2P"; font-size: clamp(26px, 8vw, 46px); color: #fff; text-shadow: 0 4px 0 var(--ink); letter-spacing: 2px; }
.logo b { color: var(--taxi); font-weight: normal; }
.sub { display: inline-block; font-family: "Press Start 2P"; font-size: 8px; color: #fff; background: var(--sign); border: 2px solid #fff; border-radius: 4px; padding: 6px 8px; margin: 14px 0 12px; letter-spacing: 1px; }
#title-art { width: min(480px, 90vw); image-rendering: pixelated; }
.title-in p { font-size: 21px; line-height: 1.1; }
.keys { color: #a9a49a; font-size: 18px !important; }
.myth { animation: rainbowt 2s linear infinite; }
@keyframes rainbowt { 0% { color: #ff3df0 } 25% { color: #2ef2ff } 50% { color: #ffe14a } 75% { color: #45e08a } 100% { color: #ff3df0 } }
#title { background: rgba(29,27,36,.72); }

@media (max-width: 520px) {
  .sign { font-size: 9px; padding: 6px 8px; }
  .count { font-size: 8px; padding: 4px 6px; }
  .right .btn { padding: 6px 6px; font-size: 8px; }
  #drain { display: none; }
  .modal-head span:nth-child(2) { font-size: 16px; }
  .zone { top: 96px; }
}
