/* ===============================
   Laotian Racer — New Edition
   Visuals / Layout / Components
   =============================== */

:root {
  --bg-1: #0b2e26;
  --bg-2: #071b15;
  --glass: rgba(255,255,255,0.08);
  --glass-2: rgba(255,255,255,0.14);
  --brand: #2de39b;
  --brand-2: #19c6ff;
  --text: #eafaf3;
  --danger: #ff5d6c;
  --warn: #ffd166;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 18px;
  --panel: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
}

/* Background */
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 1200px at 20% -10%, #135e4a 0%, var(--bg-1) 35%, var(--bg-2) 70%);
  overflow: hidden;
}

/* Top HUD */
.hud {
  position: fixed; inset: 16px 16px auto 16px;
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center;
  z-index: 30;
}
.badge {
  background: linear-gradient(135deg, var(--glass-2), var(--glass));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: var(--shadow);
  padding: 10px 14px; border-radius: var(--radius);
  font-weight: 700; letter-spacing: .2px;
}
.title { font-size: clamp(16px, 2.3vw, 22px); }
.pill { display:flex; align-items:center; gap:10px; }
.dot { width:10px; height:10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 10px var(--brand); }

.btn {
  cursor: pointer; user-select: none; border: 0;
  padding: 10px 16px; border-radius: 14px; font-weight: 700;
  background: linear-gradient(180deg, var(--brand) 0%, #12b889 100%);
  color: #003528; box-shadow: 0 6px 18px rgba(45,227,155,0.45);
  transition: transform .08s ease, filter .2s ease, opacity .2s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.secondary {
  background: linear-gradient(180deg, var(--brand-2) 0%, #0da8e0 100%);
  color: #002235; box-shadow: 0 6px 18px rgba(25,198,255,0.35);
}
.btn.ghost {
  background: var(--glass); color: var(--text);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: var(--shadow);
}
.btn.danger {
  background: linear-gradient(180deg, var(--danger), #d64c58);
  color: #fff; box-shadow: 0 6px 18px rgba(255,93,108,0.35);
}

/* Stage / Canvas */
.stage { position: fixed; inset: 0; display: grid; place-items: center; }
canvas { width: 100vw; height: 100vh; display:block; }

/* Touch pads */
.touchpad {
  position: fixed; bottom: 18px; width: 120px; height: 120px; display: none;
  place-items: center; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  box-shadow: var(--shadow); font-size: 42px; font-weight: 800; user-select: none;
  z-index: 40;
}
.touchpad.left { left: 18px; }
.touchpad.right { right: 18px; }
@media (max-width: 900px) {
  .touchpad { display: grid; }
}

/* Chips */
.chips { position: fixed; left: 16px; bottom: 16px; display:flex; gap:10px; flex-wrap:wrap; z-index: 35; }
.chip {
  background: var(--glass); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px; padding: 8px 12px; box-shadow: var(--shadow);
  font-weight: 700; display:flex; align-items:center; gap:8px;
}

/* Drawers */
.drawer {
  position: fixed; top:0; right: 0; height: 100vh; width: min(420px, 92vw);
  transform: translateX(110%); transition: transform .28s ease; z-index: 50;
  background: rgba(6, 36, 29, 0.9); backdrop-filter: blur(10px);
  border-left: 1px solid rgba(255,255,255,0.1);
  box-shadow: -20px 0 40px rgba(0,0,0,0.4);
  display:flex; flex-direction:column;
}
.drawer.left {
  right: auto; left: 0; border-left: none; border-right: 1px solid rgba(255,255,255,0.1);
  box-shadow: 20px 0 40px rgba(0,0,0,0.4);
  transform: translateX(-110%);
}
.drawer.open { transform: translateX(0); }
.drawer header {
  padding: 18px 16px; display:flex; justify-content:space-between; align-items:center;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.drawer h2 { margin:0; font-size: 20px; }
.list { padding: 12px 14px; overflow:auto; }
.card {
  display:grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items:center;
  background: var(--glass); padding: 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.12); margin-bottom: 12px;
}
.swatch { width: 72px; height: 48px; border-radius: 10px; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2); }
.muted { opacity: .85; font-weight:600; font-size: 12px; }
.price { font-weight:800; }
.owned { color: #a1f7d7; font-weight:800; }

.settings-list .setting-section { margin-bottom: 18px; }
.settings-list h3 { margin: 12px 2px; opacity: .95; }
.setting-row {
  display:flex; align-items:center; justify-content:space-between;
  background: var(--glass); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
}
.setting-row label { font-weight: 700; }
.setting-row input[type="range"] { width: 160px; }

/* Modal */
.modal {
  position: fixed; inset: 0; display:none; place-items:center; padding: 20px;
  background: rgba(0,0,0,0.55); z-index: 60;
}
.modal.show { display:grid; }
.modal.translucent { background: rgba(0,0,0,0.35); }
.panel {
  width: min(560px, 92vw); background: var(--panel);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 22px; box-shadow: var(--shadow);
  padding: 20px; text-align:center;
}
.panel.glassy { backdrop-filter: blur(6px); }
.panel h1 { margin-top:6px; margin-bottom:6px; font-size: clamp(28px, 5vw, 42px); }
.panel p { opacity:.9; }
.row { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

/* Achievements grid */
.achv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
  max-height: 50vh; overflow: auto; margin: 14px 0;
}
.achv {
  background: var(--glass); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 12px; text-align:left;
}
.achv h4 { margin: 0 0 6px 0; }
.achv .tag { display:inline-block; padding: 2px 8px; font-size: 11px; border-radius: 999px; background: rgba(255,255,255,0.1); }
.achv.unlocked { border-color: rgba(45,227,155,0.6); box-shadow: 0 0 0 2px rgba(45,227,155,0.2) inset; }

/* Hint */
.hint {
  position: fixed; bottom: 16px; right: 16px; background: var(--glass);
  border:1px solid rgba(255,255,255,0.14); padding:8px 12px; border-radius: 10px;
  box-shadow: var(--shadow); font-size:12px; opacity:.9; z-index: 35;
}

/* Debug HUD */
.debug {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.18);
  padding: 6px 10px; border-radius: 10px; font-size: 12px; z-index: 70;
}

/* Utility */
.hidden { display:none !important; }
