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

:root {
  --bg: #12151b;
  --panel: rgba(18, 22, 30, 0.82);
  --panel-border: rgba(120, 140, 170, 0.18);
  --text: #d7dee8;
  --text-dim: #8b95a5;
  --accent: #ffb347;
  --good: #4ecb8f;
  --warn: #e8c34a;
  --bad: #e8604c;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Windshield grime ---------- */
#grime {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(90, 78, 60, 0.5) 0%, transparent 8%),
    radial-gradient(circle at 70% 20%, rgba(80, 70, 55, 0.5) 0%, transparent 7%),
    radial-gradient(circle at 45% 60%, rgba(95, 82, 62, 0.4) 0%, transparent 9%),
    radial-gradient(circle at 85% 70%, rgba(78, 68, 52, 0.45) 0%, transparent 8%),
    radial-gradient(circle at 12% 80%, rgba(88, 76, 58, 0.4) 0%, transparent 7%),
    radial-gradient(circle at 60% 85%, rgba(82, 72, 55, 0.42) 0%, transparent 8%),
    radial-gradient(ellipse at 50% 40%, rgba(70, 62, 48, 0.28) 0%, rgba(60, 54, 42, 0.16) 60%, transparent 100%);
  transition: opacity 0.4s linear;
  mix-blend-mode: multiply;
}

/* ---------- Rain ---------- */
#rain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background-image: repeating-linear-gradient(
    100deg,
    transparent 0 6px,
    rgba(174, 194, 224, 0.14) 6px 7px,
    transparent 7px 13px
  );
  background-size: 100% 200%;
  transition: opacity 0.8s linear;
  animation: rainfall 0.55s linear infinite;
}
@keyframes rainfall {
  from { background-position: 0 0; }
  to   { background-position: -40px 200%; }
}

/* ---------- Wipers ---------- */
.wiper {
  position: absolute;
  bottom: -20%;
  width: 4px;
  height: 90%;
  background: linear-gradient(to top, rgba(20, 24, 30, 0.9), rgba(40, 46, 56, 0.3));
  transform-origin: bottom center;
  opacity: 0;
  pointer-events: none;
  border-radius: 3px;
}
#wiper-left  { left: 32%; }
#wiper-right { left: 68%; }
.wiper.sweeping { opacity: 0.85; animation: wipe 0.7s ease-in-out; }
@keyframes wipe {
  0%   { transform: rotate(48deg); }
  50%  { transform: rotate(-48deg); }
  100% { transform: rotate(48deg); }
}

/* ---------- Panels ---------- */
.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.7rem;
  padding: 0.75rem 0.85rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  font-size: 0.85rem;
}
#gauges { top: 1rem; left: 1rem; width: 15rem; max-width: 42vw; }
#status { top: 1rem; right: 1rem; width: 13rem; max-width: 40vw; }

.panel-title {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
  font-weight: 600;
}

/* Gauge bars */
.gauge {
  margin-bottom: 0.5rem;
}
.gauge:last-child { margin-bottom: 0; }
.gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  margin-bottom: 0.18rem;
}
.gauge-name { color: var(--text-dim); }
.gauge-name .g-icon { margin-right: 0.3rem; }
.gauge-pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.gauge-bar {
  height: 0.45rem;
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 100%;
  border-radius: 0.3rem;
  transition: width 0.25s linear, background 0.3s;
}
.gauge.low .gauge-name { color: var(--bad); }
.gauge.low.flash { animation: warnflash 0.9s ease-in-out infinite; }
@keyframes warnflash { 50% { opacity: 0.45; } }

/* Status rows */
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}
.status-label { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.1em; }
.status-val { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
#stat-money { color: var(--good); }

#job-box {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--panel-border);
}
.job-title { font-size: 0.68rem; letter-spacing: 0.12em; color: var(--text-dim); margin-bottom: 0.25rem; }
#job-desc { font-size: 0.82rem; line-height: 1.25; }
#job-dist { font-size: 0.72rem; color: var(--accent); margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
#weather-line {
  margin-top: 0.55rem; padding-top: 0.5rem;
  border-top: 1px solid var(--panel-border);
  font-size: 0.76rem; color: var(--text-dim);
}

/* ---------- Dash (speed) ---------- */
#dash {
  position: absolute;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.8rem;
  padding: 0.5rem 1.1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
#speedo { display: flex; align-items: baseline; gap: 0.3rem; }
#speed-val { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.speed-unit { font-size: 0.75rem; color: var(--text-dim); }
#gear-ind {
  font-size: 1.4rem; font-weight: 700; color: var(--accent);
  min-width: 1.6rem; text-align: center;
  border-left: 1px solid var(--panel-border); padding-left: 0.9rem;
}

#prompt {
  position: absolute;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 179, 71, 0.16);
  border: 1px solid rgba(255, 179, 71, 0.5);
  color: var(--accent);
  padding: 0.5rem 1.1rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#prompt.show { opacity: 1; }

#controls-hint {
  position: absolute;
  bottom: 0.4rem;
  right: 0.8rem;
  font-size: 0.68rem;
  color: var(--text-dim);
  opacity: 0.7;
}
#controls-hint b { color: var(--text); }

/* ---------- Modals ---------- */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 14, 0.7);
  backdrop-filter: blur(3px);
  z-index: 20;
}
.modal.hidden { display: none; }
.modal-card {
  background: #1a1f28;
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  padding: 1.5rem 1.6rem;
  width: 26rem;
  max-width: 90vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent);
}

/* Service items */
.svc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.6rem;
  margin-bottom: 0.55rem;
}
.svc-info { flex: 1; min-width: 0; }
.svc-name { font-weight: 600; font-size: 0.92rem; }
.svc-sub { font-size: 0.74rem; color: var(--text-dim); margin-top: 0.15rem; }
.svc-buy {
  background: var(--accent);
  color: #1a1206;
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.8rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.svc-buy:hover { filter: brightness(1.1); }
.svc-buy:disabled { opacity: 0.4; cursor: not-allowed; }
.svc-item.full .svc-buy { background: var(--good); color: #06210f; }

.btn-close, .btn-primary {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.65rem;
  border-radius: 0.6rem;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.btn-close:hover { background: rgba(255, 255, 255, 0.12); }
.btn-primary {
  background: var(--accent);
  color: #1a1206;
  border: none;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.1); }

.intro-body { font-size: 0.9rem; line-height: 1.5; color: var(--text); }
.intro-body p { margin-bottom: 0.7rem; }
.intro-body b { color: var(--accent); }
.intro-keys { font-size: 0.8rem; color: var(--text-dim) !important; }
.intro-keys b { color: var(--text); }

#gameover-text { font-size: 0.95rem; line-height: 1.6; margin-bottom: 0.5rem; }
#gameover-text .go-stat { color: var(--accent); font-weight: 700; }

/* ---------- Toast ---------- */
#toast {
  position: absolute;
  top: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  z-index: 15;
  pointer-events: none;
}
.toast-msg {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toastin 0.3s ease-out;
}
.toast-msg.bad { border-left-color: var(--bad); }
.toast-msg.good { border-left-color: var(--good); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Gary the gull's speech bubble ---------- */
.bird-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 15rem;
  background: #f2f4f7;
  color: #1a1f28;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.4rem 0.7rem;
  border-radius: 0.7rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  z-index: 14;
  white-space: normal;
  text-align: center;
  transition: opacity 0.2s;
}
.bird-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -0.5rem;
  transform: translateX(-50%);
  border: 0.35rem solid transparent;
  border-top-color: #f2f4f7;
}
.bird-bubble.show { opacity: 0.97; }

/* ---------- Loading ---------- */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 1rem;
  z-index: 30;
}
#loading.hidden { display: none; }

@media (max-width: 560px) {
  #gauges { width: 12rem; font-size: 0.78rem; }
  #controls-hint { display: none; }
  #speed-val { font-size: 1.5rem; }
}
