/* BreakPlay F1 Mini Games - shared racing chrome for all play-f1-* pages */
:root {
  --f1-red: #e10600;
  --f1-red-soft: #ff3b24;
  --f1-dark: #0b0b0f;
  --f1-carbon: #15151c;
  --f1-panel: #1b1b24;
  --f1-line: #2c2c3a;
  --f1-yellow: #ffd400;
  --f1-green: #00d26a;
  --f1-ink: #f5f6fa;
  --f1-muted: #9aa0b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body.f1-game {
  min-height: 100dvh;
  color: var(--f1-ink);
  font-family: "Chivo", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 12px, transparent 12px 24px),
    radial-gradient(900px 460px at 15% -10%, rgba(225, 6, 0, 0.28), transparent 60%),
    radial-gradient(760px 420px at 110% 15%, rgba(255, 212, 0, 0.1), transparent 55%),
    linear-gradient(180deg, var(--f1-carbon), var(--f1-dark) 70%);
  -webkit-tap-highlight-color: transparent;
}

/* ── Shared BreakPlay nav (matches other folder games) ── */
.bp-game-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(7, 7, 12, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: system-ui, -apple-system, sans-serif;
  position: relative;
  z-index: 50;
}
.bp-game-nav a {
  color: var(--f1-ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}
.bp-game-nav a:first-child { color: var(--f1-red-soft); }
.bp-game-nav a:last-child {
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0 16px;
}
.bp-game-nav a:hover { color: var(--f1-yellow); }

/* ── Top bar: title + stats + buttons ── */
.f1-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px 0;
}
.f1-title {
  font-family: "Bricolage Grotesque", var(--f1-ink);
  font-weight: 800;
  font-size: clamp(1rem, 4vw, 1.25rem);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.f1-title::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--f1-red), var(--f1-red-soft));
  box-shadow: 0 0 14px rgba(225, 6, 0, 0.7);
  flex: 0 0 auto;
}
.f1-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.f1-stats span {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--f1-line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem;
  color: var(--f1-muted);
  white-space: nowrap;
}
.f1-stats b { color: var(--f1-yellow); font-variant-numeric: tabular-nums; display: inline-block; }
.f1-btns { display: flex; gap: 8px; }
.f1-btns button {
  min-width: 46px;
  min-height: 46px;
  background: var(--f1-panel);
  border: 1px solid var(--f1-line);
  color: var(--f1-ink);
  border-radius: 14px;
  font-size: 1.05rem;
  cursor: pointer;
}
.f1-btns button:hover { border-color: var(--f1-red); color: var(--f1-yellow); }
.f1-btns button:focus-visible,
.f1-big:focus-visible { outline: 3px solid var(--f1-yellow); outline-offset: 2px; }


/* ── Stage: arena + side cards ── */
.f1-stage {
  max-width: 1080px;
  margin: 12px auto;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
}
.f1-arena {
  position: relative;
  background:
    radial-gradient(600px 380px at 50% 20%, rgba(225, 6, 0, 0.14), transparent 65%),
    linear-gradient(180deg, #17171f, #0d0d13);
  border: 1px solid var(--f1-line);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: clamp(16px, 4vw, 34px);
  min-height: clamp(330px, 56vh, 470px);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.f1-arena::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  background-image:
    linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%),
    linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%);
  background-color: #000;
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
  opacity: 0.5;
  pointer-events: none;
}
.f1-side { display: flex; flex-direction: column; gap: 12px; }
.f1-card {
  background: linear-gradient(180deg, var(--f1-panel), #14141b);
  border: 1px solid var(--f1-line);
  border-radius: 16px;
  padding: 14px 15px;
}
.f1-card h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-family: "Bricolage Grotesque", var(--f1-ink);
  color: var(--f1-red-soft);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.f1-card p { margin: 0; font-size: 0.85rem; color: var(--f1-muted); line-height: 1.55; }
.f1-card p + p { margin-top: 7px; }
.f1-card b { color: var(--f1-ink); }
.f1-card .f1-keys { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.f1-card kbd {
  background: #0e0e14;
  border: 1px solid var(--f1-line);
  border-bottom-width: 3px;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 0.74rem;
  color: var(--f1-yellow);
  font-family: "VT323", ui-monospace, monospace;
}
.f1-card .f1-bestline { margin-top: 9px; font-size: 0.8rem; color: var(--f1-yellow); }

/* ── Status line inside arena ── */
.f1-status {
  margin: 0;
  font-size: clamp(0.85rem, 3vw, 1rem);
  color: var(--f1-muted);
  text-align: center;
  min-height: 1.3em;
  font-weight: 600;
}
.f1-status.hot { color: var(--f1-yellow); }
.f1-status.good { color: var(--f1-green); }
.f1-status.bad { color: #ff6b5e; }

/* ── Toast flash inside arena ── */
.f1-flash {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid var(--f1-line);
  color: var(--f1-yellow);
  font-weight: 800;
  font-size: 0.86rem;
  border-radius: 999px;
  padding: 8px 16px;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}
.f1-flash.show { opacity: 1; }
.f1-flash.good { color: var(--f1-green); border-color: rgba(0, 210, 106, 0.5); }
.f1-flash.bad { color: #ff6b5e; border-color: rgba(255, 107, 94, 0.5); }

/* Big buttons (start again) always 44px, auto width (no clipping) */
.f1-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 13px 30px;
  border: none;
  border-radius: 15px;
  background: linear-gradient(95deg, var(--f1-yellow), #ff9d2e);
  color: #241300;
  font-family: "Bricolage Grotesque", var(--f1-ink);
  font-weight: 800;
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  letter-spacing: 0.4px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(255, 160, 40, 0.25);
  transition: transform 0.15s ease;
}
.f1-big:hover { transform: translateY(-2px); }
.f1-big:active { transform: translateY(1px); }
.f1-big.alt {
  background: linear-gradient(95deg, var(--f1-red), #ff5a3c);
  color: #fff;
  box-shadow: 0 10px 26px rgba(225, 6, 0, 0.3);
}
.f1-big.ghost {
  background: transparent;
  border: 2px solid var(--f1-line);
  color: var(--f1-ink);
  box-shadow: none;
}

/* Fullscreen start + gameover overlays */
.f1-overlay,
.f1-gameover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: max(22px, env(safe-area-inset-top, 0px)) 22px max(22px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 14px, transparent 14px 28px),
    radial-gradient(700px 420px at 50% -10%, rgba(225, 6, 0, 0.35), transparent 65%),
    rgba(6, 6, 10, 0.975);
}
.f1-overlay[hidden],
.f1-gameover[hidden] { display: none; }
.f1-overlay h1,
.f1-gameover h2 {
  margin: 0;
  font-family: "Bricolage Grotesque", var(--f1-ink);
  font-weight: 800;
  font-size: clamp(1.7rem, 8vw, 2.6rem);
  letter-spacing: 1px;
  line-height: 1.1;
  word-break: break-word;
  max-width: 640px;
}
.f1-overlay h1 span,
.f1-gameover h2 span {
  background: linear-gradient(90deg, var(--f1-red-soft), var(--f1-yellow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.f1-intro {
  margin: 0;
  max-width: 560px;
  line-height: 1.6;
  color: var(--f1-muted);
  font-size: clamp(0.88rem, 3.4vw, 1rem);
}
.f1-intro b { color: var(--f1-ink); }
.f1-intro .warn { color: var(--f1-yellow); }
#goStats { color: var(--f1-muted); font-size: 1.02rem; margin: 0; max-width: 520px; line-height: 1.6; }
#goStats b { color: var(--f1-yellow); }
.f1-overlay-actions,
.f1-go-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* Fixed "all games" pill */
.f1-home {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 45;
  color: var(--f1-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 11px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: rgba(20, 20, 28, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--f1-line);
  border-radius: 999px;
}
.f1-home:hover { color: var(--f1-yellow); border-color: var(--f1-red); }

@keyframes f1-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.f1-shake { animation: f1-shake 0.22s ease; }

/* Responsive: stack below desktop sidebar */
@media (max-width: 860px) {
  .f1-stage { grid-template-columns: 1fr; }
  .f1-side { flex-direction: row; flex-wrap: wrap; }
  .f1-side .f1-card { flex: 1 1 240px; }
}

@media (max-width: 380px) {
  .f1-top { padding: 10px 10px 0; }
  .f1-stats span { padding: 6px 10px; font-size: 0.74rem; }
  .f1-arena { padding: 14px 10px; }
}

/* === Shared tap pad - big touch target for reaction games === */
.tap-pad {
  width: min(420px, 92%);
  min-height: 96px;
  border-radius: 18px;
  border: 2px dashed rgba(255, 212, 0, 0.55);
  background: linear-gradient(180deg, rgba(255, 212, 0, 0.1), rgba(225, 6, 0, 0.12));
  color: var(--f1-yellow);
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  letter-spacing: 3px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.tap-pad:active,
.tap-pad.hit {
  background: linear-gradient(180deg, rgba(255, 212, 0, 0.32), rgba(225, 6, 0, 0.3));
  border-style: solid;
  transform: scale(0.99);
}

@media (max-width: 860px) {
  .tap-pad { min-height: 110px; }
}

/* ════════════════════════════════════════════════════════════
   SMOOTHNESS + RESPONSIVE POLISH - shared across all play-f1-*
   ════════════════════════════════════════════════════════════ */

/* ── Overlay: auto-margin centering never clips the top when the
      content is taller than the viewport (scroll stays reachable) ── */
.f1-overlay > :first-child,
.f1-gameover > :first-child { margin-top: auto; }
.f1-overlay > :last-child,
.f1-gameover > :last-child { margin-bottom: auto; }

/* ── Entrance animations for start / game-over screens ── */
@keyframes f1-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes f1-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.f1-overlay:not([hidden]),
.f1-gameover:not([hidden]) {
  animation: f1-fade 0.22s ease both;
}
.f1-overlay:not([hidden]) > *,
.f1-gameover:not([hidden]) > * {
  animation: f1-rise 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.f1-overlay:not([hidden]) > :nth-child(2),
.f1-gameover:not([hidden]) > :nth-child(2) { animation-delay: 0.06s; }
.f1-overlay:not([hidden]) > :nth-child(3),
.f1-gameover:not([hidden]) > :nth-child(3) { animation-delay: 0.12s; }
.f1-overlay:not([hidden]) > :nth-child(4),
.f1-gameover:not([hidden]) > :nth-child(4) { animation-delay: 0.18s; }

/* ── Flash toast: pop instead of snap ── */
@keyframes f1-pop {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(0.88); }
  60% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.05); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.f1-flash.show { animation: f1-pop 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

/* ── Stat micro-bump: f1-arcade.js adds .bump when a tracked value changes ── */
@keyframes f1-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.24); }
  100% { transform: scale(1); }
}
.f1-stats b.bump,
.f1-bestline.bump {
  animation: f1-bump 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  color: #fff;
}

/* ── Status line colour crossfade ── */
.f1-status { transition: color 0.2s ease; }

/* ── Control press feedback (works for mouse + touch) ── */
.f1-btns button {
  transition: transform 0.12s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.f1-btns button:active { transform: scale(0.9); }
.f1-big {
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.f1-big:hover { filter: brightness(1.06); }
.f1-home {
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.f1-home:active { transform: scale(0.95); }
.f1-card {
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .f1-card:hover {
    transform: translateY(-2px);
    border-color: #3d3d50;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  }
}
.tap-pad {
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
}
button,
a { touch-action: manipulation; }

/* ── Rolling checkered strips (subtle conveyor motion) ── */
@keyframes f1-checker-roll-14 {
  to { background-position: -14px 0, -7px 7px; }
}
.f1-arena::after { animation: f1-checker-roll-14 3s linear infinite; }

/* ── Small screens: title + buttons share row 1, stats wrap to row 2 ── */
@media (max-width: 560px) {
  .f1-top { row-gap: 8px; }
  .f1-title { order: 1; flex: 1 1 auto; min-width: 0; }
  .f1-btns { order: 2; flex: 0 0 auto; }
  .f1-stats { order: 3; flex: 1 0 100%; }
}

/* ── Clearance so the fixed "All games" pill never covers arena content ── */
.f1-stage { margin-bottom: 64px; }

/* ── Short landscape phones: compact intro/game-over + arena ── */
@media (max-height: 480px) and (orientation: landscape) {
  .f1-overlay,
  .f1-gameover { gap: 10px; padding: 14px; }
  .f1-overlay h1,
  .f1-gameover h2 { font-size: clamp(1.3rem, 6.4vh, 1.9rem); }
  .f1-intro { font-size: 0.84rem; line-height: 1.5; }
  .f1-big { min-height: 46px; padding: 10px 24px; }
  .f1-arena { min-height: clamp(220px, 62vh, 330px); }
}

/* ── Ultra-narrow phones (≤340px): tighten stats so all four fit one row ── */
@media (max-width: 340px) {
  .f1-stats span { padding: 5px 8px; font-size: 0.7rem; }
  .f1-title { font-size: 0.95rem; }
}

/* ── Tap comfort: no accidental pull-to-refresh, double-tap zoom or
      text-selection while mashing the arena ── */
html { overscroll-behavior: none; }
.f1-arena,
.f1-top,
.f1-overlay,
.f1-gameover,
.tap-pad {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.f1-arena { touch-action: manipulation; }

/* ── Game-over "new personal best" celebration badge (injected by f1-arcade.js).
      Scoped so it outranks the generic .f1-gameover > * rise animation (same
      specificity, later in file → wins the tie). ── */
.f1-gameover > .f1-newbest {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 212, 0, 0.22), rgba(225, 6, 0, 0.22));
  border: 1px solid rgba(255, 212, 0, 0.65);
  color: var(--f1-yellow);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 2px;
  animation: f1-best-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both,
    f1-best-glow 1.6s ease-in-out 0.5s infinite;
}
@keyframes f1-best-pop {
  from { opacity: 0; transform: scale(0.6) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes f1-best-glow {
  50% { box-shadow: 0 0 22px rgba(255, 212, 0, 0.5); }
}

/* ── Respect reduced-motion: kill all animation/transition flourish ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Race event chip (per-round modifier badge inside the arena) ── */
.f1-event-chip {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 7;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: #3a2200;
  background: linear-gradient(90deg, #ffd400, #ff944d);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1.2, 0.36, 1);
}
.f1-event-chip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Challenge target chip (?ch=SCORE) ── */
.f1-target-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 7;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: #3a2200;
  background: linear-gradient(90deg, #ffd400, #ffb300);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* ── Game-over extras: medal, challenge result, run sparkline ── */
.f1-medal {
  display: inline-block;
  margin: 8px 0 2px;
  padding: 5px 15px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
}
.f1-medal-gold { color: #3a2200; background: linear-gradient(90deg, #ffd400, #ffb300); }
.f1-medal-silver { color: #161d30; background: linear-gradient(90deg, #eef1f8, #b9c1d6); }
.f1-medal-bronze { color: #2b1600; background: linear-gradient(90deg, #ffbd8a, #d77b3f); }
.f1-chal {
  margin-top: 7px;
  font-size: 0.84rem;
  font-weight: 800;
}
.f1-chal-win { color: var(--f1-green); }
.f1-chal-miss { color: #ffb020; }
.f1-hist {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 7px;
  color: var(--f1-muted, #9aa3c7);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.f1-spark { color: var(--f1-green); }

/* ── Achievement toast ── */
.f1-toast {
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 999;
  transform: translate(-50%, -18px);
  opacity: 0;
  padding: 9px 17px;
  border-radius: 999px;
  background: #11182d;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f5f7ff;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1.2, 0.36, 1);
  pointer-events: none;
}
.f1-toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) {
  .f1-event-chip, .f1-toast { transition-duration: 0.01ms !important; }
}
