/* ── Fonts (self-hosted, no CDN) ─────────────────────────────────────────── */
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/cinzel-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/cinzel-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Theme (ported from the bingo app for a matching look) ──────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #1e2530;
  --border:       #30363d;
  --border-lite:  #21272e;
  --text:         #e6edf3;
  --text-muted:   #7d8590;
  --text-dim:     #484f58;
  --accent:       #b88cf0;
  --accent-glow:  rgba(184,140,240,0.35);
  --accent-dim:   rgba(184,140,240,0.12);
  --danger:       #f85149;
  --success:      #3fb950;
  --info:         #58a6ff;
  --gold:         #f0b429;
  --radius:       8px;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-display: 'Cinzel', serif;
  --drawer-width: min(92vw, 520px);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px 48px;
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(90,40,160,0.18) 0%, transparent 70%),
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 60%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 70%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 80%, rgba(255,255,255,0.2) 0%, transparent 100%);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header { text-align: center; margin-bottom: 24px; }
.site-header h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 36px); font-weight: 700; letter-spacing: 0.06em;
  background: linear-gradient(135deg, #b88cf0 0%, #e0aaff 50%, #7ec8f8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 14px rgba(180,130,255,0.5));
  line-height: 1.2; margin-bottom: 4px;
}
.site-header .subtitle { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.logout-link {
  display: inline-block; margin-top: 8px; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim); text-decoration: none;
  border-bottom: 1px dotted var(--text-dim); transition: color 0.15s, border-color 0.15s;
}
.logout-link:hover { color: var(--text-muted); border-color: var(--text-muted); }

/* ── Login (manage gate) ──────────────────────────────────────────────────── */
.login-stage { display: flex; align-items: center; justify-content: center; min-height: 70vh; width: 100%; }
.login-card {
  background: var(--surface); border: 1px solid var(--accent); border-radius: 16px;
  padding: 36px 32px; width: min(92vw, 360px); text-align: center;
  box-shadow: 0 0 50px var(--accent-glow), 0 20px 60px rgba(0,0,0,0.6);
}
.login-card h2 {
  font-family: var(--font-display); font-size: 18px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.login-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input[type=password], .login-card input[type=text] { text-align: center; }
.login-error { margin-top: 14px; font-size: 12px; color: var(--danger); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.main-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Manage drawer (popout panel) ─────────────────────────────────────────── */
.manage-tab {
  position: fixed; top: 50%; right: 0; transform: translateY(-50%);
  background: var(--surface); border: 1px solid var(--border); border-right: none;
  border-radius: 8px 0 0 8px; padding: 20px 10px;
  cursor: pointer; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  transition: right 0.3s ease;
  box-shadow: -4px 0 16px rgba(0,0,0,0.35);
}
.manage-tab:hover { background: var(--surface2); }
.manage-tab span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent);
}

.manage-backdrop {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(13,17,23,0.6);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.manage-backdrop.open { opacity: 1; pointer-events: auto; }

.manage-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; z-index: 80;
  width: var(--drawer-width);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 24px 18px 40px;
}
.manage-drawer.open { transform: translateX(0); }
.manage-tab.open { right: var(--drawer-width); }

.manage-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.manage-drawer-header h2 {
  font-family: var(--font-display); font-size: 15px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
}
.manage-close-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px; transition: color 0.15s;
}
.manage-close-btn:hover { color: var(--text); }

/* ── History (modal, left-edge tab) ──────────────────────────────────────────── */
.history-tab {
  position: fixed; top: 50%; left: 0; transform: translateY(-50%);
  background: var(--surface); border: 1px solid var(--border); border-left: none;
  border-radius: 0 8px 8px 0; padding: 20px 10px;
  cursor: pointer; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 0 16px rgba(0,0,0,0.35);
}
/* Shifts up to make room once the Stats tab joins it below (see .stats-tab.visible) */
.history-tab.paired { transform: translateY(calc(-50% - 60px)); }
.history-tab:hover { background: var(--surface2); }
.history-tab span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent);
}

/* ── Stats (modal, left-edge tab stacked below History — V3) ────────────────── */
.stats-tab {
  position: fixed; top: 50%; left: 0; transform: translateY(calc(-50% + 60px));
  background: var(--surface); border: 1px solid var(--border); border-left: none;
  border-radius: 0 8px 8px 0; padding: 20px 10px;
  cursor: pointer; z-index: 90;
  display: none; align-items: center; justify-content: center;
  box-shadow: 4px 0 16px rgba(0,0,0,0.35);
}
.stats-tab.visible { display: flex; }
.stats-tab:hover { background: var(--surface2); }
.stats-tab span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent);
}

.stats-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 68vh; overflow-y: auto; }
.stats-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  font-size: 15px; background: var(--bg);
  border: 1px solid var(--border-lite); border-radius: 8px; padding: 10px 14px;
}
.stats-list li .stat-label { color: var(--text-muted); min-width: 0; }
.stats-list li .stat-figure {
  color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 16px;
  flex-shrink: 0; text-align: right; white-space: nowrap;
}

.history-modal-backdrop {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(13,17,23,0.75);
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.history-modal-backdrop.open { opacity: 1; pointer-events: auto; }

.history-modal {
  position: fixed; inset: 0; z-index: 96;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.history-modal.open { opacity: 1; pointer-events: auto; }

.history-modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 32px 28px 28px;
  width: min(94vw, 680px);
  box-shadow: 0 0 50px var(--accent-glow), 0 20px 60px rgba(0,0,0,0.6);
}
.history-modal.open .history-modal-card { animation: winner-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.history-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.history-modal-header h2 {
  font-family: var(--font-display); font-size: 18px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
}
.history-modal-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px; transition: color 0.15s;
}
.history-modal-close:hover { color: var(--text); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.panel + .panel { margin-top: 16px; }
.panel h2 {
  font-family: var(--font-display); font-size: 13px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}

/* ── Slice input list ─────────────────────────────────────────────────────── */
.slice-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.slice-form input[type=text] { flex: 1; min-width: 140px; }
.slice-form input[type=number] { width: 80px; }
.slice-form select#slice-class-input { width: 160px; }

input[type=text], input[type=password], input[type=number], select {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px;
  padding: 9px 12px; outline: none; font-family: var(--font-body);
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }

.slice-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.slice-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border-lite);
  border-radius: 6px; padding: 6px 8px;
}
.slice-row .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.slice-row .slice-name { flex: 1; min-width: 0; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slice-row input[type=number] { width: 68px; padding: 5px 8px; font-size: 12px; flex-shrink: 0; }
.slice-row .slice-class-select { width: 148px; padding: 5px 6px; font-size: 12px; flex-shrink: 0; }
.slice-row .pct { font-size: 11px; color: var(--text-muted); width: 40px; text-align: right; }
.slice-row .remove-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 4px; transition: color 0.15s;
}
.slice-row .remove-btn:hover { color: var(--danger); }
.slice-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 12px 0; }

/* ── Stats drawer editor (V3) ────────────────────────────────────────────────── */
.stat-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.stat-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border-lite);
  border-radius: 6px; padding: 6px 8px;
}
.stat-row .stat-desc-input { flex: 1; min-width: 0; font-size: 13px; padding: 6px 8px; }
.stat-row .stat-value-input { width: 110px; flex-shrink: 0; font-size: 12px; padding: 6px 8px; }
.stat-row .stat-value-input:disabled { color: var(--text-muted); background: var(--surface2); cursor: not-allowed; }
.stat-row .remove-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 4px; transition: color 0.15s; flex-shrink: 0;
}
.stat-row .remove-btn:hover { color: var(--danger); }
.stat-row .remove-btn:disabled { visibility: hidden; cursor: default; }

.panel-footer-note { font-size: 11px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.toggle-row span { font-size: 13px; color: var(--text); }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 22px;
  cursor: pointer; transition: background 0.15s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: var(--text-muted); border-radius: 50%; transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .slider { background: var(--accent-dim); border: 1px solid var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }

/* ── Presets bar ──────────────────────────────────────────────────────────── */
.presets-row { display: flex; gap: 8px; flex-wrap: wrap; }
.presets-row select { flex: 1; min-width: 120px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 9px 18px; border-radius: 5px;
  border: 1px solid var(--accent); background: rgba(184,140,240,0.1); color: var(--accent);
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { background: rgba(184,140,240,0.2); box-shadow: 0 0 12px rgba(184,140,240,0.3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.muted { border-color: var(--text-dim); background: rgba(255,255,255,0.04); color: var(--text-dim); }
.btn.muted:hover { border-color: var(--text-muted); background: rgba(255,255,255,0.07); color: var(--text-muted); box-shadow: none; }
.btn.danger { border-color: var(--danger); background: rgba(248,81,73,0.1); color: var(--danger); }
.btn.danger:hover { background: rgba(248,81,73,0.22); box-shadow: 0 0 12px rgba(248,81,73,0.3); }
.btn.success { border-color: var(--success); background: rgba(63,185,80,0.1); color: var(--success); }
.btn.success:hover { background: rgba(63,185,80,0.22); box-shadow: 0 0 12px rgba(63,185,80,0.3); }
.btn.info { border-color: var(--info); background: rgba(88,166,255,0.1); color: var(--info); }
.btn.info:hover { background: rgba(88,166,255,0.22); box-shadow: 0 0 12px rgba(88,166,255,0.3); }
.btn.small { padding: 7px 12px; font-size: 10px; }

/* ── Wheel ────────────────────────────────────────────────────────────────── */
.wheel-panel { display: flex; flex-direction: column; align-items: center; gap: 18px; }

.wheel-stage {
  position: relative;
  width: min(90vw, 70vh, 760px);
  aspect-ratio: 1 / 1;
}

.wheel-pointer {
  position: absolute;
  top: -4px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 28px solid var(--accent);
  filter:
    drop-shadow(0 0 2px #f0e3ff)
    drop-shadow(0 0 5px rgba(224,170,255,0.9))
    drop-shadow(0 0 12px var(--accent-glow))
    drop-shadow(0 0 22px rgba(184,140,240,0.4));
  z-index: 5;
}

canvas#wheel-canvas {
  width: 100%; height: 100%; display: block; border-radius: 50%;
  box-shadow: 0 0 0 6px var(--surface), 0 0 0 8px var(--border), 0 8px 40px rgba(0,0,0,0.6);
}

canvas#confetti-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 260;
}

.spin-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) translateZ(0);
  width: 22%; height: 22%; min-width: 64px; min-height: 64px;
  border-radius: 50%; z-index: 6;
  background: var(--surface2);
  border: 3px solid #e0c8ff;
  box-shadow:
    0 0 3px #f0e3ff,
    0 0 8px rgba(224,170,255,0.9),
    0 0 20px var(--accent-glow),
    0 0 40px rgba(184,140,240,0.3),
    inset 0 0 8px rgba(224,170,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(24px, 5vw, 36px);
  cursor: pointer;
  transition: box-shadow 0.15s;
  overflow: hidden;
  backface-visibility: hidden;
}
.spin-btn:hover:not(:disabled) {
  box-shadow:
    0 0 4px #f0e3ff,
    0 0 10px rgba(224,170,255,0.95),
    0 0 28px var(--accent-glow),
    0 0 55px rgba(184,140,240,0.35),
    inset 0 0 10px rgba(224,170,255,0.25);
}
.spin-btn:disabled { cursor: default; }
.spin-btn.hidden { display: none; }
.spin-btn.static { cursor: default; }
.spin-btn.static:hover { box-shadow:
    0 0 3px #f0e3ff,
    0 0 8px rgba(224,170,255,0.9),
    0 0 20px var(--accent-glow),
    0 0 40px rgba(184,140,240,0.3),
    inset 0 0 8px rgba(224,170,255,0.2);
}
.spin-btn .snake-face {
  display: inline-block;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Winner overlay ───────────────────────────────────────────────────────── */
.winner-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.winner-overlay.visible { opacity: 1; pointer-events: auto; }

.winner-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 44px 36px 36px;
  width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 0 60px var(--accent-glow), 0 20px 60px rgba(0,0,0,0.6);
}
.winner-overlay.visible .winner-card { animation: winner-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes winner-pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }

.winner-card .trophy { font-size: 44px; margin-bottom: 10px; filter: drop-shadow(0 0 14px rgba(240,180,41,0.5)); }
.winner-card .close-btn,
.winner-close-btn {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px; transition: color 0.15s;
}
.winner-close-btn:hover { color: var(--text); }
.winner-close-btn.hidden { display: none; }

.winner-word {
  font-family: var(--font-display); font-size: clamp(28px, 8vw, 44px); font-weight: 700; letter-spacing: 0.06em;
  background: linear-gradient(135deg, #c8a0ff 0%, #ffffff 40%, #f0b429 80%, #e06aff 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 24px rgba(184,140,240,0.8)); line-height: 1.2; display: block;
}
.winner-subtext { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-top: 6px; }

/* ── Lucky Dip ────────────────────────────────────────────────────────────── */
.lucky-dip-row { display: none; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.lucky-dip-row.visible { display: flex; }
.lucky-dip-box {
  width: clamp(64px, 20vw, 92px); height: clamp(64px, 20vw, 92px);
  border-radius: 14px; background: var(--surface2); border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 16px var(--accent-glow);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  padding: 6px; text-align: center;
}
.lucky-dip-box .gift-icon { font-size: clamp(28px, 8vw, 40px); line-height: 1; }
.lucky-dip-box:hover:not(.revealed):not(.static):not(.shaking) { transform: translateY(-3px) scale(1.05); box-shadow: 0 0 26px var(--accent-glow); }
.lucky-dip-box.static { cursor: default; }
.lucky-dip-row.locked .lucky-dip-box { cursor: default; pointer-events: none; }

.lucky-dip-box.shaking { animation: lucky-dip-shake 0.5s ease both; }
@keyframes lucky-dip-shake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  15%  { transform: rotate(-10deg) scale(1.05); }
  30%  { transform: rotate(9deg) scale(1.05); }
  45%  { transform: rotate(-8deg) scale(1.08); }
  60%  { transform: rotate(7deg) scale(1.1); }
  75%  { transform: rotate(-5deg) scale(1.08); }
  90%  { transform: rotate(3deg) scale(1.02); }
}

.lucky-dip-box.revealed {
  cursor: default; background: var(--surface); border-color: var(--accent);
  font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text); line-height: 1.3; word-break: break-word;
  animation: lucky-dip-reveal 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes lucky-dip-reveal { from { transform: scale(0.7) rotateY(90deg); opacity: 0.4; } to { transform: scale(1) rotateY(0); opacity: 1; } }

.lucky-dip-box.revealed.selected {
  border-color: #3ddc71;
  box-shadow: 0 0 28px 6px rgba(61,220,113,0.7), 0 0 0 2px rgba(61,220,113,0.4) inset;
}
.lucky-dip-box.revealed.other {
  border-color: #ffa028;
  box-shadow: 0 0 28px 6px rgba(255,160,40,0.7), 0 0 0 2px rgba(255,160,40,0.4) inset;
}

/* ── History ──────────────────────────────────────────────────────────────── */
.history-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 68vh; overflow-y: auto; }
.history-list li {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 15px; color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border-lite); border-radius: 8px; padding: 10px 14px;
}
.history-list li .h-top { display: flex; justify-content: space-between; align-items: center; }
.history-list li .h-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.history-list li .h-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.history-list li .h-name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.history-list li .h-num { color: #7ec4ff; font-family: var(--font-display); font-size: 12px; flex-shrink: 0; margin-left: 10px; }
.history-list li .h-prize {
  font-size: 13px; color: var(--text); background: var(--surface2);
  border: 1px solid var(--accent); border-radius: 6px; padding: 3px 9px;
  flex-shrink: 0; margin-left: 14px;
}

/* ── Controls row ─────────────────────────────────────────────────────────── */
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }

.footer-note { margin-top: 24px; font-size: 11px; letter-spacing: 0.04em; text-align: center; color: var(--text-muted); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface); border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 18px; font-size: 13px; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 300; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--danger); }
