/* Road Fighter web door — themeable chrome.
   Themes are variable sets on <html data-theme>; Audiowide is the
   display face, Rajdhani the body/UI face, in every theme.
   Animations are OFF by default (data-anim="off"): panel pops and
   the separator flow only exist when the player turns them on. */

:root { color-scheme: dark; }
html[data-theme="heat"] {
  --bg: #0d0a08; --panel: rgba(13, 10, 8, 0.87); --field: #1a130e;
  --edge: #33241a; --accent: #ff4d00; --on-accent: #1c0d02;
  --text: #f7efe8; --dim: #b3a08e; --warn: #ffc21f;
  --sep1: #ff2d00; --sep2: #ff8c1a; --sep3: #ffc21f;
}
html[data-theme="midnight"] {
  --bg: #0b0e14; --panel: rgba(11, 14, 20, 0.82); --field: #12161f;
  --edge: #232a38; --accent: #22d3ee; --on-accent: #0b0e14;
  --text: #e8ecf3; --dim: #94a3b8; --warn: #f1c40f;
  --sep1: #22d3ee; --sep2: #818cf8; --sep3: #22d3ee;
}
html[data-theme="sunset"] {
  --bg: #160b08; --panel: rgba(22, 11, 8, 0.86); --field: #241209;
  --edge: #3a2015; --accent: #ff8c1a; --on-accent: #1c0d02;
  --text: #f7ece2; --dim: #c9a18c; --warn: #ffd23e;
  --sep1: #ff2d78; --sep2: #ff8c1a; --sep3: #ffd23e;
}
html[data-theme="toxic"] {
  --bg: #071207; --panel: rgba(7, 18, 7, 0.86); --field: #0d1f0d;
  --edge: #1d3319; --accent: #a3e635; --on-accent: #101c02;
  --text: #e9f5e3; --dim: #94b08a; --warn: #fde047;
  --sep1: #a3e635; --sep2: #22d3ee; --sep3: #a3e635;
}
html[data-theme="violet"] {
  --bg: #0e0a1c; --panel: rgba(14, 10, 28, 0.87); --field: #171231;
  --edge: #2a2350; --accent: #818cf8; --on-accent: #0d0a24;
  --text: #eceaf7; --dim: #a49ec9; --warn: #fbbf24;
  --sep1: #818cf8; --sep2: #c084fc; --sep3: #22d3ee;
}
html[data-theme="paper"] {
  color-scheme: light;
  --bg: #f2efe9; --panel: rgba(255, 255, 255, 0.9); --field: #ffffff;
  --edge: #d8d2c4; --accent: #d90429; --on-accent: #ffffff;
  --text: #191c22; --dim: #5d6470; --warn: #b45309;
  --sep1: #d90429; --sep2: #ff8c1a; --sep3: #d90429;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Rajdhani", system-ui, sans-serif;
  font-weight: 600;
  display: flex;
  justify-content: center;
  padding: 16px;
}
#app { position: relative; width: 960px; max-width: 100%; }
canvas {
  display: block;
  width: 100%;
  border-radius: 12px;
  background: #1e7d32;
}
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--panel);
  border-radius: 12px;
  text-align: center;
  padding: 20px;
}
html[data-anim="on"] .panel { animation: panelpop 0.3s ease-out; }
@keyframes panelpop {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.hidden { display: none; }
h1 { margin: 0; font-family: "Audiowide", "Rajdhani", sans-serif; font-weight: 400; font-size: 44px; letter-spacing: 2px; }
.tag { margin: 0; color: var(--dim); }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
button {
  font-family: inherit;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
button { transition: transform 0.06s ease-out; }
button:active:not(:disabled) { transform: scale(0.97); }
button:hover:not(:disabled) { filter: brightness(1.1); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.controls { color: var(--dim); font-size: 14px; line-height: 1.9; }
.controls b { color: var(--text); }
.lobby-row { display: flex; gap: 8px; }
input {
  font-family: inherit;
  padding: 12px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--field);
  color: var(--text);
  text-transform: uppercase;
}
#input-name { text-transform: none; }
.lobby-players { font-size: 15px; line-height: 1.8; }
.hint { color: var(--dim); font-size: 13px; max-width: 520px; }
#status { min-height: 22px; color: var(--warn); text-align: center; }

/* Themed separator: a static gradient bar by default; the flow
   animation only runs when animations are on, and the whole bar
   can be switched off in Customize. Colours come from the theme. */
.sep {
  height: 2px;
  width: min(420px, 82%);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--sep1), var(--sep2), var(--sep3), var(--sep1));
  background-size: 200% 100%;
}
html[data-anim="on"] .sep { animation: sepflow 6s linear infinite; }
html[data-sep="off"] .sep { display: none; }
@keyframes sepflow { to { background-position: 200% 0; } }

/* ---- Customize sheet ---- */
#btn-settings {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
#sheet {
  position: fixed;
  top: 68px;
  right: 14px;
  width: 302px;
  max-width: calc(100vw - 28px);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
  z-index: 41;
  display: none;
  text-align: left;
}
#sheet.open { display: block; }
html[data-anim="on"] #sheet.open { animation: panelpop 0.25s ease-out; }
#sheet h2 { margin: 0 0 10px; font-family: "Audiowide", sans-serif; font-weight: 400; font-size: 18px; letter-spacing: 1px; }
#sheet .sep { width: 100%; margin-bottom: 6px; }
#sheet h3 { margin: 12px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--dim); }
.pick-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-grid button {
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--edge);
  padding: 8px 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.pick-grid button.active { border-color: var(--accent); outline: 1px solid var(--accent); }
.chip {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--c1) 50%, var(--c2) 50%);
  border: 1px solid rgba(128, 128, 128, 0.5);
}
.row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0 2px;
  font-size: 14px;
  cursor: pointer;
}
.row-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--edge); position: relative; transition: background 0.15s;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text); transition: transform 0.15s;
}
.row-toggle input:checked + .switch { background: var(--accent); }
.row-toggle input:checked + .switch::before { transform: translateX(18px); }
.row-toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
#btn-done { width: 100%; margin-top: 14px; }

/* ---- Custom cursors ----
   The native cursor is hidden only while a custom one is active
   (text inputs keep their I-beam). Every custom cursor carries
   its own contrast — a white core with a dark rim — so it stays
   readable on any theme. Movement is transform-only (composited),
   and the hover grow is a transform on the inner wrapper. */
html:not([data-cursor="native"]) body,
html:not([data-cursor="native"]) button,
html:not([data-cursor="native"]) .panel,
html:not([data-cursor="native"]) .row-toggle { cursor: none; }
/* Blanket backstop: every element hides its native cursor while
   a custom one is active — text inputs keep their I-beam. */
html:not([data-cursor="native"]) *:not(input):not(textarea) { cursor: none !important; }
#cursor {
  position: fixed;
  left: 0; top: 0;
  width: 38px; height: 38px;
  margin: -19px 0 0 -19px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s;
  will-change: transform;
  display: none;
}
#cursor.on { opacity: 1; }
#cursor-in { position: absolute; inset: 0; transition: transform 0.15s; }
#cursor.hovering #cursor-in { transform: scale(1.35); }
/* Orb: accent ring, white core, dark rim */
html[data-cursor="orb"] #cursor-in::before {
  content: ""; position: absolute; inset: 2px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.6), 0 0 12px var(--accent);
}
html[data-cursor="orb"] #cursor-in::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.65);
}
/* Crosshair: accent bars with dark outline, white centre dot */
html[data-cursor="crosshair"] #cursor-in::before {
  content: ""; position: absolute; left: 3px; right: 3px; top: 50%;
  height: 2px; margin-top: -1px; background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
html[data-cursor="crosshair"] #cursor-in::after {
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 50%;
  width: 2px; margin-left: -1px; background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
html[data-cursor="crosshair"] #cursor-in {
  background: radial-gradient(circle, #fff 0 2.5px, rgba(0, 0, 0, 0.65) 3.5px, transparent 4.5px);
}
/* Chevron: accent arrow head, tip on the pointer, dark drop edge */
html[data-cursor="chevron"] #cursor-in::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--sep2), var(--accent));
  clip-path: polygon(0 0, 100% 62%, 58% 74%, 76% 100%, 60% 100%, 44% 78%, 0 100%);
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.8));
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Phone layout: the menu panel scrolls internally instead
   of clipping, type steps down, nothing runs off the sides. ---- */
@media (max-width: 560px) {
  body { padding: 8px; }
  h1 { font-size: 29px; letter-spacing: 1px; }
  .panel { gap: 9px; padding: 12px 10px; overflow-y: auto; justify-content: flex-start; }
  .controls { font-size: 12.5px; line-height: 1.55; }
  button { padding: 10px 14px; font-size: 14px; }
  #btn-settings { top: 8px; right: 8px; width: 40px; height: 40px; }
  #sheet { top: 56px; right: 8px; }
  .lobby-row { flex-wrap: wrap; justify-content: center; }
  input { max-width: 100%; }
}
