/**
 * base.css — Shared layout/reset tokens for the Gacha Draw mini-game.
 * Colors are NEVER hardcoded here — everything routes through the
 * var(--g-*) tokens emitted by gachaThemeVarsBlock() in <head>.
 * Per-theme decorative flourishes (glows, gradients, SVG paint) live in the
 * template file itself; this file only carries structure shared by all themes.
 */

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--g-bg);
  color: var(--g-text);
}
body {
  font-family: var(--g-font, inherit);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; }

.g-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 56px;
  position: relative;
}

/* Desktop two-column layout: machine left, tickets right, >=980px */
@media (min-width: 980px) {
  .g-wrap {
    max-width: 1040px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
    padding-top: 24px;
  }
  .g-col-left,
  .g-col-right { min-width: 0; }
  .g-title-row { grid-column: 1 / -1; }
}

.g-title-row { text-align: center; margin-bottom: 16px; }

.g-hidden { display: none !important; }
.g-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;
}

/* Coupon header */
.g-coupons {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--g-panel);
  border: 1px solid var(--g-panel-border);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.g-coupons .g-dots { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.g-coupons .g-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--g-panel-border);
  border: 1px solid var(--g-panel-border);
}
.g-coupons .g-dot.g-full {
  background: var(--g-accent-2);
  border-color: var(--g-accent-2);
  box-shadow: 0 0 8px var(--g-accent-2);
}
.g-coupons .g-overflow { font-size: 11px; color: var(--g-text-dim); margin-left: 4px; }
.g-coupons small { color: var(--g-text-dim); display: block; }
.g-progress-label { text-align: right; font-size: 11px; }
.g-bar {
  height: 6px; border-radius: 3px; overflow: hidden; margin-top: 6px;
  width: 150px; max-width: 40vw; background: var(--g-panel-border);
  margin-left: auto;
}
.g-bar > i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--g-accent), var(--g-accent-2));
}

/* Machine stage — canvas physics world */
.g-stage {
  position: relative; display: flex; justify-content: center;
  margin-bottom: 14px;
}
.g-machine-svg { width: 100%; max-width: 340px; height: auto; overflow: visible; }
/* Canvas gacha machine: rounded "room" card, crisp on devicePixelRatio. */
.g-machine-canvas {
  width: 100%; max-width: 360px; height: auto; display: block;
  border-radius: 20px;
  border: 1px solid var(--g-panel-border);
  background: var(--g-bg);
  cursor: grab;
  touch-action: none;
  box-shadow: 0 10px 40px rgba(0,0,0,0.28);
}
.g-machine-canvas:active { cursor: grabbing; }
.g-machine-canvas.is-cranking { cursor: default; }
/* drag-the-crank affordance line */
.g-crank-drag-hint {
  text-align: center; font-size: 11px; color: var(--g-text-dim);
  margin: -6px 0 12px; letter-spacing: 1px; min-height: 1em; opacity: 0.85;
}

/* Crank button */
.g-crank-btn {
  display: block; width: 100%; padding: 16px; border: none; border-radius: 14px;
  font-size: 18px; font-weight: 800; letter-spacing: 2.5px; cursor: pointer;
  text-transform: uppercase; margin-bottom: 16px;
}
.g-crank-btn:disabled { cursor: not-allowed; filter: grayscale(0.75) opacity(0.6); }
.g-crank-hint {
  text-align: center; font-size: 12px; color: var(--g-warn);
  margin: -8px 0 16px; min-height: 1em;
}

/* Reveal digit cards */
.g-reveal {
  display: flex; justify-content: center; gap: 10px;
  min-height: 86px; margin-bottom: 20px; perspective: 700px;
}
.g-digit {
  width: 56px; height: 76px; border-radius: 10px;
  background: var(--g-digit-bg);
  border: 1.5px solid var(--g-accent-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 800; color: var(--g-accent-2);
  opacity: 0;
}

/* CTA countdown banner */
.g-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--g-win); border-radius: 14px; padding: 14px 16px;
  margin-bottom: 22px; cursor: pointer; background: var(--g-panel);
}
.g-cta .g-label {
  font-size: 11px; letter-spacing: 2px; color: var(--g-win); text-transform: uppercase;
}
.g-cta .g-timer {
  font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--g-win);
}
.g-cta .g-timer .g-tick { display: inline-block; }
.g-cta .g-go {
  background: var(--g-win); color: var(--g-claim-text); font-weight: 800; border: none;
  border-radius: 10px; padding: 10px 14px; font-size: 12px; letter-spacing: 1px;
  cursor: pointer; white-space: nowrap;
}
.g-cta.g-locked { cursor: default; opacity: 0.85; }
.g-cta.g-locked .g-go { display: none; }

/* Tickets */
.g-section-title {
  font-size: 14px; letter-spacing: 3px; color: var(--g-text-dim);
  text-transform: uppercase; margin: 4px 0 10px;
}
.g-draw-group { margin-bottom: 18px; }
.g-draw-heading {
  font-size: 12px; color: var(--g-text-dim); margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.g-draw-heading .g-winning-digits { color: var(--g-win); font-weight: 700; letter-spacing: 2px; }

.g-ticket {
  background: var(--g-panel); border: 1px solid var(--g-panel-border); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.g-ticket .g-nums { display: flex; gap: 6px; }
.g-ticket .g-chip {
  display: inline-flex; width: 32px; height: 42px; border-radius: 8px;
  background: var(--g-digit-bg); border: 1px solid var(--g-panel-border);
  align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
  color: var(--g-text);
}
.g-ticket .g-meta { text-align: right; font-size: 11px; color: var(--g-text-dim); line-height: 1.5; }
.g-ticket.g-won {
  border-color: var(--g-win);
}
.g-ticket.g-won .g-chip.g-hit {
  background: var(--g-win); color: var(--g-claim-text); border-color: var(--g-win);
}
.g-ticket.g-won .g-meta b { color: var(--g-win); font-size: 13px; }
.g-ticket.g-lost { opacity: 0.5; }
.g-ticket.g-pending { opacity: 0.92; }

.g-claim-btn {
  background: var(--g-claim-bg); color: var(--g-claim-text); border: none; border-radius: 8px;
  font-weight: 800; padding: 8px 14px; font-size: 12px; cursor: pointer; margin-top: 6px;
}
.g-claim-btn:disabled { opacity: 0.6; cursor: default; }

.g-badge {
  font-size: 10px; letter-spacing: 1px; padding: 3px 8px; border-radius: 99px;
  border: 1px solid var(--g-accent-2); color: var(--g-accent-2); white-space: nowrap;
}

/* Terms accordion */
.g-terms { margin-top: 22px; }
.g-terms details {
  background: var(--g-panel); border: 1px solid var(--g-panel-border); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 8px;
}
.g-terms summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--g-text-dim);
  list-style: none;
}
.g-terms summary::-webkit-details-marker { display: none; }
.g-terms ul { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--g-text-dim); }
.g-terms li { margin-bottom: 4px; }

/* Debug bar spacing (JS controls visibility) */
#gacha-debug-bar { font-family: monospace; }

/* Reduced motion: kill all transitions/animations, keep final states */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
