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

:root {
  --bg: #f4f7fb;
  --bg-2: #eef3fb;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --surface-soft: #f8fbff;
  --border: #dbe3ef;
  --border-strong: #c7d2e3;
  --text: #152033;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #3f5efb;
  --primary-2: #14b8a6;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --radius-sm: 12px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fbff 0%, #eef3fb 58%, #f5f7fb 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(63, 94, 251, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 184, 166, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 88%);
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 18px 32px;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  flex: 0 0 auto;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.brand-mark.brand-mark-lg {
  width: 72px;
  height: 72px;
  border-radius: 22px;
}

.toolbar-copy,
.login-copy {
  min-width: 0;
}

.toolbar h1,
.login-card h1,
.admin-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
  color: var(--text);
}

.toolbar h1 {
  font-size: 22px;
  font-weight: 800;
}

.page-subtitle,
.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  background: linear-gradient(135deg, #fde68a, #fbbf24);
}

.badge.admin {
  color: #fff;
  background: linear-gradient(135deg, #6d28d9, #4338ca);
}

.btn,
.btn-sm,
.btn-ghost {
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  font-weight: 700;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 22px rgba(63, 94, 251, 0.18);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(63, 94, 251, 0.24);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 10px 22px rgba(239, 68, 68, 0.16);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  color: #334155;
  background: #fff;
  border-color: var(--border);
}

.btn-sm:hover,
.btn-ghost:hover {
  border-color: var(--border-strong);
  background: #f8fbff;
}

.btn-ghost {
  min-height: 36px;
  padding: 0 14px;
  color: #334155;
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--border);
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input:focus,
select:focus {
  border-color: rgba(63, 94, 251, 0.5);
  box-shadow: 0 0 0 4px rgba(63, 94, 251, 0.08);
}

::placeholder {
  color: #94a3b8;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  text-align: center;
}

.login-card .brand-mark {
  margin: 0 auto 18px;
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.login-card .btn {
  width: 100%;
}

.login-card .error,
.error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.login-card .link {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.login-card .link a {
  color: var(--primary);
  text-decoration: none;
}

.login-card .link a:hover {
  text-decoration: underline;
}

.version {
  text-align: center;
  padding: 18px 0 8px;
  color: var(--muted-2);
  font-size: 12px;
  letter-spacing: 0.5px;
}

.level-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  margin-bottom: 18px;
  border-left: 5px solid var(--primary);
}

.level-icon {
  font-size: 36px;
}

.level-info {
  min-width: 0;
}

.level-info .lv-name {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.level-info .lv-title,
.lv-stats {
  color: var(--muted);
  font-size: 13px;
}

.level-bar-wrap {
  height: 10px;
  margin: 10px 0 6px;
  border-radius: 999px;
  background: #e8eef7;
  overflow: hidden;
}

.level-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 16px rgba(63, 94, 251, 0.18);
}

.level-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.level-perks .perk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #526277;
  background: #f4f7fc;
  border: 1px solid var(--border);
}

.level-perks .perk.active {
  color: #0f172a;
  background: #edf8f7;
  border-color: rgba(20, 184, 166, 0.24);
}

.wheel-section {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: center;
  padding: 24px;
  margin-bottom: 18px;
}

.wheel-box {
  position: relative;
  justify-self: center;
}

.wheel-box .pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid var(--accent);
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.12));
  z-index: 10;
}

#wheel {
  display: block;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.wheel-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  min-width: 0;
}

.wheel-actions .btn-primary {
  font-size: 16px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 14px;
}

.result-box {
  min-height: 44px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text);
}

.result-box.flash {
  animation: resultPop 0.45s ease;
}

@keyframes resultPop {
  0% {
    transform: scale(0.86);
    opacity: 0.2;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.quick-toggle,
.lucky-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.quick-toggle input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

.lucky-pick select {
  width: auto;
  min-width: 160px;
}

.color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.color-picker .swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.12);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.color-picker .swatch:hover,
.color-picker .swatch.active {
  transform: scale(1.12);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(63, 94, 251, 0.08);
}

.dish-section,
.admin-grid .card {
  padding: 20px 22px;
}

.dish-section h2,
.admin-grid .card h2,
.modal h3 {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
}

.dish-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #f8fbff;
  border: 1px solid var(--border);
  color: #314056;
  font-size: 14px;
}

.tag .del {
  cursor: pointer;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
}

.tag .del:hover {
  transform: scale(1.1);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.admin-grid .card h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.form-inline {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-inline input {
  flex: 1;
  min-width: 140px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f8fbff;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fbff;
}

td .btn-sm {
  padding-inline: 12px;
  min-height: 32px;
}

.lv-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: #0f172a;
  background: #ecfdf5;
  border: 1px solid rgba(16, 185, 129, 0.15);
  font-size: 12px;
  font-weight: 700;
}

.history-list {
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 14px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item .time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
}

.modal {
  width: min(100%, 460px);
  padding: 24px;
  background: var(--surface-strong);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

.modal h3 {
  text-align: center;
  margin-bottom: 18px;
}

.modal .form-group {
  margin-bottom: 14px;
}

.modal .form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal .form-group .hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.modal .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.avatar,
.avatar-lg {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #edf2ff, #ecfeff);
  border: 1px solid rgba(63, 94, 251, 0.14);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.avatar-lg {
  width: 84px;
  height: 84px;
  border-radius: 50%;
}

.avatar img,
.avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-default {
  font-size: 18px;
}

.avatar-default-lg {
  font-size: 36px;
}

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.38);
}

.celebrate .msg {
  padding: 24px 30px;
  text-align: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  animation: celebPop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes celebPop {
  0% {
    transform: scale(0.72);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.celebrate .msg .icon {
  font-size: 54px;
}

.celebrate .msg .title {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
}

.celebrate .msg .sub {
  margin-top: 4px;
}

.particle {
  position: fixed;
  pointer-events: none;
  z-index: 199;
  font-size: 22px;
  animation: particleFall 1.6s ease-out forwards;
}

@keyframes particleFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(540deg);
    opacity: 0;
  }
}

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

@media (max-width: 980px) {
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-bar {
    justify-content: flex-start;
  }

  .wheel-section {
    grid-template-columns: 1fr;
  }

  .wheel-box {
    justify-self: center;
  }

  .wheel-actions {
    align-items: center;
  }

  .level-card {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .level-perks {
    justify-content: flex-start;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 12px;
  }

  .toolbar,
  .card,
  .login-card,
  .modal {
    border-radius: 14px;
  }

  .toolbar h1,
  .login-card h1,
  .admin-title {
    font-size: 20px;
  }

  .brand-mark.brand-mark-lg {
    width: 60px;
    height: 60px;
  }

  .wheel-section {
    padding: 18px;
  }

  .dish-section,
  .admin-grid .card {
    padding: 18px;
  }

  .add-row,
  .form-inline {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .add-row .btn,
  .form-inline .btn,
  .form-inline .btn-sm {
    width: 100%;
  }

  .login-card {
    padding: 22px 18px;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal {
    padding: 18px;
  }
}
