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

:root {
  --gold: #f0b90b;
  --gold2: #f7931e;
  --gold-dim: #a68a40;
  --text: #f0ece4;
  --text2: #a09888;
  --card: rgba(22, 20, 34, 0.75);
  --card-border: rgba(240, 185, 11, 0.12);
  --input-bg: rgba(16, 14, 24, 0.6);
  --input-border: rgba(240, 185, 11, 0.2);
  --danger: #ff6b6b;
  --success: #4ade80;
  --radius: 20px;
  --radius-sm: 12px;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
  background: #0a0a14;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* subtle animated bg orbs */
body::before {
  content: ''; position: fixed; top: -40%; left: -20%;
  width: 140vw; height: 140vh;
  background: radial-gradient(ellipse at 30% 20%, rgba(240,185,11,0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 60%, rgba(247,147,30,0.05) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(240,185,11,0.04) 0%, transparent 40%);
  pointer-events: none; z-index: 0;
}

/* ===== SHARED ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 28px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #1a1608; box-shadow: 0 4px 20px rgba(240,185,11,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(240,185,11,0.5); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; filter: grayscale(0.5); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 16px rgba(255,107,107,0.3); }
.btn-danger:hover { box-shadow: 0 6px 22px rgba(255,107,107,0.45); }

.btn-sm {
  padding: 6px 16px; font-size: 13px; border-radius: 8px;
  background: transparent; border: 1px solid var(--card-border); color: var(--text2);
  cursor: pointer; transition: all 0.2s;
}
.btn-sm:hover { border-color: var(--gold-dim); color: var(--text); background: rgba(240,185,11,0.06); }
.btn-ghost {
  background: transparent; border: none; color: var(--text2);
  cursor: pointer; font-size: 14px; padding: 6px 10px; border-radius: 8px; transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text); background: rgba(240,185,11,0.08); }

input, select {
  padding: 10px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); font-size: 15px;
  outline: none; transition: border 0.2s, box-shadow 0.2s; width: 100%;
}
input:focus, select:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240,185,11,0.1);
}
::placeholder { color: #5a5040; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; border: 1px solid var(--card-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  position: relative; z-index: 1;
}

.glass { background: var(--card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }

/* ===== LOGIN ===== */
.login-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; position: relative; z-index: 1;
}
.login-card { width: 100%; max-width: 400px; text-align: center; }
.login-card .icon { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; background: linear-gradient(135deg, var(--gold), var(--gold2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-card .sub { font-size: 14px; color: var(--text2); margin-bottom: 24px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.login-card .btn { width: 100%; }
.login-card .error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 20px; }
.login-card .link { margin-top: 20px; font-size: 13px; color: var(--text2); }
.login-card .link a { color: var(--gold); text-decoration: none; }
.login-card .link a:hover { text-decoration: underline; }

/* ===== LAYOUT ===== */
.container { max-width: 860px; margin: 0 auto; padding: 20px; position: relative; z-index: 1; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.toolbar h1 {
  font-size: 24px; background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.user-bar { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user-bar .badge {
  font-size: 11px; padding: 3px 10px; border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1a1608;
  font-weight: 700; letter-spacing: 0.5px;
}
.user-bar .badge.admin { background: linear-gradient(135deg, #a855f7, #7c3aed); color: #fff; }

/* ===== LEVEL CARD ===== */
.level-card {
  margin-bottom: 20px; padding: 18px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.level-icon { font-size: 36px; flex-shrink: 0; }
.level-info { flex: 1; min-width: 180px; }
.level-info .lv-name { font-size: 17px; font-weight: 700; color: var(--gold); }
.level-info .lv-title { font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.level-bar-wrap {
  height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px;
  overflow: hidden; margin-bottom: 4px;
}
.level-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(240,185,11,0.4);
}
.level-info .lv-stats { font-size: 12px; color: var(--text2); }
.level-perks { display: flex; gap: 8px; flex-wrap: wrap; }
.level-perks .perk {
  font-size: 12px; padding: 4px 10px; border-radius: 8px;
  background: rgba(240,185,11,0.1); color: var(--gold-dim);
  border: 1px solid rgba(240,185,11,0.15);
}
.level-perks .perk.active { background: rgba(240,185,11,0.18); color: var(--gold); border-color: rgba(240,185,11,0.3); }

/* ===== WHEEL ===== */
.wheel-section {
  display: flex; gap: 24px; align-items: center; justify-content: center;
  margin-bottom: 24px; flex-wrap: wrap;
}
.wheel-box {
  position: relative; display: inline-block; flex-shrink: 0;
}
.wheel-box .pointer {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 10;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 32px solid var(--gold);
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6)) drop-shadow(0 0 8px rgba(240,185,11,0.4));
}
#wheel {
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(240,185,11,0.15), 0 0 80px rgba(240,185,11,0.05);
}
.wheel-actions {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 140px;
}
.wheel-actions .btn-primary { font-size: 18px; padding: 14px 36px; border-radius: 16px; }
.result-box {
  text-align: center; min-height: 44px; font-size: 22px; font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.result-box.flash {
  animation: resultPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes resultPop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* quick mode toggle */
.quick-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2);
}
.quick-toggle input[type="checkbox"] { width: auto; accent-color: var(--gold); }

/* lucky pick select */
.lucky-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }
.lucky-pick select { width: auto; padding: 4px 8px; font-size: 13px; }

/* color picker */
.color-picker {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.color-picker .swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.2s;
}
.color-picker .swatch:hover, .color-picker .swatch.active { border-color: var(--gold); transform: scale(1.15); }

/* ===== DISH SECTION ===== */
.dish-section h2 { font-size: 16px; color: var(--text2); margin-bottom: 12px; font-weight: 500; }
.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row input { flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px; background: rgba(240,185,11,0.08); border-radius: 20px;
  font-size: 14px; border: 1px solid rgba(240,185,11,0.12);
  transition: all 0.2s;
}
.tag:hover { background: rgba(240,185,11,0.14); border-color: rgba(240,185,11,0.25); }
.tag .del {
  cursor: pointer; color: var(--danger); font-size: 18px; line-height: 1;
  transition: all 0.2s; opacity: 0.7;
}
.tag .del:hover { opacity: 1; transform: scale(1.2); }

/* ===== ADMIN ===== */
.admin-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.admin-grid .card h2 {
  font-size: 16px; margin-bottom: 14px; padding-bottom: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  border-bottom: 1px solid var(--card-border); font-weight: 600;
}
.form-inline { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.form-inline input { flex: 1; min-width: 100px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 10px 8px; color: var(--text2); font-weight: 500;
  border-bottom: 1px solid var(--card-border); white-space: nowrap; font-size: 13px;
}
td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(240,185,11,0.03); }
td .btn-sm { padding: 4px 12px; font-size: 12px; white-space: nowrap; }
.lv-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: rgba(240,185,11,0.15); color: var(--gold);
  font-weight: 600;
}

.history-list { max-height: 260px; overflow-y: auto; }
.history-item {
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.history-item:last-child { border-bottom: none; }
.history-item .time { color: var(--text2); font-size: 12px; white-space: nowrap; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 400px; animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 {
  font-size: 18px; margin-bottom: 20px; color: var(--gold); text-align: center;
}
.modal .form-group { margin-bottom: 14px; }
.modal .form-group label {
  display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px;
}
.modal .form-group .hint { font-size: 12px; color: var(--text2); margin-top: 4px; }
.modal .form-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px;
}
.modal .error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ===== AVATAR ===== */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--gold-dim); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(240,185,11,0.08);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-default { font-size: 18px; line-height: 1; }
.avatar-lg {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--gold); margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: rgba(240,185,11,0.1);
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.avatar-default-lg { font-size: 36px; line-height: 1; }

/* ===== VERSION ===== */
.version {
  text-align: center; padding: 20px 0 8px;
  font-size: 12px; color: rgba(160,152,136,0.4); letter-spacing: 1px;
}

/* ===== CELEBRATION OVERLAY ===== */
.celebrate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); pointer-events: none;
}
.celebrate .msg {
  text-align: center; animation: celebPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes celebPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.celebrate .msg .icon { font-size: 64px; }
.celebrate .msg .title {
  font-size: 28px; font-weight: 800; margin-top: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.celebrate .msg .sub { color: var(--text2); font-size: 15px; margin-top: 4px; }

/* ===== PARTICLES ===== */
.particle {
  position: fixed; pointer-events: none; z-index: 199;
  animation: particleFall 1.5s ease-out forwards;
  font-size: 24px;
}
@keyframes particleFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  .container { padding: 12px; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .wheel-section { flex-direction: column; gap: 16px; }
  .wheel-actions { flex-direction: row; flex-wrap: wrap; }
  .admin-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .login-card { padding: 20px; }
  .level-card { flex-direction: column; align-items: flex-start; }
  .level-perks { justify-content: flex-start; }
  .form-inline { flex-direction: column; }
  .form-inline input { width: 100%; }
}

/* ===== UTILS ===== */
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-center { text-align: center; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
