:root {
  --box: #12203a;
  --box2: #0c1830;
  --edge: #eaf1ff;
  --gold: #f6c500;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif; -webkit-user-select: none; user-select: none; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- loading ---- */
#loading {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #274a6e, #0b1524);
  color: #fff; text-align: center;
}
.load-title { font-size: 42px; font-weight: 800; letter-spacing: 2px; }
.load-sub { margin-top: 8px; opacity: .8; font-size: 16px; }
.load-tip { margin-top: 22px; max-width: 440px; opacity: .7; font-size: 14px; }

/* ================= Dialogue (Pokémon-style) ================= */
#dlg {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(860px, 94vw); min-height: 118px; z-index: 30;
  display: flex; gap: 14px; padding: 14px;
  background: linear-gradient(180deg, var(--box), var(--box2));
  border: 4px solid var(--edge); border-radius: 16px;
  box-shadow: 0 0 0 4px #0a1220, 0 12px 34px rgba(0,0,0,.6);
  transition: opacity .18s ease, transform .18s ease;
}
#dlg.hidden { opacity: 0; transform: translateX(-50%) translateY(16px); pointer-events: none; }
#dlg[data-tone="scold"] { border-color: #ff8f7e; box-shadow: 0 0 0 4px #3a0d08, 0 12px 34px rgba(0,0,0,.6); }
#dlg[data-tone="warn"]  { border-color: #ffd479; box-shadow: 0 0 0 4px #3a2a05, 0 12px 34px rgba(0,0,0,.6); }
#dlg[data-tone="praise"]{ border-color: #9be48c; box-shadow: 0 0 0 4px #0f3510, 0 12px 34px rgba(0,0,0,.6); }
#dlg-portrait {
  width: 92px; height: 92px; flex: 0 0 92px; border-radius: 12px;
  border: 3px solid rgba(255,255,255,.35); background: #101826; align-self: center;
  image-rendering: auto;
}
#dlg-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
#dlg-name { color: var(--gold); font-weight: 800; font-size: 15px; letter-spacing: .4px; margin-bottom: 4px; }
#dlg-text { color: #dfe8ff; font-size: 21px; line-height: 1.28; font-weight: 600; min-height: 27px; }
#dlg-sub  { color: #9fb4d8; font-size: 14px; font-style: italic; margin-top: 6px; }
#dlg-next { position: absolute; right: 16px; bottom: 10px; color: var(--edge); font-size: 18px; opacity: 0; }

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; color: #fff; }

#objective {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(10,18,32,.78); border: 2px solid rgba(255,255,255,.22);
  padding: 8px 16px; border-radius: 999px; font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
#obj-arrow { color: var(--gold); font-size: 20px; display: inline-block; }

#gauge-wrap {
  position: absolute; right: 22px; bottom: 22px; width: 150px; height: 150px;
}
#speedo { position: absolute; inset: 0; }
#speed-num {
  position: absolute; top: 52px; left: 0; width: 100%; text-align: center;
  font-size: 40px; font-weight: 800; text-shadow: 0 2px 6px #000;
}
#speed-num::after { content: ' km/h'; font-size: 12px; font-weight: 600; opacity: .7; }
#gear {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
  font-size: 18px; font-weight: 800; color: var(--gold);
  background: rgba(0,0,0,.4); border-radius: 6px; padding: 1px 10px;
}
#limit {
  position: absolute; right: 186px; bottom: 60px; width: 66px; height: 66px; border-radius: 50%;
  background: #fff; border: 7px solid #d0161f; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
#limit.over { animation: pulse .5s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(208,22,31,.6); } to { box-shadow: 0 0 0 10px rgba(208,22,31,0); } }
#limit-num { color: #111; font-size: 27px; font-weight: 800; }

#minimap {
  position: absolute; top: 16px; right: 16px; width: 180px; height: 180px;
  border: 2px solid rgba(255,255,255,.25); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
#controls {
  position: absolute; left: 16px; bottom: 16px; font-size: 13px; color: #cdd8ea;
  background: rgba(10,18,32,.6); padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14);
}
