/* Layout: cena 3D em tela cheia; HUD de cabine nos cantos; tela inicial como cartão de briefing de voo */
:root {
  --ink: #0e1a22;
  --panel: rgba(9, 22, 30, 0.64);
  --line: rgba(190, 230, 255, 0.22);
  --text: #eaf4f8;
  --muted: #a3b9c4;
  --hud: #7ff0c4;
  --warn: #ffb43a;
  --danger: #ff5a4e;
  --accent: #ffcf5c;
  --f-display: "Chakra Petch", ui-monospace, "Segoe UI", sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--f-body); overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { position: fixed; inset: 0; }
button, label { touch-action: manipulation; }
html:not(.touch) .touch-only { display: none !important; }
html.touch .key-only { display: none !important; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.lbl { font-family: var(--f-display); font-size: 11px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
b { font-family: var(--f-display); font-weight: 600; font-variant-numeric: tabular-nums; }

#hud { position: fixed; inset: 0; pointer-events: none; }
.panel { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.readouts { left: calc(16px + env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding: 12px 16px; display: grid; gap: 8px; min-width: 150px; }
.readout { display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 6px; }
.readout .lbl { grid-column: 1 / -1; }
.readout b { font-size: 30px; color: var(--hud); line-height: 1.05; }
.readout.small b { font-size: 20px; }
.unit { font-size: 12px; color: var(--muted); }
.throttle { left: calc(190px + env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding: 12px 12px; display: grid; justify-items: center; gap: 8px; }
.bar { width: 16px; height: 120px; border-radius: 8px; background: rgba(255,255,255,0.08); border: 1px solid var(--line); position: relative; overflow: hidden; }
.bar i { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(to top, var(--hud), var(--accent)); }
.throttle b { font-size: 14px; color: var(--text); }
.heading { top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); padding: 6px 16px; display: flex; gap: 10px; align-items: baseline; }
.heading b { font-size: 20px; color: var(--hud); }
#adi { position: absolute; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 140px; height: 140px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); }
.hint { position: absolute; top: calc(64px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); text-align: center; font-size: 16px; padding: 8px 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); transition: opacity .4s; }
.hint:empty { opacity: 0; }
.hint kbd, .card kbd { font-family: var(--f-display); font-size: 12px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255,255,255,0.08); color: var(--text); }
.warn { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-family: var(--f-display); font-weight: 700; font-size: 34px; letter-spacing: 0.2em; color: var(--danger); text-shadow: 0 2px 12px rgba(0,0,0,.5); animation: blink 0.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.keys-mini { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); padding: 8px 12px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.keys-mini span { color: var(--text); font-family: var(--f-display); }

.overlay { position: fixed; inset: 0; display: flex; padding: 16px; padding-top: max(16px, env(safe-area-inset-top, 0px)); padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: linear-gradient(180deg, rgba(8,20,28,0.15), rgba(8,20,28,0.65)); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.overlay > .card { margin: auto; }
.card { width: min(520px, 100%); background: rgba(9, 22, 30, 0.82); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 16px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.card h1 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: clamp(36px, 8vw, 54px); letter-spacing: 0.04em; line-height: 1; text-wrap: balance; }
.card h1 em { font-style: normal; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.5; }
.callsign { font-family: var(--f-display); font-size: 12px; letter-spacing: 0.18em; color: var(--hud); }
.controls { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; align-items: center; }
.controls dt { white-space: nowrap; }
.controls dd { margin: 0; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.btn { pointer-events: auto; font-family: var(--f-display); font-weight: 700; font-size: 18px; letter-spacing: 0.12em; padding: 12px 28px; border-radius: 10px; border: 0; background: var(--accent); color: #1c1606; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible, .chk input:focus-visible { outline: 3px solid var(--hud); outline-offset: 3px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--hud); }

.start { display: flex; justify-content: flex-start; align-items: center; padding-left: max(4vw, 16px);
  background: linear-gradient(90deg, rgba(8,20,28,0.82) 0%, rgba(8,20,28,0.4) 48%, rgba(8,20,28,0) 72%), linear-gradient(0deg, rgba(8,20,28,0.5), rgba(8,20,28,0) 35%); }
.start .card { flex: 0 1 520px; margin: auto 0; }
.picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pick { font: inherit; text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.pick span { font-family: var(--f-display); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.pick small { font-size: 11px; color: var(--muted); }
.pick:hover { background: rgba(255,255,255,0.1); }
.pick:focus-visible { outline: 3px solid var(--hud); outline-offset: 2px; }
.pick[aria-pressed="true"] { border-color: var(--accent); background: rgba(255,207,92,0.16); }
.showcase { right: max(4vw, 16px); bottom: 7vh; width: min(340px, 30vw); padding: 18px; display: grid; gap: 10px; }
.showcase h2 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: clamp(32px, 4vw, 54px); letter-spacing: 0.08em; text-transform: uppercase; line-height: 1; color: var(--accent); }
.showcase p { margin: 0; font-size: 15px; line-height: 1.45; }
.stats { display: grid; gap: 8px; margin-top: 4px; }
.stat { display: grid; grid-template-columns: 82px 1fr 74px; gap: 10px; align-items: center; }
.track { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.18); overflow: hidden; display: block; }
.track i { display: block; height: 100%; width: 0; background: var(--hud); transition: width .4s; }
.stat b { font-size: 13px; text-align: right; }
.btn.alt { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.alt:hover { background: rgba(255,255,255,0.08); }
.btn.small { font-size: 13px; padding: 8px 14px; letter-spacing: 0.06em; }
.menu .btn:not(.small) { width: 100%; }
.menu .row { flex-wrap: nowrap; }
@media (max-width: 860px) { .showcase { display: none; } .start { justify-content: center; padding-left: 16px; } .start .card { margin: auto auto 0; } }
@media (max-width: 480px) { .picks { grid-template-columns: repeat(2, 1fr); } }
#crash h1 { color: var(--danger); font-size: 40px; }

@media (max-width: 600px) {
  .keys-mini { display: none; }
  .readout b { font-size: 22px; }
  .readout.small b { font-size: 16px; }
  .readouts { min-width: 120px; padding: 10px 12px; }
  .throttle { left: calc(150px + env(safe-area-inset-left, 0px)); }
  .bar { height: 90px; }
  #adi { width: 100px; height: 100px; }
}
@media (prefers-reduced-motion: reduce) { .warn { animation: none; } }

/* ---------- Controles de toque ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#joyZone { position: absolute; left: 0; top: 18%; bottom: 0; width: 46%; pointer-events: auto; touch-action: none; }
#joy { position: absolute; left: calc(28px + env(safe-area-inset-left, 0px)); bottom: calc(28px + env(safe-area-inset-bottom, 0px)); width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(9,22,30,0.2) 30%, rgba(9,22,30,0.5)); border: 1px solid var(--line); opacity: 0.7; transition: opacity .15s; }
#joy.on { opacity: 1; transition: none; }
#joy::before, #joy::after { content: ""; position: absolute; background: var(--line); }
#joy::before { left: 50%; top: 14px; bottom: 14px; width: 1px; }
#joy::after { top: 50%; left: 14px; right: 14px; height: 1px; }
#knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(127,240,196,0.45); border: 2px solid var(--hud); z-index: 1; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.tbtn { pointer-events: auto; min-width: 56px; height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(9,22,30,0.62); color: var(--text);
  font-family: var(--f-display); font-weight: 700; font-size: 14px; letter-spacing: 0.08em; touch-action: none; user-select: none; -webkit-user-select: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tbtn.on, .tbtn:active { background: rgba(127,240,196,0.35); border-color: var(--hud); }
.tops { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); display: flex; gap: 8px; }
.tbtn.icon { min-width: 48px; padding: 0 10px; }
#tBrake { position: absolute; right: calc(112px + env(safe-area-inset-right, 0px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); height: 64px; min-width: 84px; }
#lever { position: absolute; right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); width: 76px; padding: 8px 0 12px; display: grid; justify-items: center; gap: 6px;
  pointer-events: auto; touch-action: none; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.ltrack { position: relative; width: 22px; height: 170px; border-radius: 11px; background: rgba(255,255,255,0.08); border: 1px solid var(--line); margin: 14px 0; }
#lfill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 11px; background: linear-gradient(to top, var(--hud), var(--accent)); }
#lgrip { position: absolute; left: 50%; bottom: 0; width: 62px; height: 30px; margin: 0 0 -15px -31px; border-radius: 8px; background: #23343f; border: 2px solid var(--accent); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
#lgrip b { font-size: 13px; color: var(--text); }
#lever.on #lgrip { background: #34505f; }

/* HUD em aparelhos de toque: instrumentos no alto, mãos livres embaixo */
html.touch .keys-mini, html.touch .throttle { display: none; }
html.touch .readouts { top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); bottom: auto; display: flex; gap: 14px; min-width: 0; padding: 8px 12px; }
html.touch .readout { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 4px; }
html.touch .readout .lbl { flex-basis: 100%; font-size: 10px; }
html.touch .readout b { font-size: 22px; }
html.touch .readout.small b { font-size: 16px; }
html.touch .heading { top: calc(12px + env(safe-area-inset-top, 0px)); }
html.touch .hint { top: calc(84px + env(safe-area-inset-top, 0px)); font-size: 14px; max-width: min(440px, calc(100% - 290px)); }
html.touch #adi { top: calc(70px + env(safe-area-inset-top, 0px)); bottom: auto; right: calc(12px + env(safe-area-inset-right, 0px)); width: 96px; height: 96px; }
html.touch .warn { top: 32%; }
html.touch .btn { min-height: 48px; }
html.touch .chk input { width: 22px; height: 22px; }
html.touch .pick { min-height: 48px; }

/* Celular deitado (pouca altura) */
@media (max-height: 520px) {
  .card { padding: 14px 18px; gap: 10px; }
  .card h1 { font-size: 34px; }
  .card p { font-size: 14px; line-height: 1.4; }
  .controls { font-size: 13px; gap: 4px 12px; }
  .start .card { flex-basis: min(460px, 58vw); }
  .start .card > p { display: none; }
  .menu .btn:not(.small) { padding: 10px 20px; font-size: 15px; }
  #crash h1 { font-size: 30px; }
  .card.menu { width: min(640px, 100%); grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .card.menu > :not(.btn) { grid-column: 1 / -1; }
  .card.menu h1 { font-size: 28px; }
  .picks { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .pick { padding: 6px 8px; }
  .pick span { font-size: 12px; }
  html.touch .start .controls { display: none !important; }
  .ltrack { height: 130px; margin: 10px 0; }
  #joy { width: 124px; height: 124px; }
  html.touch .readout b { font-size: 19px; }
  html.touch #adi { width: 84px; height: 84px; top: calc(66px + env(safe-area-inset-top, 0px)); }
  html.touch .hint { font-size: 13px; padding: 6px 10px; top: calc(76px + env(safe-area-inset-top, 0px)); }
}
@media (max-height: 520px) and (min-width: 561px) and (orientation: landscape) {
  .start { justify-content: flex-start; padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .start .card { margin: auto 0; }
}
@media (max-height: 380px) { #joyZone { top: 22%; } .ltrack { height: 110px; } }
@media (max-width: 700px) and (orientation: landscape) { html.touch .readouts { gap: 10px; } html.touch .readout .unit { display: none; } }
@media (max-width: 760px) { html.touch .heading { display: none; } }

/* Aviso de girar o celular */
#rotate { z-index: 20; background: rgba(8,20,28,0.94); }
.rot { text-align: center; justify-items: center; width: min(360px, 100%); }
.phone { width: 54px; height: 92px; border: 3px solid var(--accent); border-radius: 12px; animation: turn 2.4s ease-in-out infinite; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .phone { animation: none; transform: rotate(-90deg); } }
