/* Shared 3D simulation-game styles (see sim3d.js). Scoped to .sim-* classes. */

.sim-play { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.sim-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 76vh;
  border-radius: 14px; overflow: hidden; background: #0b1622;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .06);
  touch-action: none; user-select: none; -webkit-user-select: none; container-type: inline-size;
}
@container (max-width: 620px) { .sim-compass { display: none; } }
@media (max-width: 560px) { .sim-stage { aspect-ratio: 4 / 3.4; } }
.sim-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.sim-stage canvas:focus-visible { box-shadow: inset 0 0 0 3px #ffd54a; }
.sim-overlay { position: absolute; inset: 0; pointer-events: none; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff; }
.sim-overlay button { pointer-events: auto; }

/* instrument cluster */
.sim-hud { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 5px; }
.sim-gauge {
  background: rgba(8, 16, 28, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; padding: 5px 9px; min-width: 64px; text-align: center; line-height: 1.1;
}
.sim-gauge b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sim-gauge small { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.sim-gauge.is-warn { border-color: #ff5b5b; background: rgba(120, 10, 10, .7); animation: sim-blink .5s steps(2) infinite; }
@keyframes sim-blink { 50% { opacity: .55; } }
.sim-bar { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .18); margin-top: 3px; overflow: hidden; }
.sim-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #4ade80, #facc15, #fb7185); }

/* compass tape */
.sim-compass { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: min(300px, 40%); height: 26px; overflow: hidden;
  background: rgba(8, 16, 28, .55); border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px; }
.sim-compass__tape { position: absolute; top: 0; height: 100%; white-space: nowrap; font: 700 12px/26px system-ui, sans-serif; }
.sim-compass__tape span { display: inline-block; width: 30px; text-align: center; opacity: .85; }
.sim-compass::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ffd54a; }

.sim-map { position: absolute; right: 10px; top: 10px; width: 118px; height: 118px; border-radius: 50%; overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .7); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.sim-map canvas { width: 100%; height: 100%; display: block; }
@media (max-width: 560px) { .sim-map { width: 78px; height: 78px; } .sim-gauge b { font-size: 14px; } .sim-gauge { min-width: 52px; padding: 4px 6px; } .sim-compass { display: none; } }

.sim-banner { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(.9); opacity: 0; transition: opacity .25s, transform .25s;
  background: rgba(8, 16, 28, .78); border: 1px solid rgba(255, 255, 255, .2); border-radius: 14px; padding: 10px 18px; text-align: center;
  font-weight: 800; font-size: clamp(15px, 2.6vw, 24px); max-width: 80%; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.sim-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.sim-banner small { display: block; font-weight: 600; font-size: .62em; opacity: .9; margin-top: 3px; }
.sim-banner--good { border-color: #4ade80; } .sim-banner--bad { border-color: #fb7185; } .sim-banner--gold { border-color: #facc15; }

.sim-arrow { position: absolute; width: 0; height: 0; }
.sim-arrow__tip { position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; border: 3px solid #ffd54a; box-shadow: 0 0 10px rgba(255, 213, 74, .8); }
.sim-arrow.is-edge .sim-arrow__tip { border: none; border-radius: 0; width: 0; height: 0; left: -12px; top: -14px; box-shadow: none;
  border-left: 12px solid transparent; border-right: 12px solid transparent; border-bottom: 22px solid #ffd54a; filter: drop-shadow(0 0 6px rgba(0, 0, 0, .6)); }
.sim-arrow__lbl { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); white-space: nowrap; font: 800 12px system-ui, sans-serif;
  background: rgba(8, 16, 28, .7); padding: 2px 7px; border-radius: 6px; }

.sim-toolbar { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.sim-toolbar button, .sim-tbtn {
  background: rgba(8, 16, 28, .66); color: #fff; border: 1px solid rgba(255, 255, 255, .22); border-radius: 10px;
  font: 700 13px system-ui, sans-serif; padding: 7px 10px; cursor: pointer; min-height: 36px;
}
.sim-toolbar button:hover { background: rgba(30, 50, 80, .8); }
.sim-toolbar button:focus-visible, .sim-tbtn:focus-visible { outline: 3px solid #ffd54a; outline-offset: 1px; }

/* touch controls */
.sim-touch { display: none; }
.sim-touch.is-on { display: block; }
.sim-stick { position: absolute; left: 14px; bottom: 14px; width: 120px; height: 120px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), rgba(255, 255, 255, .05)); border: 2px solid rgba(255, 255, 255, .35); }
.sim-stick__knob { position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.sim-throttle { position: absolute; right: 16px; bottom: 60px; width: 44px; height: 130px; border-radius: 12px; pointer-events: auto; touch-action: none;
  background: rgba(8, 16, 28, .5); border: 2px solid rgba(255, 255, 255, .35); overflow: visible; }
.sim-throttle__fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 10px; background: linear-gradient(0deg, #22c55e, #facc15); opacity: .8; }
.sim-throttle__knob { position: absolute; left: -6px; right: -6px; bottom: -14px; height: 28px; border-radius: 8px; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.sim-throttle span { position: absolute; left: 0; right: 0; top: -18px; text-align: center; font: 800 11px system-ui, sans-serif; text-shadow: 0 1px 3px #000; }
.sim-tbtns { position: absolute; left: 150px; bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.sim-tbtns .sim-tbtn { pointer-events: auto; touch-action: none; min-width: 48px; min-height: 44px; }
@media (max-width: 560px) { .sim-stick { width: 96px; height: 96px; } .sim-tbtns { left: 118px; } .sim-throttle { height: 100px; bottom: 54px; } }

/* phone-sized stage: portrait stage, HUD as one top row, icon-only toolbar under it, bottom edge left to the touch controls */
@media (max-width: 560px) { .sim-stage, .sim-loading { aspect-ratio: 3 / 4; } }
.sim-timer { position: absolute; left: 50%; top: 44px; transform: translateX(-50%); font-weight: 800; min-width: 90px; }
@container (max-width: 480px) {
  .sim-hud { flex-direction: row; gap: 4px; left: 8px; top: 8px; }
  .sim-gauge { min-width: 50px; padding: 3px 5px; border-radius: 8px; }
  .sim-gauge b { font-size: 14px; }
  .sim-gauge small { font-size: 8px; letter-spacing: .04em; }
  .sim-has-touch .sim-hud > .sim-gauge:nth-child(4) { display: none; }
  .sim-map { top: 8px; right: 8px; }
  .sim-toolbar { top: 50px; left: 8px; right: 92px; bottom: auto; gap: 3px; flex-wrap: wrap; }   /* right: clears the minimap */
  .sim-toolbar button { width: 32px; min-height: 34px; padding: 5px 0 5px 7px; overflow: hidden; white-space: nowrap; text-align: left; font-size: 14px; }
  .sim-timer { top: 90px; }
  .sim-banner { top: 42%; max-width: 90%; }
}

.sim-controls-help { font-size: 13px; opacity: .85; line-height: 1.5; }
.sim-controls-help kbd { background: var(--color-bg-alt, #1c1f27); border: 1px solid var(--color-border, #333); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font: 700 12px ui-monospace, monospace; }

.sim-loading { aspect-ratio: 16 / 9; max-height: 76vh; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #2d6cad, #0b1622); color: #fff; font-weight: 800; }
.sim-loading__spin { font-size: 46px; animation: sim-fly 1.4s ease-in-out infinite; }
@keyframes sim-fly { 50% { transform: translateY(-8px) rotate(-6deg); } }
.sim-nogl { padding: 30px 20px; text-align: center; border-radius: 14px; background: var(--color-bg-alt, #1c1f27); }

/* result panel shown over the stage */
.sim-result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(4, 10, 20, .55); pointer-events: auto; }
.sim-result__card { background: rgba(14, 22, 36, .95); border: 1px solid rgba(255, 255, 255, .18); border-radius: 16px; padding: 18px 22px; text-align: center; max-width: 88%; }
.sim-result__card h3 { margin: 0 0 6px; font-size: 22px; }
.sim-result__stars { font-size: 30px; letter-spacing: 4px; margin: 4px 0 8px; }
.sim-result__card p { margin: 4px 0; opacity: .9; }
.sim-result__btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { .sim-banner { transition: none; } .sim-gauge.is-warn { animation: none; } }
