/* =====================================================================
   Lottery Ball - "Deep Stage" shell (design v3)
   The machine itself is drawn on <canvas> by engine.js. This styles the
   page shell, header, history strip, controls, banners and theming around
   it. Every color reads from a --lb-* token defined for BOTH themes so
   nothing breaks on toggle (dark AND light BASE_MODE both readable).
   ===================================================================== */

:root,
[data-theme="dark"] {
  --lb-bg-1: #04030b;
  --lb-bg-2: #150a34;
  --lb-aura-1: #7c2bff;
  --lb-aura-2: #00e5ff;
  --lb-aura-3: #ff2fd6;
  --lb-text: #ffffff;
  --lb-text-dim: #cabfff;
  --lb-accent: #b026ff;
  --lb-accent-glow: rgba(176, 38, 255, 0.65);
  --lb-panel: rgba(124, 43, 255, 0.16);
  --lb-panel-edge: rgba(176, 38, 255, 0.45);
  /* raised control surface + history strip */
  --lb-surface: rgba(18, 10, 44, 0.62);
  --lb-surface-edge: rgba(176, 38, 255, 0.34);
  --lb-btn-top: color-mix(in srgb, var(--lb-accent) 88%, #ffffff 12%);
  --lb-btn-bot: color-mix(in srgb, var(--lb-accent) 62%, #000000 38%);
  --lb-btn-label: #ffffff;
}

[data-theme="light"] {
  --lb-bg-1: #eef0fb;
  --lb-bg-2: #dde4fb;
  --lb-aura-1: #7c5cff;
  --lb-aura-2: #00c2d8;
  --lb-aura-3: #ff5ad0;
  --lb-text: #170f33;
  --lb-text-dim: #564d84;
  --lb-accent: #7a1fff;
  --lb-accent-glow: rgba(122, 31, 255, 0.35);
  --lb-panel: rgba(122, 31, 255, 0.10);
  --lb-panel-edge: rgba(122, 31, 255, 0.30);
  /* raised control surface + history strip */
  --lb-surface: rgba(255, 255, 255, 0.72);
  --lb-surface-edge: rgba(122, 31, 255, 0.22);
  --lb-btn-top: color-mix(in srgb, var(--lb-accent) 80%, #ffffff 20%);
  --lb-btn-bot: color-mix(in srgb, var(--lb-accent) 66%, #000000 34%);
  --lb-btn-label: #ffffff;
}

html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--lb-text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background:
    radial-gradient(70% 50% at 15% 0%, color-mix(in srgb, var(--lb-aura-1) 32%, transparent), transparent 70%),
    radial-gradient(60% 45% at 90% 10%, color-mix(in srgb, var(--lb-aura-3) 28%, transparent), transparent 70%),
    radial-gradient(80% 60% at 50% 100%, color-mix(in srgb, var(--lb-aura-2) 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--lb-bg-2), var(--lb-bg-1) 75%);
  background-attachment: fixed;
}

.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;
}

.lb-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.lb-head { text-align: center; }
.lb-title {
  margin: 0;
  font-size: clamp(26px, 6vw, 40px);
  font-weight: 800;
  letter-spacing: 0.16em;
  background: linear-gradient(100deg, var(--lb-aura-2), var(--lb-aura-1) 45%, var(--lb-aura-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lb-sub {
  margin: 6px 0 0;
  font-size: clamp(13px, 2.6vw, 15px);
  color: var(--lb-text-dim);
  letter-spacing: 0.02em;
}

.lb-stage { width: 100%; display: flex; justify-content: center; }
.lb-canvas {
  width: 100%;
  max-width: 520px;
  display: block;
  filter: drop-shadow(0 26px 60px rgba(0, 0, 0, 0.45));
}

/* ===== history strip: recent results as rows of mini glossy balls ===== */
.lb-history {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--lb-surface);
  border: 1px solid var(--lb-surface-edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  scrollbar-width: thin;
}
.lb-history::-webkit-scrollbar { height: 5px; }
.lb-history::-webkit-scrollbar-thumb { background: var(--lb-panel-edge); border-radius: 3px; }
.lb-hlabel {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--lb-text-dim);
  padding-right: 2px;
}
.lb-hrow {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--lb-accent) 12%, transparent);
  border: 1px solid var(--lb-panel-edge);
}
.lb-mini {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.55),
              inset 0 -3px 4px rgba(0, 0, 0, 0.4),
              0 2px 4px rgba(0, 0, 0, 0.35);
}
.lb-mini::after {   /* specular hotspot */
  content: "";
  position: absolute;
  top: 3px; left: 5px;
  width: 8px; height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}
.lb-mini-n {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

.lb-winbanner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 34px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--lb-aura-2), var(--lb-accent) 55%, var(--lb-aura-3));
  box-shadow: 0 12px 34px var(--lb-accent-glow),
              inset 0 2px 2px rgba(255, 255, 255, 0.4),
              inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
  overflow: hidden;
}
.lb-winbanner::before {   /* glossy top sheen */
  content: "";
  position: absolute;
  inset: 0 0 55% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.lb-winbanner.show { opacity: 1; transform: translateY(0) scale(1); }
.lb-win-label { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.95; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.lb-win-prize { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35); }

.lb-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: 4px;
}
/* glossy pill buttons: saturated vertical gradient, bold white label, pressed state */
.lb-btn {
  position: relative;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--lb-text);
  background: var(--lb-surface);
  border: 1px solid var(--lb-surface-edge);
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
}
.lb-btn::before {   /* top gloss on every pill */
  content: "";
  position: absolute;
  inset: 1px 1px 55% 1px;
  border-radius: 999px 999px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.lb-btn > * { position: relative; z-index: 1; }
.lb-btn:hover { transform: translateY(-2px); box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.35), 0 8px 18px rgba(0, 0, 0, 0.3); }
.lb-btn:active { transform: translateY(1px); box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.35); filter: brightness(0.94); }
.lb-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.lb-btn-primary {
  color: var(--lb-btn-label);
  font-size: 17px;
  padding: 16px 40px;
  background: linear-gradient(180deg, var(--lb-btn-top), var(--lb-btn-bot));
  border: 1px solid color-mix(in srgb, var(--lb-accent) 60%, #000 40%);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.45),
              inset 0 -3px 6px rgba(0, 0, 0, 0.3),
              0 10px 26px var(--lb-accent-glow);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.lb-btn-primary:active { box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.45), 0 4px 12px var(--lb-accent-glow); }
.lb-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 18px;
}
.lb-btn-ghost.is-off { opacity: 0.5; }
.lb-btn svg { display: block; }

.lb-note {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--lb-text-dim);
  text-align: center;
  max-width: 460px;
  line-height: 1.5;
}

/* color-mix fallback for older engines: solid aura tints + flat button/pill fills */
@supports not (background: color-mix(in srgb, red, blue)) {
  body { background: linear-gradient(180deg, var(--lb-bg-2), var(--lb-bg-1)); }
  .lb-btn-primary { background: linear-gradient(180deg, var(--lb-accent), var(--lb-accent)); }
  .lb-hrow { background: var(--lb-panel); }
}

/* ===== Milestone 2: live communal draw event mode ===== */
.lb-live-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 auto 12px;
  max-width: 520px;
  padding: 0 16px;
}
.lb-live-countdown {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 32px;
  border-radius: 20px;
  background: var(--lb-surface);
  border: 1px solid var(--lb-surface-edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
}
.lb-live-countdown-label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lb-text-dim);
  font-weight: 700;
}
.lb-live-countdown-clock {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--lb-aura-2), var(--lb-accent) 60%, var(--lb-aura-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px var(--lb-accent-glow));
}
.lb-live-result {
  position: relative;
  padding: 14px 28px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--lb-aura-2), var(--lb-accent) 55%, var(--lb-aura-3));
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.05em;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 12px 30px var(--lb-accent-glow),
              inset 0 2px 2px rgba(255, 255, 255, 0.4),
              inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.lb-live-result::before {   /* glossy top sheen */
  content: "";
  position: absolute;
  inset: 0 0 55% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  pointer-events: none;
}
