:root {
  --green: #00a651;
  --green-dark: #007f3e;
  --green-deep: #005c34;
  --green-soft: #e8f5eb;
  --green-mist: #f1f8f2;
  --gold: #e6b85c;
  --gold-dark: #d4a338;
  --gold-pale: #fff6df;
  --ink: #183229;
  --muted: #6f8078;
  --line: #dfe9e2;
  --paper: #ffffff;
  --background: #f4f9f5;
  --danger: #bc4b4b;
  --shadow: 0 20px 60px rgba(0, 93, 51, 0.1);
  --shadow-soft: 0 10px 34px rgba(0, 93, 51, 0.08);
  --radius: 22px;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --serif: "STZhongsong", "Songti SC", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 9% 15%, rgba(0, 166, 81, 0.11), transparent 27rem),
    radial-gradient(circle at 91% 30%, rgba(230, 184, 92, 0.13), transparent 25rem),
    linear-gradient(145deg, #fbfdfb 0%, var(--background) 55%, #eef7f0 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.45;
  background-image: radial-gradient(rgba(0, 127, 62, 0.13) 0.7px, transparent 0.7px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(230, 184, 92, 0.55);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.app-shell {
  position: relative;
  width: min(1600px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 64px) 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: clamp(74px, 8vw, 112px);
  height: clamp(58px, 6.5vw, 88px);
  object-fit: contain;
  mix-blend-mode: multiply;
}

.brand-copy {
  padding-left: 4px;
}

.brand-copy strong {
  display: block;
  font-family: var(--serif);
  font-size: clamp(21px, 2.2vw, 34px);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.08;
}

.brand-copy span {
  display: block;
  margin-top: 6px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.38em;
}

.header-note {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-align: right;
}

.header-note b {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: 0.25em;
}

.route-enter {
  animation: route-enter 0.46s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes route-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-gold {
  border-color: #d9a844;
  color: #4d3913;
  background: linear-gradient(135deg, #f4d78c, var(--gold) 55%, var(--gold-dark));
  box-shadow: 0 12px 28px rgba(212, 163, 56, 0.28), inset 0 1px rgba(255, 255, 255, 0.7);
}

.btn-gold:hover {
  box-shadow: 0 15px 34px rgba(212, 163, 56, 0.38), inset 0 1px rgba(255, 255, 255, 0.7);
}

.btn-green {
  border-color: var(--green);
  color: white;
  background: linear-gradient(135deg, #08b95d, var(--green));
  box-shadow: 0 10px 24px rgba(0, 166, 81, 0.2);
}

.btn-green:hover {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
}

.btn-outline {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.btn-outline:hover {
  border-color: rgba(0, 166, 81, 0.45);
  background: white;
}

.btn-text {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.btn-danger:hover {
  color: var(--danger);
  background: #fff5f5;
}

.btn-square {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 12px;
}

/* Main draw route */
.draw-view {
  padding: 4px clamp(14px, 3.5vw, 56px) 54px;
}

.draw-toolbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(920px, 100%);
  margin: 0 auto 8px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.mode-switch button {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background: transparent;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.mode-switch button[aria-pressed="true"] {
  color: white;
  background: var(--green);
  box-shadow: 0 6px 14px rgba(0, 166, 81, 0.23);
}

.stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(230, 184, 92, 0.52);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 250, 237, 0.9);
  white-space: nowrap;
}

.stock-chip b {
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 19px;
}

.config-link {
  margin-left: auto;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.stage-intro {
  margin: 6px 0 10px;
  text-align: center;
}

.stage-intro h1 {
  margin: 0;
  color: var(--green-deep);
  font-family: var(--serif);
  font-size: clamp(28px, 3.4vw, 54px);
  font-weight: 700;
  letter-spacing: 0.13em;
}

.stage-intro p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 1.2vw, 15px);
  letter-spacing: 0.08em;
}

.wheel-area {
  position: relative;
  display: grid;
  place-items: center;
  width: min(80vw, 80vh);
  min-width: 300px;
  max-width: 920px;
  aspect-ratio: 1;
  margin: 0 auto;
}

.wheel-area::before {
  position: absolute;
  inset: 8%;
  z-index: -1;
  content: "";
  border-radius: 50%;
  background: rgba(0, 166, 81, 0.16);
  filter: blur(45px);
  animation: breathe 5s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.62;
    transform: scale(1.08);
  }
}

.wheel-frame {
  position: relative;
  width: 94%;
  aspect-ratio: 1;
  padding: clamp(7px, 1.1vw, 14px);
  border: clamp(4px, 0.55vw, 8px) solid var(--green-deep);
  border-radius: 50%;
  background:
    linear-gradient(145deg, #fff8e8, #d6a23b 46%, #fff2c2 61%, #bd8524);
  box-shadow:
    0 30px 70px rgba(0, 86, 48, 0.19),
    0 0 0 clamp(3px, 0.4vw, 6px) white,
    0 0 0 clamp(7px, 0.85vw, 13px) rgba(0, 166, 81, 0.13);
}

.wheel-frame.spinning {
  cursor: progress;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: pointer;
}

.wheel-frame.spinning #wheelCanvas {
  cursor: progress;
}

.pointer {
  position: absolute;
  top: -1.1%;
  left: 50%;
  z-index: 4;
  width: clamp(32px, 5vw, 64px);
  height: clamp(50px, 7vw, 90px);
  transform: translateX(-50%);
  filter: drop-shadow(0 7px 6px rgba(78, 52, 4, 0.22));
  pointer-events: none;
}

.pointer::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 47%;
  aspect-ratio: 1;
  content: "";
  border: clamp(2px, 0.3vw, 4px) solid white;
  border-radius: 50%;
  background: var(--green);
  transform: translateX(-50%);
}

.pointer::after {
  position: absolute;
  top: 20%;
  left: 50%;
  content: "";
  border-right: clamp(12px, 2vw, 25px) solid transparent;
  border-left: clamp(12px, 2vw, 25px) solid transparent;
  border-top: clamp(29px, 4.5vw, 58px) solid var(--gold);
  transform: translateX(-50%);
}

.draw-action {
  min-width: min(280px, 74vw);
  min-height: 58px;
  margin-top: 18px;
  padding: 0 34px;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.18em;
}

.draw-hint {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.history-panel {
  width: min(980px, 100%);
  margin: 46px auto 0;
  padding: clamp(18px, 2.6vw, 28px);
  border: 1px solid rgba(0, 166, 81, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

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

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.12em;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.history-icon {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(230, 184, 92, 0.35);
  border-radius: 12px;
  font-size: 23px;
  background: var(--gold-pale);
}

.history-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.history-info b {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-info time {
  color: var(--muted);
  font-size: 10px;
}

.history-tag {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  background: var(--green-soft);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed rgba(0, 166, 81, 0.25);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  background: var(--green-mist);
}

/* Config route */
.config-view {
  width: min(1240px, calc(100% - 32px));
  margin: 8px auto 70px;
}

.config-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(0, 166, 81, 0.17);
  border-radius: 30px;
  color: white;
  background:
    radial-gradient(circle at 80% -30%, rgba(255, 231, 174, 0.38), transparent 45%),
    linear-gradient(128deg, var(--green-dark), var(--green) 62%, #14b765);
  box-shadow: var(--shadow);
}

.config-kicker {
  margin: 0 0 9px;
  color: #dff6e8;
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.35em;
}

.config-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 52px);
  letter-spacing: 0.12em;
}

.config-hero .lead {
  max-width: 680px;
  margin: 13px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.8;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: white;
  font-size: 11px;
  background: rgba(0, 74, 36, 0.17);
}

.save-state::before {
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: #f4d78c;
  box-shadow: 0 0 0 4px rgba(244, 215, 140, 0.15);
}

.config-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.config-actions .btn-outline {
  border-color: rgba(255, 255, 255, 0.4);
  color: white;
  background: rgba(255, 255, 255, 0.09);
}

.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.72fr);
  gap: 20px;
  margin-top: 20px;
}

.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.surface-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.surface-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.1em;
}

.surface-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.weight-total {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  background: var(--green-soft);
}

.prize-table-head,
.prize-row {
  display: grid;
  grid-template-columns: 66px minmax(130px, 1fr) 92px 92px 88px 42px;
  gap: 10px;
  align-items: center;
}

.prize-table-head {
  padding: 13px 24px 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.prize-list {
  padding: 0 16px 10px;
}

.prize-row {
  padding: 11px 8px;
  border-top: 1px solid #edf2ee;
}

.prize-row:first-child {
  border-top: 0;
}

.prize-row.is-sold {
  opacity: 0.62;
}

.image-picker {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  overflow: hidden;
  place-items: center;
  border: 1px dashed rgba(0, 166, 81, 0.4);
  border-radius: 14px;
  cursor: pointer;
  font-size: 27px;
  background: var(--green-mist);
}

.image-picker:hover {
  border-style: solid;
  background: var(--green-soft);
}

.image-picker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-picker small {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  background: rgba(0, 92, 52, 0.82);
}

.field {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field:hover {
  border-color: rgba(0, 166, 81, 0.35);
}

.field:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.1);
}

.field-number {
  text-align: center;
  font-family: Georgia, serif;
  font-weight: 700;
}

.probability {
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--line);
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sim-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 20px 22px 12px;
}

.sim-results {
  min-height: 184px;
  padding: 10px 22px 24px;
}

.sim-placeholder {
  display: grid;
  min-height: 150px;
  place-items: center;
  padding: 24px;
  border: 1px dashed rgba(0, 166, 81, 0.23);
  border-radius: 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
  background: var(--green-mist);
}

.sim-row {
  margin-top: 13px;
}

.sim-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11px;
}

.sim-meta b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sim-meta span {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: Georgia, serif;
}

.sim-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf3ee;
}

.sim-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.config-summary {
  padding: 22px;
}

.summary-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 18px;
  margin: 18px 0 0;
  font-size: 12px;
}

.summary-list dt {
  color: var(--muted);
}

.summary-list dd {
  margin: 0;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-weight: 700;
}

/* Protected admin route */
.admin-view {
  width: min(1320px, calc(100% - 32px));
  margin: 8px auto 70px;
}

.admin-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(24px, 4vw, 44px);
  border-radius: 30px;
  color: white;
  background:
    radial-gradient(circle at 86% -45%, rgba(255, 232, 176, 0.38), transparent 48%),
    linear-gradient(125deg, #005c34, #008b46 58%, #00a651);
  box-shadow: var(--shadow);
}

.admin-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 52px);
  letter-spacing: 0.11em;
}

.admin-hero p:not(.config-kicker) {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.admin-hero-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.admin-hero-actions .btn-outline {
  border-color: rgba(255, 255, 255, 0.38);
  color: white;
  background: rgba(255, 255, 255, 0.09);
}

.admin-tabs {
  display: inline-flex;
  gap: 6px;
  margin-top: 20px;
  padding: 5px;
  border: 1px solid rgba(0, 166, 81, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.admin-tabs button {
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  background: transparent;
}

.admin-tabs button:hover {
  color: var(--green-dark);
  background: var(--green-mist);
}

.admin-tabs button.is-active {
  color: white;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  box-shadow: 0 8px 20px rgba(0, 127, 62, 0.2);
}

.admin-panel[hidden] {
  display: none;
}

.admin-config-section {
  margin-top: 20px;
}

.admin-config-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
}

.admin-config-intro h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 25px;
  letter-spacing: 0.1em;
}

.admin-config-intro p:not(.admin-config-kicker) {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.admin-config-kicker {
  margin: 0;
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
}

.admin-config-actions,
.admin-record-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
}

.admin-config-intro .save-state {
  margin-top: 0;
  border-color: rgba(0, 166, 81, 0.16);
  color: var(--green-dark);
  background: var(--green-mist);
}

.admin-config-error {
  margin-top: 20px;
  padding: 28px;
  color: #8a2d2d;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.stat-card {
  position: relative;
  min-width: 0;
  padding: 20px 22px;
  overflow: hidden;
  border: 1px solid rgba(0, 166, 81, 0.15);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.stat-card::after {
  position: absolute;
  right: -18px;
  bottom: -23px;
  width: 74px;
  height: 74px;
  content: "";
  border-radius: 50%;
  background: rgba(230, 184, 92, 0.15);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: clamp(27px, 3vw, 39px);
  line-height: 1;
}

.admin-records {
  overflow: hidden;
}

.admin-records-head {
  padding: 23px 26px;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) repeat(3, minmax(140px, 0.75fr)) auto auto;
  gap: 10px;
  align-items: end;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--green-mist);
}

.admin-filters label {
  display: grid;
  gap: 6px;
}

.admin-filters label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-table-wrap {
  position: relative;
  min-height: 230px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table th {
  padding: 13px 16px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-align: left;
  background: #fbfdfb;
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-top: 1px solid #edf2ee;
  white-space: nowrap;
}

.admin-table tbody tr:hover {
  background: var(--green-mist);
}

.admin-table td:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-prize-icon {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
  background: var(--gold-pale);
}

.mode-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 700;
  background: var(--green-soft);
}

.mode-badge.stock {
  color: #76520a;
  background: var(--gold-pale);
}

.admin-table code {
  padding: 3px 7px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10px;
  background: #f0f3f1;
}

.admin-empty {
  padding: 58px 20px;
  color: var(--muted);
  text-align: center;
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.admin-pagination .btn {
  min-height: 38px;
}

/* Modal, toast and confetti */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 45, 29, 0.54);
  backdrop-filter: blur(8px);
}

.modal.is-open {
  display: flex;
}

.modal-card {
  position: relative;
  width: min(390px, 94vw);
  padding: 48px 30px 28px;
  overflow: hidden;
  border: 1px solid rgba(230, 184, 92, 0.55);
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgba(230, 184, 92, 0.27), transparent 52%),
    white;
  box-shadow: 0 30px 90px rgba(3, 58, 32, 0.28);
  animation: modal-pop 0.42s cubic-bezier(0.2, 1.3, 0.3, 1) both;
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.78) translateY(12px);
  }
}

.modal-seal {
  position: absolute;
  top: 0;
  left: 50%;
  padding: 8px 22px;
  border-radius: 0 0 16px 16px;
  color: #513b11;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
  background: var(--gold);
  transform: translateX(-50%);
}

.modal-prize {
  display: grid;
  width: 104px;
  height: 104px;
  margin: 6px auto 15px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(0, 166, 81, 0.17);
  border-radius: 25px;
  font-size: 55px;
  background: var(--green-soft);
}

.modal-prize img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 31px;
  letter-spacing: 0.08em;
}

.modal-card p {
  margin: 9px 0 22px;
  color: var(--muted);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 110;
  max-width: calc(100vw - 30px);
  padding: 11px 20px;
  border: 1px solid rgba(230, 184, 92, 0.5);
  border-radius: 999px;
  opacity: 0;
  color: white;
  font-size: 12px;
  text-align: center;
  background: rgba(10, 65, 39, 0.94);
  box-shadow: 0 15px 38px rgba(0, 58, 31, 0.24);
  transform: translate(-50%, 30px);
  transition: opacity 0.28s, transform 0.28s;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.site-footer {
  padding: 28px 20px 40px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
}

@media (max-width: 980px) {
  .config-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .admin-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .masthead {
    padding-top: 13px;
  }

  .brand-logo {
    width: 70px;
    height: 58px;
  }

  .brand-copy strong {
    font-size: 20px;
  }

  .header-note {
    display: none;
  }

  .draw-view {
    padding-right: 12px;
    padding-left: 12px;
  }

  .draw-toolbar {
    flex-wrap: wrap;
  }

  .mode-switch {
    order: 1;
  }

  .stock-chip {
    order: 2;
  }

  .config-link {
    order: 3;
    margin-left: 0;
  }

  .admin-link {
    order: 4;
  }

  .stage-intro h1 {
    font-size: 29px;
  }

  .wheel-area {
    width: 80vw;
    min-width: 0;
    max-width: none;
  }

  .history-list {
    grid-template-columns: 1fr 1fr;
  }

  .config-view {
    width: min(100% - 20px, 1240px);
  }

  .config-hero {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 23px;
  }

  .config-actions {
    width: 100%;
  }

  .config-actions .btn {
    flex: 1;
  }

  .surface-head {
    padding: 18px;
  }

  .prize-table-head {
    display: none;
  }

  .prize-list {
    padding: 5px 12px 12px;
  }

  .prize-row {
    grid-template-columns: 58px 1fr 1fr 42px;
    gap: 8px;
    padding: 14px 4px;
  }

  .prize-row .name-field {
    grid-column: 2 / -1;
    grid-row: 1;
  }

  .prize-row .image-picker {
    grid-row: 1 / 3;
  }

  .probability {
    min-height: 42px;
    padding: 13px 5px;
    border-radius: 10px;
    background: var(--green-mist);
  }

  .side-stack {
    display: flex;
  }

  .admin-view {
    width: min(100% - 20px, 1320px);
  }

  .admin-hero {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 23px;
  }

  .admin-hero-actions {
    width: 100%;
  }

  .admin-hero-actions .btn {
    flex: 1;
  }

  .admin-config-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-config-actions {
    width: 100%;
    flex-wrap: wrap;
  }

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

  .admin-records-head {
    align-items: flex-start;
  }

  .admin-table-wrap {
    overflow: visible;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }

  .admin-table tr {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
  }

  .admin-table td,
  .admin-table td:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border: 0;
    white-space: normal;
  }

  .admin-table td::before {
    flex: 0 0 auto;
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
  }

  .admin-table td:first-child {
    justify-content: flex-start;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .admin-table td:first-child::before {
    display: none;
  }
}

@media (max-width: 520px) {
  .brand-copy span {
    letter-spacing: 0.24em;
  }

  .draw-toolbar {
    gap: 8px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-switch button {
    padding: 0 10px;
  }

  .stock-chip,
  .config-link,
  .admin-link {
    flex: 1;
  }

  .wheel-area {
    width: 86vw;
  }

  .draw-action {
    min-height: 54px;
    font-size: 18px;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .history-panel {
    margin-top: 34px;
  }

  .config-hero {
    padding: 23px 19px;
  }

  .config-hero h1 {
    font-size: 29px;
  }

  .config-actions {
    flex-direction: column;
  }

  .table-actions {
    padding: 14px;
  }

  .table-actions .btn {
    flex: 1;
    padding-right: 12px;
    padding-left: 12px;
  }

  .sim-controls {
    grid-template-columns: 1fr;
  }

  .admin-hero-actions {
    flex-direction: column;
  }

  .admin-tabs {
    display: flex;
    width: 100%;
  }

  .admin-tabs button {
    flex: 1;
    padding: 0 10px;
  }

  .admin-config-intro {
    padding: 18px;
  }

  .admin-config-actions,
  .admin-record-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-config-actions .save-state,
  .admin-config-actions .btn,
  .admin-record-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .admin-stats {
    gap: 9px;
  }

  .stat-card {
    padding: 16px;
  }

  .admin-records-head {
    flex-direction: column;
  }

  .admin-records-head .btn {
    width: 100%;
  }

  .admin-filters {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .admin-filters .btn {
    width: 100%;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
