/* =========================
   RollGeon — Pixel Medieval UI
   No libraries. No glassmorphism. Just HTML, CSS, and JS.
========================= */

/* =========================
   1. RESET + BASE
========================= */

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

:root {
  --bg: #14110d;
  --bg-2: #25190f;
  --surface: #2b2118;
  --surface-2: #3a2a1d;
  --surface-3: #4c3824;
  --parchment: #d8bf8a;
  --parchment-2: #f0dca5;
  --text: #fff3c4;
  --muted: #b9a06c;
  --muted-strong: #e4cf96;
  --primary: #a7342f;
  --primary-dark: #69211f;
  --accent: #d9a441;
  --accent-2: #fff0a6;
  --danger: #c34b43;
  --success: #5f8f45;
  --warning: #d9a441;
  --border: #7c5a2d;
  --border-strong: #d9a441;
  --ink: #15100b;
  --button-text: #fff3c4;

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --cut-corners: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  --cut-corners-lg: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  --pixel-shadow: 6px 6px 0 #090604;
  --pixel-shadow-soft: 4px 4px 0 rgba(0, 0, 0, 0.5);
  --inner-line: inset 0 0 0 2px rgba(255, 224, 146, 0.12);
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family:
    "Trebuchet MS",
    "Courier New",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.025) 75%) 0 0 / 18px 18px,
    radial-gradient(circle at top left, color-mix(in srgb, var(--primary), transparent 72%), transparent 32%),
    radial-gradient(circle at bottom right, color-mix(in srgb, var(--accent), transparent 78%), transparent 34%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  image-rendering: pixelated;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 0;
  color: var(--text);
  background: #1c140e;
  outline: none;
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.34);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow:
    inset 3px 3px 0 rgba(0, 0, 0, 0.34),
    0 0 0 3px color-mix(in srgb, var(--accent), transparent 54%);
}

::selection {
  color: var(--ink);
  background: var(--accent-2);
}

/* =========================
   2. THEMES
========================= */

body[data-theme="castle"],
body[data-theme="neon"] {
  --bg: #14110d;
  --bg-2: #25190f;
  --surface: #2b2118;
  --surface-2: #3a2a1d;
  --surface-3: #4c3824;
  --primary: #a7342f;
  --primary-dark: #69211f;
  --accent: #d9a441;
  --accent-2: #fff0a6;
  --border: #7c5a2d;
  --border-strong: #d9a441;
}

body[data-theme="tavern"],
body[data-theme="casino"] {
  --bg: #160c08;
  --bg-2: #2f170d;
  --surface: #3a2013;
  --surface-2: #4c2a17;
  --surface-3: #64361b;
  --primary: #8f2d20;
  --primary-dark: #591a12;
  --accent: #f0a13b;
  --accent-2: #ffe29b;
  --border: #935923;
  --border-strong: #f0a13b;
}

body[data-theme="forest"],
body[data-theme="minimal"] {
  --bg: #07120c;
  --bg-2: #132416;
  --surface: #1c2a1a;
  --surface-2: #24371f;
  --surface-3: #34502b;
  --primary: #7f3d27;
  --primary-dark: #4b2118;
  --accent: #8fb85c;
  --accent-2: #d5f0a0;
  --border: #60713b;
  --border-strong: #b8c96b;
}

body[data-theme="dungeon"],
body[data-theme="galaxy"] {
  --bg: #08090b;
  --bg-2: #161a20;
  --surface: #1d222b;
  --surface-2: #282f3b;
  --surface-3: #394150;
  --primary: #5e2532;
  --primary-dark: #351620;
  --accent: #98a8b8;
  --accent-2: #e2edf7;
  --border: #596473;
  --border-strong: #aeb8c6;
}

body[data-theme="parchment"],
body[data-theme="candy"] {
  --bg: #2b1b10;
  --bg-2: #634222;
  --surface: #d0af73;
  --surface-2: #ba9056;
  --surface-3: #9d6f3d;
  --text: #27150c;
  --muted: #5c3b22;
  --muted-strong: #3d2515;
  --primary: #9c2d24;
  --primary-dark: #69211b;
  --accent: #7f5724;
  --accent-2: #2f1a0c;
  --border: #6d431f;
  --border-strong: #2f1a0c;
  --ink: #fff2c0;
  --button-text: #fff2c0;
}

/* =========================
   3. BACKGROUND
========================= */

.background-glow {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.24) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(rgba(0, 0, 0, 0.24) 1px, transparent 1px) 0 0 / 36px 36px,
    radial-gradient(circle at 12% 16%, color-mix(in srgb, var(--accent), transparent 86%), transparent 18%),
    radial-gradient(circle at 86% 12%, color-mix(in srgb, var(--primary), transparent 82%), transparent 22%);
  opacity: 0.9;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(255, 255, 255, 0.03) 49% 51%, transparent 52% 100%) 0 0 / 28px 28px,
    linear-gradient(45deg, transparent 0 48%, rgba(0, 0, 0, 0.12) 49% 51%, transparent 52% 100%) 0 0 / 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.25)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.24), transparent 18%, transparent 72%, rgba(255, 255, 255, 0.035));
}

/* =========================
   4. APP LAYOUT
========================= */

.app {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding: 18px;
  border: 3px solid var(--border-strong);
  clip-path: var(--cut-corners-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #ffffff 8%), var(--surface));
  box-shadow: var(--pixel-shadow), var(--inner-line);
}

.app-header::before,
.panel-card::before,
.wheel-section::before,
.history-section::before,
.winner-card::before,
.import-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 0;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 45%);
  pointer-events: none;
}

.app-header > *,
.panel-card > *,
.wheel-section > *,
.history-section > *,
.winner-card > *,
.import-card > * {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 3px solid var(--ink);
  outline: 2px solid var(--border-strong);
  border-radius: 0;
  clip-path: var(--cut-corners);
  color: var(--ink);
  font-size: 2rem;
  background:
    linear-gradient(135deg, var(--accent-2), var(--accent) 42%, var(--primary) 43% 58%, var(--accent) 59%);
  box-shadow: 5px 5px 0 #090604;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.25);
  transform-origin: center;
  animation: iconBob 2.2s steps(2, end) infinite;
}

@keyframes iconBob {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  50% {
    transform: translate(0, -4px) rotate(-2deg);
  }
}

.brand h1 {
  line-height: 0.95;
  font-size: clamp(2rem, 4vw, 3.8rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 var(--ink),
    5px 5px 0 var(--primary-dark);
}

.brand p {
  margin-top: 8px;
  color: var(--muted-strong);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.82fr);
  gap: 24px;
  align-items: start;
}

/* =========================
   5. GENERIC COMPONENTS
========================= */

.section-label,
.section-header,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-label {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 1000;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-label strong {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 2px solid var(--border);
  color: var(--accent-2);
  font-size: 0.74rem;
  background: rgba(0, 0, 0, 0.24);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 6px;
  padding-left: 10px;
  border-left: 6px solid var(--primary);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 1000;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-card,
.wheel-section,
.history-section {
  position: relative;
  border: 3px solid var(--border);
  border-radius: 0;
  clip-path: var(--cut-corners-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #ffffff 4%), var(--surface));
  box-shadow: var(--pixel-shadow), var(--inner-line);
}

.panel-card {
  padding: 20px;
}

.panel-card + .panel-card {
  margin-top: 16px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2,
.section-header h2 {
  color: var(--text);
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.46);
}

.empty-state {
  display: grid;
  gap: 5px;
  padding: 22px;
  border: 2px dashed var(--border);
  border-radius: 0;
  color: var(--muted);
  text-align: center;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.12) 0 8px, rgba(255, 255, 255, 0.025) 8px 16px),
    rgba(0, 0, 0, 0.16);
}

.empty-state strong {
  color: var(--muted-strong);
}

.empty-state.horizontal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hidden {
  display: none !important;
}

/* =========================
   6. BUTTONS
========================= */

.primary-button,
.ghost-button,
.small-button,
.preset-button,
.floating-button,
.icon-button,
.spin-button {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  color: var(--text);
  text-transform: uppercase;
  transition:
    transform 0.12s steps(2, end),
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
}

.primary-button::before,
.spin-button::before,
.preset-button::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent),
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(255, 255, 255, 0.08) 9px 12px);
  transform: translateX(-100%);
}

.primary-button:hover::before,
.spin-button:hover::before,
.preset-button:hover::before {
  opacity: 1;
  animation: buttonShine 0.48s steps(6, end);
}

@keyframes buttonShine {
  to {
    transform: translateX(100%);
  }
}

.primary-button {
  min-height: 50px;
  padding: 0 20px;
  border: 3px solid var(--ink);
  outline: 2px solid var(--border-strong);
  color: var(--button-text);
  font-weight: 1000;
  letter-spacing: 0.04em;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary), #ffffff 10%), var(--primary-dark));
  box-shadow: 5px 5px 0 #090604;
}

.primary-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #090604;
  filter: brightness(1.1);
}

.primary-button:active,
.spin-button:active,
.ghost-button:active,
.small-button:active,
.preset-button:active,
.floating-button:active,
.icon-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #090604;
}

.ghost-button,
.small-button,
.icon-button,
.floating-button {
  border: 2px solid var(--border);
  color: var(--muted-strong);
  font-weight: 950;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-3), #ffffff 4%), var(--surface-2));
  box-shadow: 4px 4px 0 #090604;
}

.ghost-button {
  min-height: 42px;
  padding: 0 16px;
}

.ghost-button:hover,
.small-button:hover,
.icon-button:hover,
.floating-button:hover {
  border-color: var(--border-strong);
  color: var(--accent-2);
  background: color-mix(in srgb, var(--surface-3), var(--accent) 10%);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #090604;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.78rem;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
}

/* =========================
   7. WHEEL SECTION
========================= */

.wheel-section {
  position: sticky;
  top: 20px;
  min-height: 720px;
  padding: clamp(20px, 3vw, 34px);
}

.wheel-stage {
  position: relative;
  display: grid;
  min-height: 500px;
  place-items: center;
}

.wheel-frame {
  position: relative;
  display: grid;
  width: min(100%, 520px);
  aspect-ratio: 1;
  place-items: center;
  border: 6px solid var(--ink);
  outline: 4px solid var(--border-strong);
  border-radius: 0;
  clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%);
  background:
    repeating-conic-gradient(from 0deg, rgba(0, 0, 0, 0.24) 0deg 7deg, rgba(255, 255, 255, 0.08) 7deg 14deg),
    conic-gradient(from 0deg, var(--primary), var(--accent), var(--primary-dark), var(--accent));
  box-shadow:
    10px 10px 0 #090604,
    inset 0 0 0 10px rgba(255, 255, 255, 0.08);
  animation: wheelGlow 1.6s steps(2, end) infinite alternate;
}

@keyframes wheelGlow {
  from {
    filter: brightness(0.96);
  }

  to {
    filter: brightness(1.08);
  }
}

.wheel-frame::before {
  content: "";
  position: absolute;
  inset: 18px;
  z-index: 1;
  border: 3px dashed color-mix(in srgb, var(--accent-2), transparent 20%);
  border-radius: 50%;
  pointer-events: none;
  animation: outerRing 1.2s steps(12, end) infinite;
}

@keyframes outerRing {
  to {
    transform: rotate(360deg);
  }
}

.wheel-canvas {
  position: relative;
  z-index: 2;
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: #1b130c;
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.08),
    inset 0 0 0 14px rgba(0, 0, 0, 0.26);
}

.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  z-index: 4;
  width: 58px;
  height: 80px;
  transform: translateX(-50%);
  filter: drop-shadow(5px 5px 0 #090604);
}

.wheel-pointer span {
  display: block;
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  border: 3px solid var(--ink);
  background:
    linear-gradient(180deg, var(--accent-2), var(--accent) 42%, var(--primary) 43%);
}

.wheel-section.is-spinning .wheel-pointer {
  animation: pointerTick 0.09s steps(2, end) infinite;
}

@keyframes pointerTick {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }

  50% {
    transform: translateX(-50%) rotate(8deg);
  }
}

.wheel-center {
  position: absolute;
  z-index: 5;
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border: 5px solid var(--ink);
  outline: 3px solid var(--border-strong);
  border-radius: 0;
  clip-path: polygon(18% 0, 82% 0, 100% 18%, 100% 82%, 82% 100%, 18% 100%, 0 82%, 0 18%);
  color: var(--ink);
  background:
    linear-gradient(135deg, var(--accent-2), var(--accent) 45%, var(--primary) 46% 62%, var(--accent) 63%);
  box-shadow: 6px 6px 0 #090604;
}

.wheel-center span {
  font-size: 2.2rem;
  font-weight: 1000;
  letter-spacing: -0.02em;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.25);
}

.spin-aura {
  position: absolute;
  inset: 13%;
  z-index: -1;
  border: 4px solid color-mix(in srgb, var(--accent), transparent 30%);
  clip-path: polygon(14% 0, 86% 0, 100% 14%, 100% 86%, 86% 100%, 14% 100%, 0 86%, 0 14%);
  background:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent), transparent 78%) 0 10px, transparent 10px 20px);
  opacity: 0.42;
}

.wheel-section.is-spinning .spin-aura {
  animation: spinAuraPulse 0.46s steps(2, end) infinite alternate;
}

@keyframes spinAuraPulse {
  from {
    transform: scale(0.96);
    opacity: 0.34;
  }

  to {
    transform: scale(1.06);
    opacity: 0.75;
  }
}

.spin-controls {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 16px;
  align-items: stretch;
  margin-top: 24px;
}

.spin-button {
  display: inline-flex;
  min-height: 76px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 4px solid var(--ink);
  outline: 3px solid var(--border-strong);
  color: var(--button-text);
  font-size: 1.45rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary), #ffffff 14%), var(--primary-dark));
  box-shadow: 8px 8px 0 #090604;
}

.spin-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 #090604;
  filter: brightness(1.12);
}

.spin-button-icon {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--accent-2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.18);
}

.spin-button.is-spinning {
  animation: spinButtonPulse 0.5s steps(2, end) infinite alternate;
}

@keyframes spinButtonPulse {
  from {
    filter: brightness(1);
  }

  to {
    filter: brightness(1.32);
  }
}

.current-result {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 18px 20px;
  border: 3px solid var(--border);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.08)),
    color-mix(in srgb, var(--surface-2), transparent 5%);
  box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.25);
}

.result-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 1000;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.current-result strong {
  font-size: clamp(1.1rem, 2.5vw, 1.55rem);
  letter-spacing: -0.01em;
}

.suspense-message {
  min-height: 28px;
  margin-top: 18px;
  color: var(--muted-strong);
  font-weight: 900;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

/* =========================
   8. CONTROL PANEL
========================= */

.control-panel {
  min-width: 0;
}

.item-form {
  display: grid;
  gap: 14px;
}

.item-form label,
.select-label,
.range-label {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 950;
  letter-spacing: 0.02em;
}

.form-row {
  display: grid;
  gap: 12px;
}

.form-row.compact {
  grid-template-columns: 1fr 86px;
}

.item-form input,
.select-label select,
.range-label input,
.import-card textarea {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 0;
}

input[type="color"] {
  height: 46px;
  padding: 4px;
  cursor: pointer;
}

input[type="number"] {
  appearance: textfield;
}

select {
  cursor: pointer;
}

.range-label {
  margin-top: 16px;
}

.range-label input {
  padding: 0;
  accent-color: var(--accent);
  box-shadow: none;
}

#durationLabel {
  display: inline-flex;
  width: max-content;
  padding: 3px 8px;
  border: 2px solid var(--border);
  color: var(--accent-2);
  font-size: 0.8rem;
  font-weight: 1000;
  background: rgba(0, 0, 0, 0.22);
}

/* =========================
   9. ITEMS LIST
========================= */

.items-list {
  display: grid;
  gap: 10px;
  max-height: 410px;
  overflow: auto;
  padding-right: 4px;
}

.items-list::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
  width: 10px;
}

.items-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--border-strong);
}

.item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 68px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 0;
  clip-path: var(--cut-corners);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #ffffff 4%), rgba(0, 0, 0, 0.12)),
    var(--surface-2);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.42);
  animation: itemEnter 0.24s steps(3, end) both;
}

@keyframes itemEnter {
  from {
    opacity: 0;
    transform: translate(0, 8px);
  }

  to {
    opacity: 1;
    transform: translate(0, 0);
  }
}

.item-card:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface-3), var(--accent) 8%);
  transform: translate(-1px, -1px);
}

.item-card.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.item-card.is-disabled .item-title {
  text-decoration: line-through;
}

.item-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.item-toggle {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 0;
  background: #17100b;
}

.item-status-dot {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.34);
}

.item-card.is-disabled .item-status-dot {
  background: var(--muted);
  box-shadow: none;
}

.item-color {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--ink);
  outline: 2px solid var(--border);
  border-radius: 0;
  background: var(--item-color, var(--primary));
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.18);
}

.item-content {
  min-width: 0;
}

.item-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.96rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

/* =========================
   10. SETTINGS + PRESETS
========================= */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-card {
  position: relative;
  display: flex;
  gap: 10px;
  min-height: 72px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 0;
  clip-path: var(--cut-corners);
  background: rgba(0, 0, 0, 0.14);
  cursor: pointer;
  transition:
    transform 0.12s steps(2, end),
    background 0.12s ease,
    border-color 0.12s ease;
}

.toggle-card:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface-3), var(--accent) 8%);
  transform: translate(-1px, -1px);
}

.toggle-card input {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #12100d;
  cursor: pointer;
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.42);
  transition: background 0.12s ease;
}

.toggle-card input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 0;
  background: var(--muted);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.12s steps(2, end), background 0.12s ease;
}

.toggle-card input:checked {
  background: var(--primary-dark);
}

.toggle-card input:checked::before {
  background: var(--accent-2);
  transform: translateX(18px);
}

.toggle-card span {
  display: grid;
  gap: 2px;
}

.toggle-card strong {
  font-size: 0.86rem;
}

.toggle-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.select-label {
  margin-top: 16px;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.preset-button {
  min-height: 50px;
  padding: 0 12px;
  border: 2px solid var(--border);
  color: var(--muted-strong);
  font-weight: 950;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-3), #ffffff 5%), var(--surface-2));
  box-shadow: 4px 4px 0 #090604;
}

.preset-button:hover {
  color: var(--accent-2);
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface-3), var(--accent) 10%);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #090604;
}

/* =========================
   11. HISTORY
========================= */

.history-section {
  margin-top: 24px;
  padding: 24px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-height: 280px;
  overflow: auto;
  margin-top: 18px;
  padding-right: 4px;
}

.history-item {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 0;
  clip-path: var(--cut-corners);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #ffffff 4%), rgba(0, 0, 0, 0.1));
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.38);
  animation: itemEnter 0.24s steps(3, end) both;
}

.history-title {
  display: block;
  font-size: 0.98rem;
}

.history-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.history-badge {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 0;
  font-size: 1.35rem;
  background: rgba(0, 0, 0, 0.16);
}

/* =========================
   12. WINNER + IMPORT MODALS
========================= */

.winner-modal,
.import-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.winner-backdrop {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.24) 0 12px, rgba(0, 0, 0, 0.4) 12px 24px),
    radial-gradient(circle at center, color-mix(in srgb, var(--primary), transparent 72%), transparent 35%),
    rgba(0, 0, 0, 0.78);
  animation: fadeIn 0.16s steps(2, end) both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.winner-card,
.import-card {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  border: 4px solid var(--border-strong);
  border-radius: 0;
  clip-path: var(--cut-corners-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2), #ffffff 7%), var(--surface));
  box-shadow:
    10px 10px 0 #090604,
    var(--inner-line);
  animation: modalPop 0.24s steps(4, end) both;
}

.winner-card {
  display: grid;
  justify-items: center;
  padding: 36px;
  text-align: center;
}

.import-card {
  display: grid;
  gap: 14px;
  padding: 30px;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translate(0, 18px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

.modal-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 0;
  color: var(--button-text);
  font-size: 1.5rem;
  background: var(--primary-dark);
  box-shadow: 4px 4px 0 #090604;
}

.modal-close-button:hover {
  border-color: var(--accent-2);
  filter: brightness(1.14);
}

.winner-kicker {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.winner-emoji {
  margin: 22px 0 14px;
  font-size: clamp(4rem, 13vw, 7rem);
  line-height: 1;
  filter: drop-shadow(6px 6px 0 rgba(0, 0, 0, 0.45));
  animation: winnerEmoji 0.7s steps(2, end) infinite alternate;
}

@keyframes winnerEmoji {
  from {
    transform: translateX(-3px) scale(1);
  }

  to {
    transform: translateX(3px) scale(1.04);
  }
}

.winner-card h2 {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 var(--ink),
    5px 5px 0 var(--primary-dark);
}

.winner-card p {
  max-width: 340px;
  margin: 14px 0 24px;
  color: var(--muted-strong);
  font-weight: 800;
}

.import-card h2 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.import-card textarea {
  min-height: 180px;
  padding: 14px;
  resize: vertical;
}

/* =========================
   13. FLOATING ACTIONS
========================= */

.floating-actions {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: grid;
  gap: 10px;
}

.floating-button {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 3px solid var(--border);
  border-radius: 0;
  font-size: 1.3rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-3), #ffffff 6%), var(--surface-2));
}

/* =========================
   14. CONFETTI
========================= */

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0, 0, 0, 0.26);
  border-radius: 0;
  background: var(--accent);
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 40px), 110vh, 0) rotate(540deg);
  }
}

/* =========================
   15. EXTRA ANIMATION STATES
========================= */

.shake {
  animation: shake 0.24s steps(4, end);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

.flash {
  animation: flash 0.42s steps(2, end);
}

@keyframes flash {
  from {
    filter: brightness(1.55);
  }

  to {
    filter: brightness(1);
  }
}

/* =========================
   16. RESPONSIVE
========================= */

@media (max-width: 1120px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .wheel-section {
    position: relative;
    top: auto;
    min-height: auto;
  }

  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .panel-card + .panel-card {
    margin-top: 0;
  }

  .panel-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-icon {
    width: 54px;
    height: 54px;
    font-size: 1.7rem;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .ghost-button {
    flex: 1;
  }

  .wheel-stage {
    min-height: auto;
    padding: 10px 0;
  }

  .wheel-frame {
    width: min(100%, 380px);
  }

  .wheel-pointer {
    width: 44px;
    height: 60px;
  }

  .wheel-center {
    width: 74px;
    height: 74px;
  }

  .wheel-center span {
    font-size: 1.8rem;
  }

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

  .control-panel {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .preset-grid {
    grid-template-columns: 1fr;
  }

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

  .empty-state.horizontal {
    align-items: flex-start;
    flex-direction: column;
  }

  .floating-actions {
    right: 12px;
    bottom: 12px;
  }

  .floating-button {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 460px) {
  .form-row.compact {
    grid-template-columns: 1fr;
  }

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

  .item-actions {
    width: 100%;
  }

  .item-actions .icon-button {
    flex: 1;
    width: auto;
  }

  .winner-card,
  .import-card {
    padding: 26px;
  }
}

/* =========================
   17. ACCESSIBILITY
========================= */

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