:root {
  --bg: rgba(10, 16, 26, 0.78);
  --line: rgba(255, 255, 255, 0.14);
  --text: #eef3f8;
  --muted: #9fb0c2;
  --accent: #ffb020;
  --accent2: #3fa9ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1119; color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif; }
#app canvas { display: block; }
#hud { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: #0b1119 url(../art/loading/phantom-flighter-dodecagons.png) center / contain no-repeat; } /* the whole image fits any window */
.load-box { width: min(560px, 90vw); margin-bottom: 7vh; padding: 14px 18px; background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line); border-radius: 10px; }
#load-text { font-size: 15px; margin-bottom: 8px; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.15); border-radius: 4px; overflow: hidden; }
#load-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.2s; }

#menu { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-columns: minmax(300px, 420px) 1fr minmax(300px, 400px);
  gap: 0; pointer-events: none; }
#menu.hidden { display: none; }
.menu-col { pointer-events: auto; background: var(--bg); backdrop-filter: blur(6px); padding: 18px 18px 24px; overflow-y: auto; }
.menu-col.left { grid-column: 1; border-right: 1px solid var(--line); }
.menu-col.right { grid-column: 3; border-left: 1px solid var(--line); }
h2 { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; }
h2:first-child { margin-top: 0; }
button { font: inherit; color: var(--text); cursor: pointer; }

.card { display: flex; width: 100%; text-align: left; gap: 12px; padding: 8px; margin-bottom: 8px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.card:hover { background: rgba(255, 255, 255, 0.09); }
.card.selected { border-color: var(--accent); background: rgba(255, 176, 32, 0.12); }
.thumb { flex: 0 0 128px; height: 80px; border-radius: 6px; background: #223 center / cover no-repeat; }
.card-title { font-weight: 700; font-size: 15px; }
.card-role { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.card-stats span { display: inline-block; font-size: 11px; padding: 2px 6px; margin: 0 4px 4px 0; border-radius: 4px;
  background: rgba(255, 255, 255, 0.08); }

.course { display: block; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.course.selected { border-color: var(--accent2); background: rgba(63, 169, 255, 0.13); }
.course-name { font-weight: 700; }
.course-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.lvl { font-size: 11px; margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: #2b6; color: #031; }
.lvl-Mellem { background: #fc4; }
.lvl-Svær { background: #f65; }

.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.seg button.selected { border-color: var(--accent2); background: rgba(63, 169, 255, 0.15); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.actions button { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 15px; }
.actions .primary { background: linear-gradient(180deg, #ffbf3a, #e8920c); color: #1a1000; font-weight: 800; border: none; font-size: 17px; }
.actions button:disabled { opacity: 0.5; cursor: default; }
.hint { color: var(--muted); font-size: 12px; text-align: center; }

#help { position: fixed; right: 16px; top: 16px; z-index: 20; display: none; padding: 14px 18px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
#help.show { display: block; }
#help h3 { margin: 0 0 8px; }
#help td { padding: 2px 10px 2px 0; }
#help td:first-child { color: var(--accent); white-space: nowrap; }

@media (max-width: 900px) {
  #menu { grid-template-columns: 1fr; overflow-y: auto; pointer-events: auto; }
  .menu-col.left, .menu-col.right { grid-column: 1; border: none; }
}

/* ---- touch controls (phones / tablets) */
#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; user-select: none; -webkit-user-select: none; }
#touch.hidden { display: none; }
#touch > *, #touch button { pointer-events: auto; touch-action: none; }
#touch button { font: 600 13px "Segoe UI", system-ui, sans-serif; color: #fff; background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 10px; }
.t-stick { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: 18px; width: 150px; height: 150px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.35); }
.t-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%;
  background: rgba(141, 255, 176, 0.55); }
.t-throttle { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: 18px; width: 56px; height: 160px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.35); overflow: hidden; }
.t-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(255, 176, 32, 0.55); }
.t-throttle span { position: absolute; left: 0; right: 0; top: 6px; text-align: center; font-size: 11px; color: #fff; }
.t-brake { position: absolute; left: calc(max(16px, env(safe-area-inset-left)) + 66px); bottom: 18px; width: 70px; height: 48px; }
.t-buttons { position: absolute; top: 64px; right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 6px; }
.t-buttons button { width: 70px; height: 38px; }
.t-pedals { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: none; gap: 14px; }
.t-pedals button { width: 90px; height: 90px; font-size: 26px !important; border-radius: 50% !important; }
#touch.bike .t-pedals { display: flex; }
.t-ice { display: none; }
#touch.bike .t-ice { display: block; }
#touch.bike .t-throttle, #touch.bike .t-buttons button[data-a="gear"], #touch.bike .t-buttons button[data-a^="flaps"] { display: none; }
@media (pointer: coarse) { #help { display: none !important; } }
.t-pedals { bottom: 190px; }
#touch::before { content: "Drej telefonen til liggende for den bedste oplevelse"; display: none; position: absolute; top: 8px;
  left: 50%; transform: translateX(-50%); padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.55);
  font-size: 12px; color: #fff; white-space: nowrap; }
@media (orientation: portrait) { #touch::before { display: block; } }

/* ---- area picker */
#area-modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); }
#area-modal.hidden { display: none; }
.area-box { width: min(1000px, 96vw); height: min(720px, 94vh); display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: #0f1724; border: 1px solid var(--line); border-radius: 12px; }
.area-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.area-head h2 { margin: 0; }
#area-search-form { display: flex; gap: 6px; flex: 1; min-width: 220px; }
#area-search { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0b1119; color: var(--text); font: inherit; }
#area-search-form button, .area-foot button, #area-presets button { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); }
#area-presets { display: flex; flex-wrap: wrap; gap: 6px; }
#area-presets button { padding: 5px 10px; font-size: 13px; }
#area-map { flex: 1; min-height: 200px; border-radius: 8px; background: #223; }
.area-foot { display: flex; gap: 8px; align-items: center; }
#area-status { flex: 1; font-size: 13px; color: var(--muted); }
.primary-btn { background: linear-gradient(180deg, #ffbf3a, #e8920c) !important; color: #1a1000 !important; font-weight: 800; border: none !important; }

/* ---- pause menu (the game stays where it is behind it) */
#pause { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(5, 10, 18, 0.45); }
#pause.hidden { display: none; }
.pause-box { width: min(340px, 90vw); display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--bg);
  backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 12px; }
.pause-box h2 { margin: 0 0 6px; text-align: center; font-size: 16px; }
.pause-box button { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 15px; }
#cockpit-tip { position: fixed; z-index: 8; display: none; padding: 4px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.75);
  color: #fff; font-size: 13px; pointer-events: none; white-space: nowrap; }
