/* BOOST — Turbocharged Arcade Racing
   All in-game UI is drawn on the canvas; this file handles page layout,
   the loading screen and the mobile touch controls. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  font-family: "Courier New", monospace;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-wrap {
  position: fixed;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- Loading screen ---------- */
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(#131a3d 0%, #3d1440 60%, #7a2020 100%);
  z-index: 30;
  transition: opacity .4s ease;
}
#loading.done { opacity: 0; pointer-events: none; }

.load-title {
  font-size: clamp(48px, 12vw, 110px);
  font-weight: 900;
  letter-spacing: .12em;
  color: #ffe74a;
  text-shadow: 0 4px 0 #d8341f, 0 8px 0 #5a0d2b, 0 10px 22px rgba(0,0,0,.6);
  font-style: italic;
}

.load-bar {
  width: min(420px, 70vw);
  height: 14px;
  border: 2px solid #ffe74a;
  background: rgba(0,0,0,.45);
  box-shadow: 0 0 12px rgba(255,231,74,.35);
}
#load-fill {
  width: 0%;
  height: 100%;
  background: repeating-linear-gradient(45deg, #ffe74a 0 10px, #ff9d2e 10px 20px);
  transition: width .15s linear;
}
.load-msg { color: #ffd9b8; font-size: 14px; letter-spacing: .15em; }

/* ---------- Touch controls ---------- */
#touch-ui {
  position: absolute;
  inset: 0;
  display: none;              /* enabled by JS when a touch device is detected */
  pointer-events: none;
  z-index: 20;
}
#touch-ui.active { display: block; }

.tc-cluster {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  align-items: flex-end;
  pointer-events: none;
}
.tc-left  { left: max(16px, env(safe-area-inset-left)); }
.tc-right { right: max(16px, env(safe-area-inset-right)); }

.tc-btn {
  pointer-events: auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.75);
  background: rgba(10, 14, 40, .45);
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
}
.tc-btn:active, .tc-btn.held {
  background: rgba(255, 231, 74, .85);
  color: #201000;
  border-color: #fff;
}
.tc-small { width: 60px; height: 60px; font-size: 13px; }
.tc-boost {
  width: 86px; height: 86px;
  font-size: 15px;
  border-color: #ff9d2e;
  color: #ffce6b;
  box-shadow: 0 0 16px rgba(255,140,30,.35);
}
.tc-boost:active, .tc-boost.held {
  background: rgba(255, 120, 20, .9);
  color: #fff;
}

@media (max-width: 640px) {
  .tc-btn { width: 62px; height: 62px; font-size: 18px; }
  .tc-boost { width: 72px; height: 72px; font-size: 12px; }
  .tc-small { width: 50px; height: 50px; font-size: 11px; }
}


/* ============================================================================
   GARAGE — car editor overlay
   ========================================================================== */
#garage {
  position: fixed; inset: 0; z-index: 40;
  display: none;
  background: rgba(6, 8, 14, 0.86);
  backdrop-filter: blur(3px);
  font-family: "Courier New", monospace;
  color: #e8ecf6;
}
#garage.show { display: block; }

.g-panel {
  position: absolute; inset: 3vh 3vw;
  background: #12141b;
  border: 2px solid #ff8c2e;
  box-shadow: 0 0 0 1px #000, 0 24px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.g-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 2px solid #2a2f3a;
  background: linear-gradient(180deg, #1b1f28, #14171e);
}
.g-head h2 {
  margin: 0; font-size: 22px; letter-spacing: 3px;
  color: #ffe74a; font-style: italic;
}
.g-actions { display: flex; gap: 8px; flex-wrap: wrap; }

#garage button {
  font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  padding: 7px 12px; cursor: pointer;
  color: #12141a; background: #ff8c2e;
  border: none; border-bottom: 3px solid #b35c12;
}
#garage button:hover { background: #ffb15e; }
#garage button:active { transform: translateY(1px); border-bottom-width: 2px; }
#garage button.danger { background: #e2262a; color: #fff; border-bottom-color: #7d1416; }

.g-body { flex: 1; display: flex; min-height: 0; }
.g-list {
  width: 320px; flex: none; overflow-y: auto;
  border-right: 2px solid #2a2f3a; padding: 10px;
}
.g-edit { flex: 1; overflow-y: auto; padding: 14px 18px; }

.g-car {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 8px;
  background: #191d26; border: 1px solid #2a2f3a;
}
.g-car.sel { border-color: #ffe74a; background: #1e2330; }
.g-swatch { width: 26px; height: 26px; flex: none; border: 1px solid #000; }
.g-info { flex: 1; display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.g-info strong { font-size: 13px; color: #ffe74a; letter-spacing: 1px; }
.g-info span { font-size: 11px; color: #9aa3b4; }
.g-btns { display: flex; gap: 4px; flex: none; }
.g-btns button { padding: 5px 8px; font-size: 10px; }

.g-edit h3 { margin: 0 0 4px; color: #ffe74a; font-size: 16px; letter-spacing: 2px; }
.g-edit h3 em { font-size: 11px; color: #7f8798; font-style: normal; letter-spacing: 0; }
.g-edit h4 {
  margin: 18px 0 8px; color: #ff8c2e; font-size: 12px;
  letter-spacing: 2px; text-transform: uppercase;
  border-bottom: 1px solid #2a2f3a; padding-bottom: 4px;
}

.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.g-grid.off { opacity: .35; pointer-events: none; }
.g-gears { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }

.g-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.g-field span { color: #9aa3b4; letter-spacing: 1px; }
.g-field em { color: #6d7484; font-size: 10px; font-style: normal; }
.g-field.small { width: 66px; }
.g-field input[type="number"], .g-field input[type="text"] {
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 5px 7px; color: #ffb15e;
  background: #0c0e14; border: 1px solid #333a48;
}
.g-field input:focus { outline: none; border-color: #ff8c2e; }
.g-field input[type="range"] { accent-color: #ff8c2e; }
.g-inline { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9aa3b4; }

.g-sheet { display: flex; gap: 16px; flex-wrap: wrap; }
.g-preview {
  background: repeating-conic-gradient(#20242e 0 25%, #171a22 0 50%) 0 0 / 16px 16px;
  border: 1px solid #333a48; padding: 4px; height: fit-content;
}
.g-sheet-ctrl { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.g-sheet-ctrl p { margin: 0; font-size: 11px; color: #9aa3b4; }
.g-sheet-ctrl code { color: #ffb15e; }
.g-note { color: #6d7484 !important; line-height: 1.5; }

.g-foot {
  margin-top: 20px; padding-top: 12px; border-top: 1px solid #2a2f3a;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.g-perf { font-size: 12px; color: #5aff7a; letter-spacing: 1px; }

@media (max-width: 720px) {
  .g-body { flex-direction: column; }
  .g-list { width: auto; max-height: 34%; border-right: none; border-bottom: 2px solid #2a2f3a; }
}

.g-field select {
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 5px 7px; color: #ffb15e;
  background: #0c0e14; border: 1px solid #333a48;
}

.g-credits { float: right; color: #ffe74a; font-size: 11px; letter-spacing: 1px; }
.g-credits b { color: #fff; }

/* ============================================================================
   BOOST SPRITE STUDIO — integrated Garage production tool
   ========================================================================== */
.sg-modal { position: absolute; inset: 0; z-index: 10; display: none; background: rgba(4,6,11,.96); color: #edf1f8; }
.sg-modal.show { display: block; }
.sg-panel { position: absolute; inset: 2vh 2vw; display: flex; flex-direction: column; overflow: hidden; background: #10141c; border: 2px solid #ff9c2c; box-shadow: 0 25px 80px #000; }
.sg-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 15px; border-bottom: 1px solid #303747; background: linear-gradient(#1c222d,#131821); }
.sg-head span { display: block; color: #ff9c2c; font-size: 9px; letter-spacing: 2px; }
.sg-head h2 { margin: 2px 0 0; color: #ffe74a; font-size: 19px; letter-spacing: 3px; font-style: italic; }
.sg-head-actions { display: flex; gap: 7px; }
.sg-modal button { font-family: inherit; cursor: pointer; border: 0; border-bottom: 3px solid #a95812; background: #ff9427; color: #11151c; font-size: 11px; font-weight: 900; letter-spacing: .5px; padding: 7px 11px; text-transform: uppercase; }
.sg-modal button:hover { background: #ffb35e; }
.sg-modal button:disabled { opacity: .35; cursor: not-allowed; }
.sg-modal button.sg-muted { background: #2a303c; color: #e7ebf3; border-bottom-color: #151922; }
.sg-tabs { display: flex; gap: 4px; padding: 7px 10px; background: #0c1017; border-bottom: 1px solid #292f3b; }
.sg-tabs button { background: #202631; color: #aeb7c8; border-bottom-color: #10141b; }
.sg-tabs button.active { background: #ffe74a; color: #19150a; border-bottom-color: #b68e0b; }
.sg-content { min-height: 0; flex: 1; overflow: hidden; }
.sg-tab { display: none; height: 100%; overflow-y: auto; padding: 14px; }
.sg-tab.active { display: block; }
.sg-cols { display: grid; grid-template-columns: minmax(300px,.8fr) minmax(500px,1.25fr); gap: 13px; }
.sg-import-cols, .sg-frame-cols, .sg-preview-cols { grid-template-columns: minmax(520px,1fr) 300px; }
.sg-card { min-width: 0; padding: 13px; background: #161b24; border: 1px solid #303747; }
.sg-card h3 { margin: 0 0 10px; color: #ffe74a; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; }
.sg-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sg-title-row h3 { margin: 0; color: #ffe74a; font-size: 14px; letter-spacing: 1.5px; }
.sg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.sg-modal label { display: flex; flex-direction: column; gap: 4px; color: #9da8ba; font-size: 10px; letter-spacing: .5px; }
.sg-modal input[type="text"], .sg-modal textarea { width: 100%; font-family: inherit; color: #ffbd6f; background: #090d13; border: 1px solid #343c4a; padding: 7px; }
.sg-modal input[type="range"] { width: 100%; accent-color: #ff9427; }
.sg-prompt-card { display: flex; flex-direction: column; }
#sg-prompt { flex: 1; min-height: 440px; resize: vertical; color: #e7ebf3; line-height: 1.45; font-size: 11px; }
.sg-help { margin: 7px 0 0; color: #828c9d; font-size: 10px; line-height: 1.5; }
.sg-warning { margin: 10px 0 0; padding: 9px 10px; color: #f5e8d1; background: rgba(255,148,39,.08); border-left: 3px solid #ff9427; font-size: 10px; line-height: 1.5; }
.sg-ref-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-top: 9px; }
.sg-ref { position: relative; padding: 0 !important; border: 1px solid #3b4452 !important; background: #080c12 !important; aspect-ratio: 1.3; overflow: hidden; }
.sg-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-ref span { position: absolute; right: 3px; top: 1px; color: #fff; background: #d5262e; padding: 1px 4px; }
.sg-drop { margin-bottom: 11px; padding: 18px; text-align: center; border: 1px dashed #566175; background: #0c1016; color: #aab3c3; cursor: pointer; }
.sg-drop.drag { border-color: #ffe74a; color: #ffe74a; background: rgba(255,231,74,.06); }
.sg-checker { display: grid; place-items: center; overflow: hidden; border: 1px solid #343c49; background-color: #e7e7e7; background-image: linear-gradient(45deg,#cfcfcf 25%,transparent 25%),linear-gradient(-45deg,#cfcfcf 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#cfcfcf 75%),linear-gradient(-45deg,transparent 75%,#cfcfcf 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; }
.sg-checker canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.sg-editor-canvas { min-height: 520px; }
.sg-canvas-title { min-height: 27px; display: flex; align-items: center; justify-content: space-between; color: #9da8ba; font-size: 10px; }
.sg-controls { display: flex; flex-direction: column; gap: 10px; }
.sg-controls label output { float: right; color: #fff; }
.sg-check { flex-direction: row !important; align-items: center; gap: 7px !important; }
.sg-check input { width: auto !important; }
.sg-label { color: #9da8ba; font-size: 10px; }
.sg-swatches { display: flex; flex-wrap: wrap; gap: 5px; min-height: 28px; margin-top: 5px; }
.sg-swatches button { width: 25px; height: 25px; padding: 0; border: 2px solid #fff; }
.sg-swatches i { color: #747e8f; font-size: 9px; }
.sg-status { padding: 9px; color: #a8b0bf; background: #090d13; border: 1px solid #303744; font-size: 10px; line-height: 1.4; }
.sg-status.good { color: #5aff8a; border-color: #256c3d; }
.sg-status.bad { color: #ff6b72; border-color: #7f272c; }
.sg-frame-strip { display: grid; grid-template-columns: repeat(7,minmax(85px,1fr)); gap: 6px; margin-bottom: 10px; }
.sg-frame-strip button { padding: 4px; background: #0b1017; border: 1px solid #313846; color: #909bac; }
.sg-frame-strip button.active { border-color: #ffe74a; color: #ffe74a; box-shadow: 0 0 0 1px #ffe74a inset; }
.sg-frame-strip canvas { width: 100%; height: 120px; object-fit: contain; image-rendering: pixelated; }
.sg-frame-strip span { display: block; font-size: 8px; }
.sg-button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#sg-preview { width: 100%; max-height: 62vh; background: #0b0e15; border: 1px solid #343c49; image-rendering: pixelated; }
.sg-spec { display: flex; justify-content: space-between; padding: 7px; background: #0b1017; border: 1px solid #2d3441; color: #919bad; font-size: 10px; }
.sg-spec b { color: #fff; }
.g-sprite-studio-button { background: #ffe74a !important; border-bottom-color: #aa8508 !important; }
@media (max-width: 900px) { .sg-panel { inset: 1vh 1vw; } .sg-cols, .sg-import-cols, .sg-frame-cols, .sg-preview-cols { grid-template-columns: 1fr; } .sg-content { overflow-y: auto; } .sg-tab { height: auto; } }
