/* GRAVITY TRIAL — Upgraded 2000s Retro-Minimalism UI */
:root {
  --ink: #161b20;
  --ink-soft: #3b4652;
  --paper: #eef3f6;
  --card: #f8fafc;
  --lcd: #dce7ee;
  --red: #d92626;
  --red-dark: #a81a1a;
  --amber: #f59e0b;
  --green: #059669;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #181c22;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  touch-action: none;
}

.hidden { display: none !important; }
body:not(.embed) .embed-only { display: none !important; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ==================== HUD ==================== */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 10px calc(var(--safe-bot) + 12px);
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
}

.hud-left {
  background: rgba(248, 250, 252, 0.92);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 5px 9px;
  box-shadow: 0 3px 0 var(--ink);
  min-width: 118px;
  max-width: 44%;
}

.hud-track-name {
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-prog-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.hud-prog-track {
  flex: 1;
  height: 7px;
  background: #cbd5e1;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  overflow: hidden;
}

.hud-prog-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red), var(--amber));
}

.hud-prog-pct {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 900;
}

.hud-center {
  text-align: center;
}

.hud-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: #181c22;
  color: #f8fafc;
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 5px 10px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.hud-stunts {
  margin-top: 4px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  color: #b45309;
  background: #fef3c7;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 1px 6px;
  display: inline-block;
}

.hud-right {
  display: flex;
  gap: 6px;
}

.hud-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: rgba(248, 250, 252, 0.94);
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.hud-icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.hud-hint {
  align-self: center;
  background: rgba(22, 27, 32, 0.86);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  transition: opacity 0.4s ease;
}

.hud-hint.faded {
  opacity: 0;
}

/* Tactile 2000s Touch Pedals */
.controls-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: auto;
  padding-bottom: 4px;
}

.ctrl-group {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 74px;
  height: 68px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: rgba(248, 250, 252, 0.9);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
}

.ctrl-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
  background: #e2e8f0;
}

.ctrl-brake {
  background: rgba(254, 226, 226, 0.94);
  border-color: #7f1d1d;
}

.ctrl-brake.pressed {
  background: #fecaca;
}

.ctrl-gas {
  width: 82px;
  background: linear-gradient(180deg, #ef4444, #c81d25);
  color: #fff;
}

.ctrl-gas.pressed {
  background: #991b1b;
}

.ctrl-arrow {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.ctrl-lbl {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

/* ==================== LOBBY ==================== */
.lobby {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(219, 231, 240, 0.72) 0%, rgba(238, 243, 246, 0.96) 36%, rgba(238, 243, 246, 0.99) 100%);
  padding: calc(var(--safe-top) + 10px) 12px calc(var(--safe-bot) + 12px);
  overflow-y: auto;
}

.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar-chips {
  display: flex;
  gap: 6px;
}

.retro-chip {
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  font-weight: 900;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 5px 10px;
  box-shadow: 0 2px 0 var(--ink);
}

.chip-stars {
  color: #b45309;
  background: #fef3c7;
}

.topbar-btns {
  display: flex;
  gap: 6px;
}

.top-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 2px solid var(--ink);
  background: #181c22;
  color: #f8fafc;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.lobby-hero {
  text-align: center;
  margin: 12px 0 10px;
}

.brand-sub {
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--red);
}

.brand-title {
  margin: 2px 0 0;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--ink);
  text-shadow: 0 2px 0 #fff;
}

.brand-title span {
  color: var(--red);
}

.boost-banner {
  margin-top: 6px;
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  padding: 3px 10px;
}

.daily-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  text-align: left;
}

.daily-strip:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.daily-strip-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
}

.daily-strip-sub {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #78350f;
}

.daily-strip-week {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 800;
  color: #78350f;
  letter-spacing: 1px;
  white-space: nowrap;
}

.daily-strip-week:empty { display: none; }

.daily-strip-go {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
}

.lobby-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.lobby-tab {
  padding: 9px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: var(--lcd);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.lobby-tab.active {
  background: #181c22;
  color: #f8fafc;
  box-shadow: 0 2px 0 var(--red);
}

.tier-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.tier-pill {
  padding: 7px 6px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 900;
  cursor: pointer;
}

.tier-pill.active {
  background: var(--red);
  color: #fff;
}

.tracks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.track-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 10px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  text-align: left;
  cursor: pointer;
}

.track-card:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.track-card.locked {
  opacity: 0.56;
  cursor: not-allowed;
}

.track-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.track-num {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 900;
  background: #181c22;
  color: #f8fafc;
  padding: 2px 6px;
  border-radius: 5px;
}

.track-stars {
  font-size: 13px;
  color: #d97706;
  letter-spacing: 1px;
}

.track-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
}

.track-meta {
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* Garage */
.garage-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bike-card {
  padding: 11px 12px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
}

.bike-card.equipped {
  border-color: var(--red);
  background: #fffbeb;
}

.bike-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bike-name {
  font-size: 14.5px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bike-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: inline-block;
}

.bike-desc {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: 3px 0 8px;
}

.bike-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 9px;
}

.bike-stat small {
  display: block;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.bike-bar {
  height: 6px;
  background: #cbd5e1;
  border: 1px solid var(--ink);
  border-radius: 99px;
  overflow: hidden;
}

.bike-bar > div {
  height: 100%;
  background: var(--ink);
}

.bike-actions {
  display: flex;
  gap: 7px;
}

/* ==================== MODALS & BUTTONS ==================== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(16, 20, 26, 0.68);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 0 var(--ink);
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: center;
}

.modal-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.modal-title.danger { color: var(--red); }
.modal-title.success { color: var(--green); }

.modal-sub {
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.finish-stars {
  font-size: 28px;
  color: #d97706;
  letter-spacing: 6px;
  line-height: 1;
}

/* Medal / streak of the daily track and the gap to the next star or medal; hidden when empty */
.finish-goal {
  align-self: center;
  font-size: 12.5px;
  font-weight: 900;
  color: var(--ink);
  background: #fef3c7;
  border: 1.5px dashed var(--ink);
  border-radius: 99px;
  padding: 3px 12px;
}

.finish-goal.medal {
  background: #fde68a;
  border-style: solid;
}

.finish-goal:empty { display: none; }

.record-tag {
  align-self: center;
  font-size: 11px;
  font-weight: 900;
  background: var(--red);
  color: #fff;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.stat-box {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 9px;
  padding: 7px 6px;
}

.stat-box small {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-soft);
}

.stat-box b {
  font-family: ui-monospace, monospace;
  font-size: 15px;
  font-weight: 900;
}

.subradar-pill {
  align-self: center;
  font-size: 11px;
  font-weight: 900;
  background: #181c22;
  color: #fcd34d;
  border: 1.5px solid var(--amber);
  border-radius: 99px;
  padding: 4px 12px;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-retro {
  padding: 11px 12px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}

.btn-retro:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-retro:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-red {
  background: linear-gradient(180deg, #ef4444, #c81d25);
  color: #fff;
}

.btn-amber {
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: var(--ink);
}

.btn-light {
  background: var(--card);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
}

.full-w { width: 100%; }

.toast {
  position: absolute;
  bottom: calc(var(--safe-bot) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: #181c22;
  color: #f8fafc;
  border: 2px solid var(--amber);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 390px) {
  .ctrl-btn { width: 66px; height: 64px; }
  .ctrl-gas { width: 74px; }
}

/* ==================== SPRITES ====================
   html.gt-spr-ui is set by src/renderer.js once ./assets/sprites/ui.webp is loaded;
   without it the old glyphs stay. ui.webp = one row of 96 px icons:
   0 gas, 1 brake, 2 lean back, 3 lean forward, 4 restart, 5 pause, 6 star, 7 empty star, 8 coin, 9 ad. */
.gt-spr-ui .ctrl-arrow,
.gt-spr-ui .hud-icon-btn {
  background-image: url(./assets/sprites/ui.webp);
  background-repeat: no-repeat;
}

.gt-spr-ui .ctrl-arrow {
  font-size: 0;
  width: 34px;
  height: 34px;
  background-size: 340px 34px;
}

.gt-spr-ui .ctrl-btn[data-ctrl='gas'] .ctrl-arrow { background-position: 0 0; }
.gt-spr-ui .ctrl-btn[data-ctrl='brake'] .ctrl-arrow { background-position: -34px 0; }
.gt-spr-ui .ctrl-btn[data-ctrl='leanBack'] .ctrl-arrow { background-position: -68px 0; }
.gt-spr-ui .ctrl-btn[data-ctrl='leanFwd'] .ctrl-arrow { background-position: -102px 0; }

/* HUD restart / pause: the sprite is the whole button */
.gt-spr-ui .hud-icon-btn {
  font-size: 0;
  border: 0;
  background-color: transparent;
  background-size: 400px 40px;
  width: 40px;
  height: 40px;
  box-shadow: 0 3px 0 rgba(22, 27, 30, 0.35);
}

.gt-spr-ui #btn-hud-restart { background-position: -160px 0; }
.gt-spr-ui #btn-hud-pause { background-position: -200px 0; }

/* Stars (track cards, finish): glyph by default, sprite with the sheet loaded */
.gt-star {
  font-style: normal;
}

.gt-spr-ui .gt-star {
  display: inline-block;
  width: 1em;
  height: 1em;
  font-size: inherit;
  color: transparent;
  vertical-align: -0.12em;
  background-image: url(./assets/sprites/ui.webp);
  background-size: 10em 1em;
  background-position: -6em 0;
}

.gt-spr-ui .gt-star.off { background-position: -7em 0; }
.gt-spr-ui .finish-stars { letter-spacing: 4px; }
.gt-spr-ui .finish-stars .gt-star { width: 1.15em; height: 1.15em; background-size: 11.5em 1.15em; background-position: -6.9em 0; }
.gt-spr-ui .finish-stars .gt-star.off { background-position: -8.05em 0; }

/* Coin chip in the lobby: the 🪙 text node is hidden, the coin sprite goes before the number */
.gt-spr-ui .topbar-chips .retro-chip:not(.chip-stars) {
  font-size: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gt-spr-ui .topbar-chips .retro-chip:not(.chip-stars)::before {
  content: '';
  width: 17px;
  height: 17px;
  background: url(./assets/sprites/ui.webp) no-repeat -136px 0 / 170px 17px;
}

.gt-spr-ui .topbar-chips .retro-chip:not(.chip-stars) b {
  font-size: 12.5px;
}

/* Garage: bike drawn from the sprites instead of the colour dot */
.bike-art {
  display: block;
  flex: none;
}
