:root {
  color-scheme: dark;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: #020617;
  color: #f8fafc;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #020617; }
/* No double-tap zoom anywhere: it has no use in the game and is hard to undo on a tablet. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button { font: inherit; }

.shell {
  width: min(100%, 650px);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1;
}


.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.toolbar button {
  border: 1px solid #475569;
  border-radius: 12px;
  background: #1e293b;
  color: #f8fafc;
  padding: 8px 10px;
  cursor: pointer;
}

.toolbar button:first-child {
  background: #34d399;
  color: #052e2b;
  border-color: #6ee7b7;
  font-weight: 800;
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 1180;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 26px;
  background: #000;
  box-shadow: 0 16px 60px rgb(0 0 0 / 45%);
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.touch-controls { display: none; }
.mobile-menu, .play-action, .quick-pause, .hud { display: none; }

@media (max-width: 520px) {
  .shell { padding: 8px; }
  .topbar { align-items: flex-start; }
  .toolbar button { padding: 7px 8px; font-size: 12px; }
}

[hidden] { display: none !important; }
.app-notice { color: #94a3b8; font-size: 11px; line-height: 1.4; margin-top: 8px; }
.app-notice p { margin: 0 0 3px; }
.touch-help { display: none; }
#updateButton, dialog button { font: inherit; color: #f8fafc; background: #1e293b; border: 1px solid #64748b; border-radius: 8px; padding: 6px 9px; }
dialog { max-width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); border: 1px solid #64748b; border-radius: 16px; background: #0f172a; color: #f8fafc; padding: 22px; }
dialog::backdrop { background: rgb(0 0 0 / 70%); }
dialog h2 { margin-top: 0; font-size: 20px; }
dialog p { font-size: 14px; line-height: 1.6; }

.compact-game, .compact-game body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.compact-game .shell {
  position: relative; width: 100%; max-width: none;
  height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: minmax(0, 1fr);
  /* The playing field runs under the status bar and down to the very bottom edge. */
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.compact-game .topbar { display: none; position: absolute; z-index: 8; top: max(58px, calc(env(safe-area-inset-top) + 52px)); right: max(8px, env(safe-area-inset-right)); width: min(275px, calc(100% - 16px)); padding: 12px; margin: 0; border: 1px solid #475569; border-radius: 14px; background: #0f172a; }
.compact-game.menu-open .topbar { display: block; }
.compact-game .topbar > div:first-child { display: none; }
.compact-game .toolbar { gap: 6px; }
.compact-game .toolbar button { font-size: 12px; min-height: 42px; padding: 7px 10px; border-radius: 8px; touch-action: none; }
.compact-game .game-area { min-width: 0; min-height: 0; display: grid; place-items: end center; overflow: hidden; }
.compact-game #game { position: absolute; top: 0; left: 50%; width: auto; height: 100%; aspect-ratio: 720 / 1180; transform: translateX(-50%); }
.compact-game .game-frame { border: 0; border-radius: 0; box-shadow: none; }
.compact-game .app-notice { margin-top: 12px; }
.compact-game .app-notice span { display: block; margin-bottom: 6px; }
.compact-game .mobile-menu { display: block; position: absolute; right: max(8px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); z-index: 9; width: 44px; height: 44px; padding: 0; border: 1px solid #64748b; border-radius: 12px; background: #0f172acc; color: #f8fafc; font-size: 24px; touch-action: none; }
.compact-game .quick-pause { display: block; position: absolute; right: calc(max(8px, env(safe-area-inset-right)) + 50px); top: max(8px, env(safe-area-inset-top)); z-index: 9; width: 44px; height: 44px; padding: 0; border: 1px solid #64748b; border-radius: 12px; background: #0f172acc; color: #f8fafc; font-size: 16px; touch-action: none; }
.compact-game .hud { display: block; position: absolute; right: max(8px, env(safe-area-inset-right)); top: calc(max(8px, env(safe-area-inset-top)) + 50px); z-index: 4; width: 94px; padding: 5px 7px; border: 1px solid #f8fafc29; border-radius: 10px; background: #0f172ab8; color: #f8fafc; font-size: 11px; line-height: 1.45; white-space: pre; text-align: right; pointer-events: none; }
.compact-game.menu-open .hud { display: none; }
.compact-game .play-action { display: block; position: absolute; left: 50%; top: 44%; transform: translateX(-50%); z-index: 2; min-width: 140px; min-height: 46px; padding: 10px 18px; border: 1px solid #6ee7b7; border-radius: 12px; background: #34d399; color: #052e2b; font: bold 16px system-ui; touch-action: none; }
.play-action:disabled { opacity: .5; }
/* The whole stick is on screen: pulling it down brakes and backs up. */
.compact-game .touch-controls { position: absolute; inset-inline: 0; bottom: max(10px, env(safe-area-inset-bottom, 0px)); height: 148px; z-index: 3; display: flex; justify-content: center; align-items: flex-start; pointer-events: none; }
/* Semi-transparent thumb stick: traffic behind the rider stays visible through it. */
.joystick { flex: none; pointer-events: auto; position: relative; width: 148px; height: 148px; border-radius: 50%; border: 2px solid #f8fafc47; background: #0f172a59; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.joystick-knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; border: 2px solid #f8fafc8c; background: #f8fafc52; pointer-events: none; will-change: transform; }
.joystick.active { background: #0f172a80; border-color: #6ee7b799; }
.joystick.active .joystick-knob { background: #34d399b3; border-color: #a7f3d0; }
.game-area { position: relative; }
.portrait-hint { position: absolute; inset: 0; z-index: 7; display: grid; place-content: center; text-align: center; padding: 20px; background: #020617; color: #f8fafc; line-height: 1.6; }
