/* Flipper Forge — app chrome (§3 colors; the table itself is drawn on canvas).
   Designed at 1512×860 first, then 1280×720 and fullscreen 1512×982; portrait 390×844 usable. */

:root {
  --bg: #0f1117;
  --panel: #171a23;
  --border: #262b38;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.noscript { padding: 24px; color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* ---------- buttons, key caps, focus ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: 600 14px/1.2 var(--font);
  cursor: pointer;
  user-select: none;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn:hover:not(:disabled) { border-color: #3a4152; background: #1d2130; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0f1117; }
.btn-primary:hover:not(:disabled) { background: #fbbf24; border-color: #fbbf24; }
.btn-icon { min-width: 38px; padding: 6px 10px; font-size: 18px; }
.btn kbd { font-size: 11px; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border: 1px solid #3a4152;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #0f1117;
  color: var(--text);
  font: 600 12px/1.3 var(--font);
  text-align: center;
  white-space: nowrap;
}
.kbd-sep { color: var(--muted); margin: 0 3px; font-size: 12px; }

/* ---------- play screen ---------- */

.play { position: absolute; inset: 0; }

.play-stage {
  position: absolute;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--border), 0 12px 40px rgba(0, 0, 0, .55);
  overflow: hidden;
  background: #0b1026;
}

.play-canvas { display: block; touch-action: none; }

.play-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel-name {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.panel-by { margin: -8px 0 0; color: var(--muted); font-size: 15px; }

.panel-block {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.panel-score-value {
  font-size: 40px;
  line-height: 1.1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.panel-balls { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-ball-label { font-weight: 600; }
.panel-dots { color: var(--accent); letter-spacing: .12em; font-size: 18px; white-space: nowrap; }

.panel-legend { margin: 6px 0 0; display: grid; gap: 8px; }
.panel-legend > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-legend dt { color: var(--muted); font-size: 14px; }
.panel-legend dd { margin: 0; text-align: right; }

.panel-buttons { display: flex; gap: 10px; margin-top: auto; }
.panel-buttons .btn:first-child { flex: 1 1 auto; }

/* portrait / narrow: plain score strip on top, ⏸ at the top right */
.play-strip {
  position: absolute;
  left: 0; right: 0; top: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.strip-main { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.strip-score {
  font-weight: 800;
  font-size: 1.25em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.strip-meta { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; color: var(--muted); white-space: nowrap; }
.strip-dots { color: var(--accent); letter-spacing: .1em; }
.strip-pause { flex: 0 0 auto; }

.play[data-layout="portrait"] .play-panel { display: none; }
.play[data-layout="portrait"] .play-strip { display: flex; }

/* ---------- overlays (inside the table stage) ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 7, 12, .62);
  z-index: 5;
}
.overlay-card {
  width: min(92%, 340px);
  padding: 24px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  text-align: center;
  animation: overlay-in .16s ease-out;
}
.overlay-title { margin: 0 0 10px; font-size: 24px; font-weight: 800; overflow-wrap: anywhere; }
.overlay-cta {
  margin: 4px 0 18px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 15px;
}
.overlay-label { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.overlay-score {
  margin: 2px 0 18px;
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.overlay-actions .btn { min-width: 120px; }
.overlay-hint { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

@keyframes overlay-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- toasts (ui/toast.js) ---------- */

.toasts{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:1000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-width:calc(100vw - 32px)}
.toast{pointer-events:auto;display:flex;align-items:center;gap:12px;background:#171a23;color:#e5e7eb;border:1px solid #262b38;border-radius:10px;padding:10px 10px 10px 16px;font:14px/1.4 system-ui,sans-serif;box-shadow:0 8px 24px rgba(0,0,0,.45);animation:toast-in .16s ease-out}
.toast-error{border-color:#ef4444}
.toast-msg{flex:1 1 auto}
.toast-action{background:transparent;color:#f59e0b;border:1px solid #f59e0b;border-radius:8px;padding:4px 10px;font:600 13px/1.2 system-ui,sans-serif;cursor:pointer}
.toast-close{background:transparent;color:#9ca3af;border:0;border-radius:6px;padding:2px 6px;font:18px/1 system-ui,sans-serif;cursor:pointer}
.toast-action:focus-visible,.toast-close:focus-visible{outline:2px solid #f59e0b;outline-offset:2px}
@keyframes toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* ---------- ?debug tooling ---------- */

.debug-overlay {
  position: fixed;
  left: 8px; top: 8px;
  z-index: 900;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .7);
  color: #a3e635;
  font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}
.debug-lab {
  position: fixed;
  right: 12px; top: 12px;
  z-index: 950;
  width: 300px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  font-size: 13px;
}
.debug-lab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.debug-lab-head h2 { margin: 0; font-size: 16px; }
.debug-lab-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-bottom: 8px; }
.debug-lab-row output { color: var(--accent); font-variant-numeric: tabular-nums; }
.debug-lab-row input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.debug-lab .btn { width: 100%; margin-top: 4px; }
.debug-lab-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- small screens / motion ---------- */

@media (max-height: 760px) {
  .play-panel { gap: 10px; padding: 16px; }
  .panel-name { font-size: 26px; }
  .panel-block { padding: 10px 14px; }
  .panel-score-value { font-size: 34px; }
  .panel-legend { gap: 6px; }
}

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