
:root {
  --bg: #0f0f1a;
  --card-bg: #1a1a2e;
  --card-border: #2a2a4a;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --primary: #7c6aff;
  --primary-light: #a393ff;
  --accent: #ff6b9d;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --success: #22d3a0;
  --danger: #ff4d6d;
  --warning: #fbbf24;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Nav ─────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(26,26,46,0.95);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--card-border);
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
}
.nav-brand-icon {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
}
.nav-brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; gap: 1rem; align-items: center; }
.nav-links a {
  color: var(--text-muted); text-decoration: none;
  font-size: .9rem; transition: color .2s;
}
.nav-links a:hover { color: var(--text); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.4rem; border-radius: 12px; border: none;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  transition: all .2s; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #5b4de8);
  color: #fff;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(124,106,255,.5); }
.btn-accent {
  background: linear-gradient(135deg, var(--accent), #e0456a);
  color: #fff;
}
.btn-outline {
  background: transparent; border: 1px solid var(--card-border); color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #000; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4rem .9rem; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Container ───────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Section ─────────────────────────────────────────── */
section { padding: 3rem 0; }

/* ── Badge ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .25rem .65rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-member { background: rgba(124,106,255,.2); color: var(--primary-light); border: 1px solid var(--primary); }
.badge-draft { background: rgba(255,107,157,.2); color: var(--accent); }

/* ── Flash messages ──────────────────────────────────── */
.flash-container { position: fixed; top: 5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.flash {
  padding: .75rem 1.25rem; border-radius: 12px; font-size: .9rem;
  animation: slideIn .3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.flash-success { background: rgba(34,211,160,.15); border: 1px solid var(--success); color: var(--success); }
.flash-error { background: rgba(255,77,109,.15); border: 1px solid var(--danger); color: var(--danger); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Color Palette ───────────────────────────────────── */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: .75rem; }
.color-chip {
  aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .25rem;
  font-size: .75rem; font-weight: 700; cursor: default;
  border: 2px solid transparent; transition: transform .2s;
  position: relative;
}
.color-chip:hover { transform: scale(1.05); }
.color-chip.owned { border-color: rgba(255,255,255,.3); }
.color-chip.empty { opacity: .25; filter: grayscale(1); }
.color-chip.hidden-special {
  opacity: .75;
  filter: none;
  border: 1px dashed rgba(255,255,255,.28);
  background-image: radial-gradient(circle at 30% 25%, rgba(255,255,255,.12), transparent 55%);
  letter-spacing: .08em;
}
.color-chip.special-silver,
.result-color-display.special-silver {
  background: linear-gradient(120deg, #777d87 0%, #f8fbff 22%, #aeb5bf 42%, #fff 52%, #858c96 72%, #e7ebf0 100%) !important;
  background-size: 220% 100% !important;
  color: #292d34 !important;
  border-color: #f3f6fa;
  text-shadow: 0 1px 1px rgba(255,255,255,.65);
  animation: silverShine 3s ease-in-out infinite;
}
.color-chip.special-gold,
.result-color-display.special-gold {
  background: linear-gradient(120deg, #8d6410 0%, #ffe98b 22%, #c99418 42%, #fff4bd 52%, #a87508 72%, #f9d65e 100%) !important;
  background-size: 220% 100% !important;
  color: #3a2800 !important;
  border-color: #ffe98b;
  text-shadow: 0 1px 1px rgba(255,255,255,.55);
  animation: goldShine 2.6s ease-in-out infinite;
}
@keyframes silverShine { 50% { background-position: 100% 0; box-shadow: 0 0 18px rgba(220,230,245,.55); } }
@keyframes goldShine { 50% { background-position: 100% 0; box-shadow: 0 0 22px rgba(255,215,0,.65); } }
@media (prefers-reduced-motion: reduce) {
  .color-chip.special-silver,
  .color-chip.special-gold,
  .result-color-display.special-silver,
  .result-color-display.special-gold {
    animation: none;
  }
}
.color-chip .count {
  position: absolute; top: -6px; right: -6px;
  background: var(--primary); color: #fff;
  border-radius: 999px; padding: 1px 6px; font-size: .7rem;
}

/* ── Draw Button ─────────────────────────────────────── */
.draw-area { text-align: center; }
.draw-btn {
  width: 160px; height: 160px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none; cursor: pointer; font-size: 1.1rem; font-weight: 700;
  color: #fff; transition: all .3s;
  box-shadow: 0 0 30px rgba(124,106,255,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto;
}
.draw-btn:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 0 50px rgba(124,106,255,.6); }
.draw-btn:active:not(:disabled) { transform: scale(.97); }
.draw-btn:disabled { opacity: .4; cursor: not-allowed; }
.draw-btn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) scale(1.05); } }

/* ── Draw Result ─────────────────────────────────────── */
.result-popup {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.result-card {
  background: var(--card-bg); border-radius: 24px; padding: 3rem 2.5rem;
  text-align: center; max-width: 360px; width: 90%;
  border: 1px solid var(--card-border); animation: popIn .3s cubic-bezier(.34,1.56,.64,1);
}
.result-card.special-silver { border-color: #dce3ec; box-shadow: 0 0 36px rgba(205,218,235,.28); }
.result-card.special-gold { border-color: #ffdf65; box-shadow: 0 0 42px rgba(255,215,0,.32); }
.result-card.special-transgender {
  border-color: #74d7ee;
  box-shadow: 0 0 40px rgba(116, 215, 238, 0.45), 0 0 80px rgba(255, 177, 200, 0.25);
  animation: transgenderPop 0.4s cubic-bezier(.34,1.56,.64,1);
}
.result-card.special-rainbow {
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 50px rgba(228,3,3,0.35), 0 0 80px rgba(115,41,130,0.35);
  background: linear-gradient(135deg, rgba(26,26,46,0.95), rgba(40,25,50,0.95));
}

@keyframes transgenderPop {
  0% { transform: scale(0.75); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.result-color-display {
  width: 120px; height: 120px; border-radius: 50%;
  margin: 1rem auto; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 900;
  box-shadow: 0 0 40px rgba(255,255,255,.2);
}
.result-color-display.special-transgender {
  background: linear-gradient(180deg, #74d7ee 0%, #74d7ee 20%, #ffb1c8 20%, #ffb1c8 40%, #ffffff 40%, #ffffff 60%, #ffb1c8 60%, #ffb1c8 80%, #74d7ee 80%, #74d7ee 100%) !important;
  color: #1a1a2e !important;
  font-size: 3rem;
  box-shadow: 0 0 35px rgba(116,215,238,0.7);
}
.result-color-display.special-rainbow {
  background: linear-gradient(180deg, #e40303 0%, #e40303 16.6%, #ff8c00 16.6%, #ff8c00 33.3%, #ffed00 33.3%, #ffed00 50%, #008026 50%, #008026 66.6%, #24408e 66.6%, #24408e 83.3%, #732982 83.3%, #732982 100%) !important;
  color: #ffffff !important;
  font-size: 3rem;
  box-shadow: 0 0 40px rgba(255,237,0,0.6);
  animation: rainbowSpin 8s linear infinite;
}
@keyframes rainbowSpin {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ── 進步驕傲旗拼圖展台 ─────────────────────────────── */
.pride-puzzle-stage {
  background: linear-gradient(135deg, rgba(26,26,46,0.9), rgba(18,18,32,0.95));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}
.pride-puzzle-stage.all-completed {
  border-color: rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 40px rgba(124, 106, 255, 0.3), 0 0 70px rgba(255, 107, 157, 0.25);
}
.pride-puzzle-stage.all-completed::before {
  content: '';
  position: absolute; inset: -2px;
  background: linear-gradient(90deg, #e40303, #ff8c00, #ffed00, #008026, #24408e, #732982, #74d7ee, #ffb1c8, #ffffff, #613915, #1a1a1a, #e40303);
  background-size: 300% 100%;
  border-radius: calc(var(--radius) + 2px);
  z-index: -1;
  animation: prideBorder 8s linear infinite;
  opacity: 0.8;
}
@keyframes prideBorder {
  0% { background-position: 0% 0%; }
  100% { background-position: 300% 0%; }
}

.pride-flag-wrapper {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 1.25rem auto 1.5rem;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.5));
}
.pride-flag-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  background: #12121e;
}

.flag-part {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  stroke-width: 1.5;
}
.flag-part.unowned {
  opacity: 0.18;
  filter: grayscale(90%) brightness(0.5);
  stroke: rgba(255,255,255,0.2);
  stroke-dasharray: 4 3;
}
.flag-part.owned {
  opacity: 1;
  stroke: rgba(255,255,255,0.35);
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.35));
}
.flag-part:hover {
  filter: brightness(1.22) drop-shadow(0 0 10px rgba(255,255,255,0.6));
  stroke: #ffffff;
  stroke-width: 2.5;
}

.flag-complete-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(255,215,0,0.18), rgba(255,107,157,0.18));
  border: 1px solid rgba(255,215,0,0.5);
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  margin-top: 1rem;
  color: #fff;
  font-weight: 700;
  text-align: center;
  animation: bannerGlow 3s ease-in-out infinite alternate;
}
@keyframes bannerGlow {
  0% { box-shadow: 0 0 15px rgba(255,215,0,0.2); }
  100% { box-shadow: 0 0 28px rgba(255,215,0,0.45); }
}

.flag-tooltip-box {
  background: rgba(15,15,26,0.92);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Tables ──────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--card-border); font-size: .9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Form ────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
input, select, textarea {
  width: 100%; background: rgba(255,255,255,.05);
  border: 1px solid var(--card-border); border-radius: 10px;
  color: var(--text); padding: .65rem 1rem; font-size: .95rem;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,106,255,.15);
}
select {
  color-scheme: dark;
  background-color: var(--card-bg);
  color: var(--text);
}
select option {
  background-color: #171727;
  color: var(--text);
}
select option:checked {
  background-color: #4f46a5;
  color: #fff;
}
.event-picker-label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
.event-picker { position: relative; }
.event-picker > summary {
  width: 100%;
  list-style: none;
  cursor: pointer;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
  padding: .65rem 2.5rem .65rem 1rem;
  font-size: .92rem;
  position: relative;
}
.event-picker > summary::-webkit-details-marker { display: none; }
.event-picker > summary::after {
  content: "▾";
  position: absolute;
  right: 1rem;
  color: var(--primary-light);
}
.event-picker[open] > summary {
  border-color: var(--primary);
  border-radius: 10px 10px 0 0;
}
.event-picker-options {
  position: absolute;
  z-index: 220;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #171727;
  border: 1px solid var(--primary);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.55);
}
.event-picker-option {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  width: 100%;
  padding: .7rem .9rem;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.event-picker-option:last-child { border-bottom: 0; }
.event-picker-option:hover,
.event-picker-option:focus-visible,
.event-picker-option[aria-selected="true"] {
  outline: none;
  background: rgba(124,106,255,.2);
}
.event-picker-option span { color: var(--text-muted); font-size: .78rem; }
textarea { resize: vertical; min-height: 100px; }

/* ── Hero ────────────────────────────────────────────── */
.hero {
  min-height: 85vh; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 4rem 2rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,106,255,.15) 0%, transparent 70%);
}
.hero-icon {
  display: block;
  width: clamp(5rem, 14vw, 8rem);
  height: auto;
  margin: 0 auto 1.25rem;
}
.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem); font-weight: 900; line-height: 1.1;
  background: linear-gradient(135deg, #fff 30%, var(--primary-light) 60%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 1.25rem;
}
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 500px; margin: 0 auto 2.5rem; }

/* ── Ticket counter ──────────────────────────────────── */
.ticket-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(124,106,255,.15); border: 1px solid var(--primary);
  border-radius: 999px; padding: .4rem 1rem; font-size: 1rem; font-weight: 700;
  color: var(--primary-light);
}

/* ── Progress bar ────────────────────────────────────── */
.tier-progress { margin: .5rem 0; }
.tier-bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; }
.tier-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .5s; }

/* ── Sidebar layout ──────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 65px); }
.sidebar {
  width: 240px; background: var(--card-bg); border-right: 1px solid var(--card-border);
  padding: 1.5rem 1rem; flex-shrink: 0;
}
.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem; border-radius: 10px; color: var(--text-muted);
  text-decoration: none; font-size: .9rem; margin-bottom: .25rem;
  transition: all .2s;
}
.sidebar-link:hover, .sidebar-link.active { background: rgba(124,106,255,.15); color: var(--primary-light); }
.admin-content { flex: 1; padding: 2rem; overflow-x: auto; }

/* ── Stat cards ──────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 1.25rem; }
.stat-card .label { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary-light); }

@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--card-border); }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
}
