/* Phone controller page. The controls themselves are styled by touch.css (shared with the game). */
:root { --red: #d40000; --ink: #0d0d0f; --w: #f4f4f2; --dim: rgba(244,244,242,.55); --y: #f1c40f; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--ink); color: var(--w); touch-action: none; overscroll-behavior: none;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-user-select: none; user-select: none; }
body { background: radial-gradient(120% 90% at 50% 0%, #1b1c20 0%, #0d0d0f 60%); }
.hidden { display: none !important; }
.led { display: block; width: 8px; height: 8px; border-radius: 2px; background: #5b5d63; flex: none; }

/* ---- pairing ---- */
#pair { position: fixed; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
#pair .card { width: min(360px, 100%); padding: 20px 22px 22px; background: rgba(18,18,21,.94); border: 1px solid rgba(255,255,255,.16); border-radius: 6px; display: flex; flex-direction: column; gap: 12px; }
#pair .brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; letter-spacing: .08em; font-style: italic; margin-bottom: 6px; }
#pair .brand .mark { width: 8px; height: 22px; background: var(--red); transform: skewX(-14deg); }
#pair label { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
#code { width: 100%; height: 64px; text-align: center; text-transform: uppercase; font: 800 40px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .3em; text-indent: .3em; color: var(--w);
  background: #08080a; border: 1px solid rgba(255,255,255,.22); border-radius: 4px; outline: none; -webkit-user-select: text; user-select: text; }
#code:focus { border-color: var(--y); box-shadow: 0 0 0 2px rgba(241,196,15,.25); }
#code::placeholder { color: rgba(255,255,255,.18); }
#pairGo { height: 50px; border: 0; border-radius: 4px; background: var(--red); color: #fff; font: 800 15px/1 inherit; letter-spacing: .18em; text-transform: uppercase; cursor: pointer; }
#pairGo:disabled { background: #3a3a3e; color: var(--dim); }
#pairMsg { min-height: 16px; font-size: 13px; font-weight: 600; color: #ff7a6e; }
#pairMsg.ok { color: var(--dim); }
@media (orientation: landscape) and (max-height: 480px) {
  #pair .card { width: min(560px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; padding: 16px 20px; }
  #pair .brand { grid-column: 1 / 2; margin: 0; } #pair label { grid-column: 1 / 2; align-self: end; }
  #pair #code { grid-column: 2 / 3; grid-row: 1 / 3; height: 76px; align-self: center; }
  #pair #pairGo { grid-column: 2 / 3; } #pair #pairMsg { grid-column: 1 / 2; grid-row: 3; align-self: center; }
}

/* ---- telemetry (top centre) ---- */
#tele { position: fixed; z-index: 6; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 2px); transform: translateX(-50%); width: 292px; padding: 8px 12px 8px; background: rgba(13,13,15,.62); border: 1px solid rgba(255,255,255,.1); border-radius: 6px; pointer-events: none; font-variant-numeric: tabular-nums; }
.t-main { display: flex; align-items: baseline; gap: 8px; }
#tSpeed { font-size: 40px; font-weight: 800; font-style: italic; line-height: .9; letter-spacing: -.02em; min-width: 3ch; text-align: right; }
.t-main small { font-size: 11px; font-weight: 700; color: var(--dim); letter-spacing: .1em; text-transform: uppercase; }
#tGear { margin-left: auto; min-width: 34px; height: 34px; padding: 0 6px; display: grid; place-items: center; background: var(--w); color: var(--ink); font-weight: 900; font-size: 24px; font-style: italic; transform: skewX(-8deg); align-self: center; }
#tGear.p { background: transparent; color: var(--w); box-shadow: inset 0 0 0 2px var(--w); }
#tRpm { display: grid; grid-template-columns: repeat(30, 1fr); gap: 2px; height: 7px; margin: 7px 0 7px; transform: skewX(-14deg); }
#tRpm i { background: rgba(255,255,255,.14); } #tRpm i.on { background: var(--w); } #tRpm i.on.y { background: #ffc400; } #tRpm i.on.r { background: var(--red); }
.t-sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 16px; }
.t-fuel { display: flex; align-items: center; gap: 6px; flex: 1; color: var(--dim); }
.t-fuel svg { width: 14px; height: 14px; flex: none; }
.t-fuel i { display: block; flex: 1; height: 5px; background: rgba(255,255,255,.16); overflow: hidden; }
.t-fuel b { display: block; height: 100%; width: 100%; background: #e9ebee; transform-origin: left; transition: transform .25s; }
.t-fuel.low b { background: #ff5a4d; } .t-fuel.none { visibility: hidden; }
.t-stars { display: flex; gap: 2px; visibility: hidden; }
.t-stars.on { visibility: visible; }
.t-stars svg { width: 14px; height: 14px; fill: none; stroke: rgba(244,244,242,.4); stroke-width: 1.6; stroke-linejoin: round; }
.t-stars svg.on { fill: #ffc21a; stroke: #ffe28a; filter: drop-shadow(0 0 4px rgba(255,194,26,.7)); }
.t-stars.chase { animation: rb .5s steps(2) infinite; }
@keyframes rb { 0% { box-shadow: 0 2px 0 #e5252a; } 100% { box-shadow: 0 2px 0 #3b6dff; } }

/* ---- link status (top left) and tilt button ---- */
#link { position: fixed; z-index: 6; left: calc(max(14px, env(safe-area-inset-left)) + 2px); top: calc(max(14px, env(safe-area-inset-top)) + 2px); display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: rgba(13,13,15,.62); border-radius: 4px;
  font: 700 11px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: rgba(244,244,242,.85); pointer-events: none; font-variant-numeric: tabular-nums; }
#link.ok .led { background: #3ddc84; box-shadow: 0 0 6px rgba(61,220,132,.7); }
#link.warn .led { background: #ffc21a; box-shadow: 0 0 6px rgba(255,194,26,.7); }
#link.bad .led { background: #ff4a3d; box-shadow: 0 0 6px rgba(255,74,61,.8); animation: blink .7s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }
#tiltBtn { position: fixed; z-index: 7; left: calc(max(14px, env(safe-area-inset-left)) + 8px); top: calc(max(14px, env(safe-area-inset-top)) + 46px); }
#tiltBtn.on { color: #5fc6ff; } #tiltBtn.on .led { background: #31b6ff; box-shadow: 0 0 6px 1px rgba(49,182,255,.9); }
body.touch #gearBtn { position: fixed; z-index: 31; display: grid; place-items: center; border: 0; padding: 0; cursor: pointer; }
body.settings-open #gearBtn, body.settings-open #tiltBtn { visibility: hidden; }

/* ---- settings sheet ---- */
#menu { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(8,8,10,.7); padding: 12px; }
#menu .card { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 14px 16px 16px; background: rgba(18,18,21,.97); border: 1px solid rgba(255,255,255,.16); border-radius: 6px; }
.m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.m-head button, .m-grid > button { height: 40px; padding: 0 14px; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; background: #1d1e22; color: var(--w); font: 700 12px/1 inherit; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.m-grid > button:active, .m-head button:active { background: #2a2b30; }
.m-grid > button.warn { color: #ff7a6e; border-color: rgba(255,122,110,.4); }
.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.m-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 0 2px; font-size: 13px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.1); }
.m-row em { font-style: normal; color: var(--dim); margin-left: 6px; }
.m-row input[type=range] { width: 120px; accent-color: var(--y); touch-action: pan-x; }
.m-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--y); }
@media (orientation: portrait) { .m-grid { grid-template-columns: 1fr; } }

/* ---- connection lost ---- */
#down { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8,8,10,.62); }
#down .card { display: flex; align-items: center; gap: 12px; padding: 16px 22px; background: rgba(18,18,21,.96); border: 1px solid rgba(255,255,255,.18); border-radius: 6px; font: 700 14px/1 inherit; letter-spacing: .08em; text-transform: uppercase; }
#down .led { background: #ff4a3d; box-shadow: 0 0 6px rgba(255,74,61,.8); animation: blink .7s steps(2) infinite; }
