:root {
  --bg: #0b1118;
  --panel: rgba(10, 16, 24, 0.72);
  --panel-strong: rgba(10, 16, 24, 0.88);
  --line: rgba(255,255,255,0.08);
  --text: #eef4ff;
  --muted: #9fb0c7;
  --accent: #f5c400;
  --accent2: #ff5a3d;
  --good: #59ffa1;
  --shadow: 0 20px 60px rgba(0,0,0,0.45);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body, #app { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
canvas { display: block; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.hidden { display: none !important; }

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(18,26,38,0.82), rgba(10,16,24,0.62));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.brand-mini {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.brand-gta {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 18px rgba(245,196,0,0.25);
}
.brand-gta span { color: var(--accent); }

.hud-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stat-pill {
  min-width: 88px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.stat-pill .label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 2px;
}
.stat-pill .value {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-pill.wanted-pill .value { display: flex; gap: 4px; align-items: center; min-height: 24px; }
.wanted-dot {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  transform: skewX(-10deg);
}
.wanted-dot.active {
  background: linear-gradient(180deg, #ffe27a, var(--accent));
  border-color: rgba(255,226,122,0.8);
  box-shadow: 0 0 10px rgba(245,196,0,0.45);
}

.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.hint {
  max-width: min(520px, calc(100vw - 200px));
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.hint strong { color: #fff; }
.hint .k {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 5px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: baseline;
}

.minimap-wrap {
  width: 168px;
  height: 168px;
  padding: 6px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
#minimap {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: #0a121c;
}

/* Toast / interact */
.toast, .interact-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: rgba(10, 16, 24, 0.88);
  border: 1px solid var(--line);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 40;
  max-width: min(92vw, 680px);
  text-align: center;
}
.toast { top: max(14px, env(safe-area-inset-top)); }
.interact-hint { bottom: max(140px, calc(env(safe-area-inset-bottom) + 120px)); font-size: 15px; }

/* Menus */
.menu-overlay, .pause-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(10,18,30,0.35), rgba(5,8,14,0.72));
  backdrop-filter: blur(4px);
  z-index: 50;
}
.menu-card {
  width: min(720px, 100%);
  padding: 28px;
  background: linear-gradient(180deg, rgba(20,30,44,0.94), rgba(10,16,24,0.94));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  box-shadow: 0 30px 100px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
}
.menu-tag {
  display: inline-block;
  padding: 4px 10px;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #111;
  background: var(--accent);
  border-radius: 999px;
}
.menu-card h1 {
  font-size: clamp(40px, 8vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-weight: 900;
}
.menu-card h1 span { color: var(--accent); }
.menu-sub {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 56ch;
}
.menu-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.btn {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255,255,255,0.1);
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  pointer-events: auto;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary {
  color: #151515;
  background: linear-gradient(180deg, #ffe27a, var(--accent));
  border-color: rgba(255,226,122,0.5);
  box-shadow: 0 8px 24px rgba(245,196,0,0.25);
}
.btn-ghost {
  color: #fff;
  background: rgba(255,255,255,0.04);
}
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 14px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.control {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.k {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

/* Touch controls */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: none;
}
.touch-zone {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  pointer-events: auto;
}
.touch-zone.left { left: max(18px, env(safe-area-inset-left)); align-items: flex-end; }
.touch-zone.right { right: max(18px, env(safe-area-inset-right)); flex-direction: column; align-items: flex-end; }
.touch-row { display: flex; gap: 12px; }
.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.touch-btn:active, .touch-btn.active {
  background: rgba(245,196,0,0.22);
  border-color: rgba(245,196,0,0.55);
  transform: scale(0.97);
}
.touch-btn.wide { width: 84px; }
.touch-btn.action { width: 48px; height: 44px; border-radius: 12px; font-size: 12px; }
.touch-btn:disabled { opacity: 0.4; }
.touch-btn small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; }
.touch-stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }

/* Responsive */
@media (max-width: 900px) {
  .brand-gta { font-size: 24px; }
  .stat-pill { min-width: 76px; padding: 7px 10px; }
  .stat-pill .value { font-size: 15px; }
  .minimap-wrap { width: 136px; height: 136px; }
  .hint { font-size: 12px; max-width: min(480px, calc(100vw - 170px)); }
}
@media (max-width: 700px) {
  .hud-top { flex-direction: column; align-items: stretch; }
  .hud-stats { justify-content: flex-start; }
  .hint { display: none; }
  .minimap-wrap { width: 120px; height: 120px; }
  .menu-card { padding: 22px; }
  .menu-sub { font-size: 14px; }
}
@media (pointer: coarse), (max-width: 900px) {
  .touch-controls { display: block; }
  .hint { display: none; }
  .hud-bottom { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(102px, calc(env(safe-area-inset-bottom) + 84px)); }
  .minimap-wrap { width: 108px; height: 108px; }
  .interact-hint { bottom: max(230px, calc(env(safe-area-inset-bottom) + 212px)); }
  .toast { top: auto; bottom: max(18px, env(safe-area-inset-bottom)); }
}
@media (max-width: 440px) {
  .touch-row { gap: 8px; }
  .touch-btn { width: 59px; height: 56px; font-size: 11px; }
  .touch-btn.wide { width: 69px; }
  .touch-btn.action { width: 44px; height: 40px; }
  .minimap-wrap { width: 94px; height: 94px; }
  .hud-bottom { top: calc(max(14px, env(safe-area-inset-top)) + 116px); right: max(14px, env(safe-area-inset-right)); bottom: auto; left: auto; }
  .toast { bottom: max(218px, calc(env(safe-area-inset-bottom) + 200px)); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .touch-btn { width: 58px; height: 58px; border-radius: 14px; font-size: 12px; }
  .touch-btn.action { height: 38px; }
  .minimap-wrap { width: 110px; height: 110px; }
  .hud-top { flex-direction: row; }
  .hint { display: none; }
}
