/* Full Lock, the drift game. Loaded after /play/parts-rush/game.css, which holds the shared
   games look (paper, ink, wobbly cards, toggles, best scores); everything here is .sw- scoped. */

.sw-body {
  --sw-paper: #fbf8f1;
  --sw-ink: #24211c;
  --sw-wash: #ebe3d1;
  --sw-red: #d7141c;
  --sw-red-ink: #b3121a;
}

/* ---------- start screen ---------- */
.sw-start, .sw-finish { padding: 28px 0 40px; }
.sw-subtitle { display: block; font-size: 0.42em; letter-spacing: 0.04em; color: var(--sw-red-ink); margin-top: 4px; }
.sw-safety { border-left: 4px solid var(--sw-red); padding: 6px 0 6px 12px; margin: 14px 0; }
.sw-go { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.sw-go .btn { flex: 1 1 150px; }
.sw-settings { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 6px; }
.sw-settings .pr-toggle:disabled { opacity: 0.55; cursor: not-allowed; }
.sw-aid-note { margin-top: 4px; }
.sw-drills { margin: 22px 0; }
.sw-drill-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.sw-drill {
  border: 1.5px solid var(--sw-ink); border-radius: var(--pr-wobble); background: var(--sw-paper); padding: 10px 14px;
}
.sw-drill h3 { font: 700 italic 1.2rem/1.1 var(--font-display); text-transform: uppercase; margin: 0 0 4px; }
.sw-drill p { margin: 0 0 8px; }
.sw-drill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 !important; }
.sw-drill-go { min-height: 44px; padding: 8px 16px; }
.sw-honest { margin-top: 18px; }
.sw-foot-safety { padding-top: 8px; padding-bottom: 24px; }
@media (min-width: 700px) {
  .sw-drill-list { grid-template-columns: 1fr 1fr; }
}

/* ---------- play: a fixed full-viewport layout, nothing scrolls or zooms ---------- */
html.sw-playing, html.sw-playing body { overflow: hidden; overscroll-behavior: none; }
.sw-play {
  position: fixed; inset: 0; z-index: 80; height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--sw-paper); color: var(--sw-ink);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.sw-play[hidden] { display: none !important; }
.sw-hud {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  border-bottom: 1.5px solid var(--sw-ink); background: var(--sw-paper); z-index: 2;
}
.sw-hud-btn {
  min-height: 44px; min-width: 64px; padding: 6px 12px; border: 1.5px solid var(--sw-ink); border-radius: var(--pr-wobble);
  background: transparent; color: var(--sw-ink); font: 700 0.95rem/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
}
.sw-hud-mid { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 0; }
.sw-zone { font: 700 italic 1.2rem/1.1 var(--font-display); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sw-time { font: 500 0.85rem/1.2 var(--font-mono); color: #5d564a; }
.sw-hud-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.sw-score { font: 500 1.4rem/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.sw-score-label { font: 700 0.7rem/1.3 var(--font-display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--sw-red-ink); }

.sw-stage { position: relative; min-height: 0; overflow: hidden; }
.sw-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sw-angle {
  position: absolute; top: 10px; right: max(12px, env(safe-area-inset-right)); text-align: right; pointer-events: none;
  font: 700 italic 2.4rem/0.9 var(--font-display); color: var(--sw-ink); text-shadow: 0 0 6px var(--sw-paper);
}
.sw-angle span::after { content: "\00B0"; }
.sw-angle small { display: block; font: 700 0.7rem/1.3 var(--font-display); font-style: normal; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sw-red-ink); }
.sw-toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%) rotate(-1deg); margin: 0; opacity: 0; pointer-events: none;
  padding: 6px 14px; border: 2px solid var(--sw-ink); border-radius: var(--pr-wobble); background: var(--sw-paper);
  box-shadow: 3px 3px 0 var(--sw-red); font: 700 italic 1.25rem/1.1 var(--font-display); text-transform: uppercase; white-space: nowrap;
}
.sw-toast-show { animation: sw-toast 2.2s ease-out; }
@keyframes sw-toast { 0% { opacity: 0; } 8%, 75% { opacity: 1; } 100% { opacity: 0; } }
.sw-drill-bar {
  position: absolute; left: 10px; right: 96px; top: 10px; display: grid; gap: 4px; pointer-events: none;
  padding: 6px 10px; border: 1.5px solid var(--sw-ink); border-radius: 10px; background: rgba(251, 248, 241, 0.92); font-size: 0.85rem;
}
.sw-drill-bar[hidden] { display: none !important; }
.sw-drill-meter { height: 8px; border: 1.5px solid var(--sw-ink); border-radius: 4px; overflow: hidden; }
.sw-drill-meter span { display: block; height: 100%; width: 100%; background: var(--sw-red); transform-origin: left; transform: scaleX(var(--p, 0)); }
.sw-rotate { display: none; }
.sw-drilling .sw-hud-score { visibility: hidden; }

/* Controls: a band under the course in portrait, so thumbs never cover the car. */
.sw-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px;
  padding: 8px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1.5px solid var(--sw-ink); background: var(--sw-paper); touch-action: none;
}
.sw-steer {
  position: relative; height: 96px; border: 2.5px solid var(--sw-ink); border-radius: 48px; background: var(--sw-wash);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; font-size: 1.6rem; color: var(--sw-ink);
  max-width: 320px; touch-action: none;
}
.sw-steer.sw-on { background: #e3d8c0; }
.sw-steer-knob {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 2.5px solid var(--sw-ink); background: var(--sw-paper); box-shadow: 2px 2px 0 var(--sw-red);
  transform: translateX(calc(var(--steer, 0) * 80px)); pointer-events: none;
}
.sw-pedals {
  display: grid; grid-template-columns: 64px 80px; grid-template-rows: 56px 96px; gap: 8px; grid-template-areas: "hb hb" "brake gas";
}
.sw-pedal {
  display: flex; align-items: center; justify-content: center; text-align: center; touch-action: none; cursor: pointer;
  border: 2.5px solid var(--sw-ink); border-radius: 16px; background: var(--sw-paper);
  font: 700 0.95rem/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--sw-ink);
}
.sw-hb { grid-area: hb; }
.sw-brake { grid-area: brake; }
.sw-gas { grid-area: gas; background: var(--sw-red); color: #fff; font-size: 1.1rem; }
.sw-pedal.sw-on { background: var(--sw-ink); color: var(--sw-paper); transform: translateY(2px); }
.sw-gas.sw-on { background: #8f0d13; }

@media (orientation: portrait) and (pointer: coarse) {
  .sw-rotate {
    display: block; position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); margin: 0; pointer-events: none;
    padding: 4px 10px; border-radius: 6px; background: rgba(36, 33, 28, 0.8); color: var(--sw-paper); font-size: 0.8rem; white-space: nowrap;
    animation: sw-fade-out 5s ease-in forwards;
  }
}
@keyframes sw-fade-out { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* Landscape: the course fills the screen and the controls sit in the bottom corners, either
   side of the car, which is drawn in the middle. */
@media (orientation: landscape) and (max-height: 600px), (orientation: landscape) and (pointer: coarse) {
  .sw-play { grid-template-rows: auto minmax(0, 1fr); }
  .sw-controls {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; border: 0; background: transparent; pointer-events: none;
    grid-template-columns: auto auto; justify-content: space-between;
  }
  .sw-steer, .sw-pedal { pointer-events: auto; }
  .sw-steer { width: min(34vw, 260px); background: rgba(235, 227, 209, 0.88); }
  .sw-pedal { background: rgba(251, 248, 241, 0.9); }
  .sw-gas { background: var(--sw-red); }
}

/* Keyboard and mouse: hide the touch controls on a big screen with no touch. */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .sw-controls { display: none; }
  .sw-stage::after {
    content: "Arrow keys or WASD: steer, power, brake. Space: handbrake. Escape: pause. R: back on the track.";
    position: absolute; left: 12px; bottom: 10px; font: 500 0.8rem/1.3 var(--font-body); color: #5d564a;
    background: rgba(251, 248, 241, 0.85); padding: 2px 6px; border-radius: 4px;
  }
}

.sw-paused { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(36, 33, 28, 0.45); }
.sw-paused[hidden] { display: none !important; }
.sw-paused-card {
  display: grid; gap: 10px; width: min(86vw, 320px); padding: 18px; text-align: center;
  background: var(--sw-paper); border: 3px solid var(--sw-ink); border-radius: var(--pr-wobble); box-shadow: 5px 6px 0 var(--sw-red);
}
.sw-paused-title { margin: 0; font: 700 italic 2rem/1 var(--font-display); text-transform: uppercase; }
.sw-paused .btn-outline { color: var(--sw-ink); border-color: var(--sw-ink); background: transparent; }

/* ---------- finish ---------- */
.sw-total { margin: 10px 0; font: 700 italic 3.6rem/1 var(--font-display); }
.sw-total small { font-size: 0.45em; margin-left: 6px; color: #5d564a; }
.sw-sheet { width: 100%; border-collapse: collapse; margin: 12px 0 6px; font-variant-numeric: tabular-nums; }
.sw-sheet th, .sw-sheet td { padding: 7px 6px; border-bottom: 1px dashed #b9ae95; text-align: right; }
.sw-sheet th:first-child { text-align: left; }
.sw-sheet thead th { font: 700 0.85rem/1.2 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }
.sw-sheet thead small { color: #5d564a; }
.sw-sheet td { font: 500 0.95rem/1.3 var(--font-mono); }
.sw-sheet tfoot th, .sw-sheet tfoot td { border-top: 2px solid var(--sw-ink); border-bottom: 0; font-weight: 700; }
.sw-sheet .sw-failed { text-align: left; font-family: var(--font-body); color: var(--sw-red-ink); }

@media (prefers-reduced-motion: reduce) {
  .sw-toast-show { animation-duration: 2.6s; }
  .sw-pedal.sw-on { transform: none; }
}

/* ---------- the /play/ hub card ---------- */
.sw-hub-art svg { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
