/* Fallback copies of prignano-theme's color tokens, used if the shared theme can't load. */
:root {
  --bg: #f6f7f9;
  --fg: #111418;
  --muted: #5f6873;
  --card: #ffffff;
  --border: #e3e6ea;
  --accent: #2563d6;
  --active: #17804a;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --fg: #e6edf3; --muted: #8b949e; --card: #151b23; --border: #2a313c; --accent: #58a6ff; --active: #3fb950;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --fg: #e6edf3; --muted: #8b949e; --card: #151b23; --border: #2a313c; --accent: #58a6ff; --active: #3fb950;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
}
body { display: flex; flex-direction: column; height: 100dvh; }
#site-header { flex-shrink: 0; }
#site-header.collapsed { display: none; }
.back-home {
  display: block;
  padding: 10px 16px;
  background: #132308;
  color: #e0a52e;
  font-family: "Barlow Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.back-home:hover { color: #fff; }

#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
}
.hud-stats { margin-right: auto; display: flex; align-items: baseline; column-gap: 12px; flex-wrap: wrap; min-width: 0; }
.hud-score { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-ball { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation; /* fast taps on Nudge shouldn't zoom the page on iOS */
}
@media (max-width: 480px) {
  .hud { gap: 6px; }
  .hud button { padding: 6px 10px; }
  .hud-score { font-size: 1.2rem; }
  .hud-ball { font-size: 0.8rem; }
}
button:hover, button:focus-visible { border-color: var(--accent); outline: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.stage { position: relative; flex: 1; min-height: 0; }
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.nudge {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  opacity: 0.75;
}
@media (hover: hover) and (pointer: fine) { .nudge { display: none; } }
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 5rem;
  font-weight: 800;
  pointer-events: none;
}

.rotate-note { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .hud, .stage { display: none; }
  .rotate-note { display: grid; place-items: center; flex: 1; margin: 0; font-size: 1.2rem; }
}

dialog {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  width: min(92vw, 420px);
  box-sizing: border-box;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
a { color: var(--accent); }
kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 0.85em; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.table-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.table-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
}
.table-list .best { color: var(--muted); font-variant-numeric: tabular-nums; }
.final-score { font-size: 2rem; font-weight: 800; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.high-scores { padding-left: 1.5em; margin: 8px 0; font-variant-numeric: tabular-nums; }
.high-scores li.new { color: var(--accent); font-weight: 700; }
#initials {
  font: inherit;
  font-size: 1.2rem;
  width: 5ch;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.2em;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Graphics choice in the table menu. */
.gfx-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.gfx-row select {
  font: inherit;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}

/* 3D view: its own canvas in a dark room, with messages and score pop-ups in HTML on top. */
.game-3d {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body.three #game { display: none; }
body.three .stage { background: #05070b; touch-action: none; }
body.three .countdown { color: #fff; }
.popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.popups span {
  position: absolute;
  left: 0;
  top: 0;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}
.table-message {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(5, 7, 11, 0.82);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  pointer-events: none;
}
.fps {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font: 12px ui-monospace, monospace;
  pointer-events: none;
}

/* The score as a dot-matrix style panel while the table is in 3D. */
body.three .hud-score {
  padding: 2px 12px;
  border-radius: 6px;
  color: #ffab3d;
  background-color: #150b02;
  background-image: radial-gradient(rgba(255, 171, 61, 0.14) 0.8px, transparent 1.1px);
  background-size: 3px 3px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-shadow: 0 0 6px rgba(255, 140, 20, 0.75);
}
