/* ============ Design tokens ============ */
:root {
  --bg: #F4F1EA;
  --glow-1: rgba(124, 92, 250, 0.16);
  --glow-2: rgba(255, 159, 67, 0.16);
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --text: #212121;
  --muted: #616161;
  --border: #D6D6D6;
  --accent: #6A4DF4;
  --accent-soft: rgba(106, 77, 244, 0.14);
  --danger: #C62828;

  /* Classic UI (top bar, panel, dialogs) */
  --topbar-bg: #212121;
  --topbar-text: #FFFFFF;
  --panel-bg: #FFFFFF;
  --panel-border: #D0D0D0;
  --panel-text: #212121;
  --panel-muted: #616161;
  --field-bg: #FFFFFF;
  --field-border: #9E9E9E;
  --cbtn-bg: #3B3F6E;
  --cbtn-hover: #4B5089;
  --cbtn-text: #FFFFFF;
  --badge-bg: #9E9E9E;
  --hover: rgba(0, 0, 0, 0.06);

  /* Wheel */
  --rim: #1B1830;
  --rim-dot: #FFD166;
  --rim-dot-dim: #4A4233;
  --wheel-empty: #DDD7CC;
  --wheel-shadow: 0 10px 28px rgba(27, 24, 48, 0.25);

  --shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  --font: 'Tajawal', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
  --ui-font: 'Roboto', 'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
  /* Top bar: Roboto for Latin, the system's native Arabic face (Segoe UI on Windows) for Arabic */
  --bar-font: 'Roboto', 'Segoe UI', Tahoma, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100E1A;
    --glow-1: rgba(124, 92, 250, 0.24);
    --glow-2: rgba(255, 120, 80, 0.10);
    --surface: #212121;
    --surface-2: #2A2A2A;
    --text: #FFFFFF;
    --muted: #BDBDBD;
    --border: #3D3D3D;
    --accent: #7559FF;
    --accent-soft: rgba(124, 98, 255, 0.2);
    --danger: #FF8A80;

    --topbar-bg: #1C1C1C;
    --panel-bg: #212121;
    --panel-border: #3D3D3D;
    --panel-text: #FFFFFF;
    --panel-muted: #BDBDBD;
    --field-bg: #1E1E1E;
    --field-border: #616161;
    --badge-bg: #5E5E5E;
    --hover: rgba(255, 255, 255, 0.07);

    --rim: #0A0912;
    --rim-dot-dim: #3A3326;
    --wheel-empty: #2A2638;
    --wheel-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 28% 18%, var(--glow-1), transparent 42%),
    radial-gradient(circle at 82% 92%, var(--glow-2), transparent 40%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.tico, .pico { flex: none; fill: currentColor; }
.tico { width: 17px; height: 17px; }
.pico { width: 16px; height: 16px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  height: 50px;
  padding-inline-end: 12px;
  background: #212121;
  color: var(--topbar-text);
}
/* Soft light glow just under the bar */
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 100%;
  height: 16px;
  background: linear-gradient(to bottom, rgba(150, 165, 178, 0.5), rgba(150, 165, 178, 0.2) 45%, transparent);
  pointer-events: none;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  padding-inline: 15px 16px;
  font-family: var(--bar-font);
  font-size: 23.3px; font-weight: 500; letter-spacing: 0;
  white-space: nowrap;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 22%, transparent 23%),
    conic-gradient(#FF5D73 0 60deg, #FF9F43 0 120deg, #FFD166 0 180deg, #06D6A0 0 240deg, #118AB2 0 300deg, #7B5CFA 0 360deg);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}
.toolbar { display: flex; align-items: center; gap: 2px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 38px;
  padding: 0 14px; border: 0; border-radius: 4px;
  background: transparent; color: #FFFFFF;
  font-family: var(--bar-font);
  font-size: 14px; font-weight: 700; letter-spacing: 0;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.tb-btn .tico { width: 20px; height: 20px; }
.tb-btn:hover, .tb-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.09); }
.tb-btn:disabled { opacity: 0.4; pointer-events: none; }
.tb-btn .tico.caret { width: 16px; height: 16px; margin-inline-start: -2px; }
.tico.more-dots { display: none; }

/* Dropdown menus (shared by toolbar + panel) */
.tb-menu-wrap { position: relative; }
.tb-menu {
  position: absolute; top: calc(100% + 9px); inset-inline-end: 0; z-index: 30;
  display: flex; flex-direction: column;
  min-width: 220px; padding: 6px;
  background: var(--panel-bg); color: var(--panel-text);
  border: 1px solid var(--panel-border); border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  font-family: var(--ui-font);
  animation: menu-in 0.14s ease;
}
.tb-menu.up { top: auto; bottom: calc(100% + 6px); }
.panel .tb-menu { inset-inline-end: auto; inset-inline-start: 0; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.tb-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border: 0; border-radius: 4px;
  background: transparent; color: inherit;
  font-size: 14px; font-weight: 500; text-align: start; white-space: nowrap;
}
.tb-menu-item:hover, .tb-menu-item:focus-visible { background: var(--hover); outline: none; }
.tb-menu-item[aria-checked="true"] { font-weight: 700; }
.tb-menu-item[aria-checked="true"]::after { content: "✓"; margin-inline-start: auto; font-weight: 800; }

/* ============ Layout ============ */
.layout {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 28px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}
.layout.panel-hidden { grid-template-columns: minmax(0, 1fr); }

.stage { min-width: 0; padding-top: 8px; }

/* ============ Wheels ============ */
.wheels {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start;
  gap: 28px 24px;
  width: 100%;
}
.wheel-unit {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 0;
}
.wheels[data-count="1"] .wheel-unit { width: 100%; }
.wheels:not([data-count="1"]) .wheel-unit { width: calc(50% - 12px); }

.wheel-title {
  margin: 0; max-width: 100%;
  font-size: clamp(1.3rem, 2.6vw, 2.1rem); font-weight: 800;
  text-align: center; overflow-wrap: anywhere;
  unicode-bidi: plaintext; /* English title on an Arabic page keeps its "?" at the end */
}
.wheels:not([data-count="1"]) .wheel-title { font-size: clamp(1rem, 1.8vw, 1.4rem); }
.wheel-desc {
  margin: -8px 0 0; max-width: min(100%, 720px);
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.15rem); line-height: 1.6;
  text-align: center; white-space: pre-line; overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}
.wheels:not([data-count="1"]) .wheel-desc { font-size: 0.9rem; }

/* Round pencil button (top corner, under the logo) → edit title & description */
.title-edit-btn {
  position: absolute; top: 64px; inset-inline-start: 16px; z-index: 15;
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 50%;
  background: rgba(59, 63, 110, 0.55); color: #E6E6E6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: background-color 0.15s, color 0.15s;
}
.title-edit-btn:hover { background: var(--cbtn-bg); color: #FFFFFF; }
.title-edit-btn .pico { width: 17px; height: 17px; }

.wheel-wrap {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* Leave room on the right for the pointer, which sits just outside the wheel */
.wheels[data-count="1"] .wheel-wrap { width: min(calc(100% - 40px), max(280px, calc(100vh - 170px)), 780px); }
.wheels[data-count="2"] .wheel-wrap { width: min(calc(100% - 36px), max(220px, calc(100vh - 230px))); }
.wheels[data-count="3"] .wheel-wrap,
.wheels[data-count="4"] .wheel-wrap { width: min(calc(100% - 32px), max(200px, calc(50vh - 120px))); }

.wheel-wrap canvas {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
  box-shadow: var(--wheel-shadow);
}
.is-spinning .wheel-wrap { cursor: progress; }

/* Classic gold pointer on the right, pointing at the wheel */
.pointer {
  position: absolute;
  top: 50%; right: -3.6%;
  width: 7.2%;
  overflow: visible;
  transform: translateY(-50%) rotate(var(--kick, 0deg));
  transform-origin: 80% 50%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
  pointer-events: none;
  z-index: 3;
}
.pointer-body { fill: url(#pointerGold); stroke: #A27A12; stroke-width: 1.4; stroke-linejoin: round; }
.pointer-shine { fill: rgba(255, 255, 255, 0.55); }

/* Plain white center */
.hub {
  position: absolute; top: 50%; left: 50%;
  width: 20%; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 0;
  background-color: #FFFFFF;
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
  z-index: 2;
}
.hub-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hub:hover { transform: translate(-50%, -50%) scale(1.03); }
.hub:active { transform: translate(-50%, -50%) scale(0.98); }
.is-spinning .hub { pointer-events: none; }

/* Curved "Click to spin" text drawn over the wheel (clicks pass through to the wheel) */
.hint {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 0.25cqw 0.35cqw rgba(0, 0, 0, 0.55)) drop-shadow(0 0 0.8cqw rgba(0, 0, 0, 0.3));
  animation: hint-breathe 2.6s ease-in-out infinite;
}
.hint-text {
  fill: #FFFFFF;
  font-family: 'Quicksand', 'Tajawal', 'Segoe UI', sans-serif;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.28);
  stroke-width: 0.55px;
  stroke-linejoin: round;
}
.hint-text-main { font-size: 8.6px; letter-spacing: 0.25px; }
.hint-text-sub { font-size: 7px; letter-spacing: 0.15px; }
@keyframes hint-breathe { 50% { opacity: 0.8; } }

/* ============ Classic side panel ============ */
.panel {
  position: sticky; top: 74px;
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-family: var(--ui-font);
}
.collapse-btn {
  position: absolute; top: 4px; inset-inline-start: -15px; z-index: 4;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  padding: 0; border: 0; border-radius: 50%;
  background: var(--cbtn-bg); color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: background-color 0.15s;
}
.collapse-btn:hover { background: var(--cbtn-hover); }
.collapse-btn .pico { width: 18px; height: 18px; }
[dir="rtl"] .collapse-btn .pico { transform: scaleX(-1); }
.collapse-btn.show { position: fixed; top: 64px; inset-inline-start: auto; inset-inline-end: 12px; }
.collapse-btn.show .pico { transform: scaleX(-1); }
[dir="rtl"] .collapse-btn.show .pico { transform: none; }

/* Tabs */
.ptabs {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  overflow-x: auto; scrollbar-width: none;
}
.ptabs::-webkit-scrollbar { display: none; }
.ptab {
  flex: 1 1 0; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 10px 9px;
  border: 0; border-bottom: 3px solid transparent;
  background: transparent; color: var(--panel-text);
  font-size: 15px; font-weight: 700;
  white-space: nowrap;
}
.ptab:hover { background: var(--hover); }
.ptab[aria-selected="true"] { border-bottom-color: var(--panel-text); }
.ptab-name { overflow: hidden; text-overflow: ellipsis; }
.pbadge {
  flex: none;
  min-width: 22px; padding: 1px 7px;
  border-radius: 10px;
  background: var(--badge-bg); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1.5; text-align: center;
}

.pane { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.editor { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; border: 0; min-width: 0; }

/* Classic buttons */
.cbtn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cbtn-row.lg { gap: 9px; }
.cbtn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border: 0; border-radius: 3px;
  background: var(--cbtn-bg); color: var(--cbtn-text);
  font-family: var(--ui-font);
  font-size: 13px; font-weight: 700; white-space: nowrap;
  transition: background-color 0.15s;
}
.cbtn:hover, .cbtn[aria-expanded="true"] { background: var(--cbtn-hover); }
.cbtn:disabled { opacity: 0.45; pointer-events: none; }
.cbtn.lg { padding: 9px 12px; font-size: 15px; gap: 10px; }
.cbtn.lg .pico { width: 18px; height: 18px; }
.cbtn.plain { background: transparent; color: var(--panel-text); padding-inline: 8px; }
.cbtn.plain:hover { background: var(--hover); }
.cbtn .pico.caret { width: 15px; height: 15px; margin-inline-start: 2px; }
.split { display: inline-flex; }
.split > .cbtn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.split > .caret-btn {
  padding-inline: 7px;
  border-inline-start: 1px solid rgba(0, 0, 0, 0.35);
  border-start-start-radius: 0; border-end-start-radius: 0;
}

.ccheck { display: inline-flex; align-items: center; gap: 10px; width: fit-content; font-size: 13px; font-weight: 700; cursor: pointer; }
.ccheck input { width: 16px; height: 16px; margin: 0; accent-color: var(--cbtn-bg); cursor: pointer; }

#entries {
  width: 100%;
  height: max(260px, calc(100vh - 420px));
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--field-border); border-radius: 4px;
  background: var(--field-bg); color: var(--panel-text);
  font-family: var(--ui-font);
  font-size: 15px; line-height: 1.45;
  unicode-bidi: plaintext;
}
#entries:focus { outline: none; border-color: var(--panel-text); }
.editor:disabled #entries, .editor:disabled .adv-list { opacity: 0.65; }

/* Advanced editor */
.adv { display: flex; flex-direction: column; gap: 8px; }
.adv-head, .adv-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 62px 30px;
  align-items: center; gap: 8px;
}
.adv-head { padding: 0 9px; color: var(--panel-muted); font-size: 12px; font-weight: 700; }
.adv-list {
  display: flex; flex-direction: column; gap: 6px;
  height: max(220px, calc(100vh - 500px));
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--field-border); border-radius: 4px;
  background: var(--field-bg);
}
.adv-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--cbtn-bg); }
.adv-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.adv-thumb { width: 28px; height: 28px; flex: none; border-radius: 3px; object-fit: cover; }
.adv-text, .adv-weight {
  width: 100%; min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--field-border); border-radius: 3px;
  background: transparent; color: var(--panel-text);
  font-size: 14px;
}
.adv-text { unicode-bidi: plaintext; }
.adv-text:focus, .adv-weight:focus { outline: none; border-color: var(--panel-text); }
.adv-row.off .adv-text { opacity: 0.5; text-decoration: line-through; }
.adv-del {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 3px;
  background: transparent; color: var(--panel-muted);
}
.adv-del:hover { background: var(--hover); color: var(--danger); }
.adv-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.adv-help { color: var(--panel-muted); font-size: 12px; }
.adv-empty { margin: auto; color: var(--panel-muted); font-size: 13px; }

/* Image entries (simple mode) */
.image-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.img-chip {
  position: relative;
  width: 52px; height: 52px;
  border: 1px solid var(--field-border); border-radius: 4px;
  overflow: hidden;
}
.img-chip img { display: block; width: 100%; height: 100%; object-fit: cover; }
.img-chip button {
  position: absolute; top: 2px; inset-inline-end: 2px;
  display: grid; place-items: center;
  width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.72); color: #fff;
  font-size: 13px; line-height: 1;
}

/* Results */
.results {
  list-style: none; margin: 0; padding: 0;
  max-height: max(260px, calc(100vh - 330px)); overflow-y: auto;
  counter-reset: res;
}
.results li {
  counter-increment: res;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 15px;
}
.results li::before {
  content: counter(res);
  display: grid; place-items: center;
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--badge-bg); color: #fff;
  font-size: 12px; font-weight: 700;
}
.r-name { flex: 1; font-weight: 700; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.r-wheel {
  padding: 1px 7px; border-radius: 3px;
  background: var(--cbtn-bg); color: #fff;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.r-time { color: var(--panel-muted); font-size: 12px; white-space: nowrap; }
.empty { margin: 8px 0; padding: 32px 8px; color: var(--panel-muted); text-align: center; }

.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--panel-border);
  font-size: 14px; font-weight: 500;
}
.link-btn {
  padding: 0; border: 0; background: none;
  color: var(--panel-muted);
  font-size: 14px; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--panel-text); }

/* ============ Modals (classic) ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in 0.18s ease;
}
.modal-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  margin: 0;
  background: var(--panel-bg); color: var(--panel-text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: var(--ui-font);
  overflow: hidden;
  animation: pop-in 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--field-border); border-radius: 3px;
  background: transparent; color: var(--panel-text);
  font-family: var(--ui-font);
  font-size: 14px; font-weight: 700;
  transition: background-color 0.15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--cbtn-bg); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--cbtn-hover); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 4px;
  background: transparent; color: var(--panel-muted);
}
.icon-btn:hover { background: var(--hover); color: var(--panel-text); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--panel-border);
}
[dir="rtl"] .modal-head { padding: 12px 20px 12px 12px; }
.modal-head h2 { margin: 0; padding: 4px 0; font-size: 1.1rem; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }

.winner-head {
  padding: 14px 20px;
  background: var(--winner-color, var(--cbtn-bg));
  color: var(--winner-ink, #fff);
  font-weight: 800; font-size: 1.05rem; text-align: center;
}
.winner-body { padding: 26px 24px 18px; text-align: center; overflow-y: auto; }
.winner-img {
  display: block; width: 120px; height: 120px; margin: 0 auto 14px;
  border-radius: 8px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.winner-wheel { color: var(--panel-muted); font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; }
.winner-name {
  font-family: var(--font);
  font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 800; line-height: 1.2;
  overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.winner-list { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.winner-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border); border-radius: 6px;
}
.winner-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; }
.winner-row .w-wheel { color: var(--panel-muted); font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.winner-row .w-name { flex: 1; font-family: var(--font); font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.winner-row img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
.winner-note { margin: -6px 24px 10px; color: var(--panel-muted); text-align: center; font-size: 0.9rem; }
.winner-card .modal-actions { justify-content: center; }
.winner-card .modal-actions .btn { min-width: 120px; padding: 9px 18px; }

.settings-card { width: min(520px, 100%); }
.settings-body { display: flex; flex-direction: column; gap: 18px; padding: 18px 20px; overflow-y: auto; }
.settings-section {
  margin: 4px 0 -4px; padding-top: 14px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.95rem; font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-label { font-weight: 700; font-size: 0.92rem; padding: 0; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.field output { font-weight: 800; }
.field input[type="text"] {
  padding: 9px 11px;
  border: 1px solid var(--field-border); border-radius: 3px;
  background: var(--field-bg); color: var(--panel-text);
}
.field input[type="text"]:focus { outline: none; border-color: var(--panel-text); }
input[type="range"] { width: 100%; accent-color: var(--cbtn-bg); }

.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px;
  border: 2px solid var(--panel-border); border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch:hover { background: var(--hover); }
.swatch:has(input:checked) { border-color: var(--cbtn-bg); background: var(--hover); }
@media (prefers-color-scheme: dark) { .swatch:has(input:checked) { border-color: #8C92D9; } }
.swatch:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch-wheel { width: 44px; height: 44px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.12); }
.swatch-name { font-size: 0.85rem; font-weight: 700; }

.toggles { display: flex; flex-direction: column; gap: 12px; }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; font-size: 0.95rem; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative; flex: none;
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--field-border);
  transition: background-color 0.2s;
}
.switch::after {
  content: "";
  position: absolute; top: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: inset-inline-start 0.2s;
}
.toggle input:checked + .switch { background: var(--cbtn-bg); }
@media (prefers-color-scheme: dark) { .toggle input:checked + .switch { background: #6B71C2; } }
.toggle input:checked + .switch::after { inset-inline-start: 21px; }
.toggle input:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }

.rename-card { width: min(400px, 100%); }

/* Edit title & description dialog */
.title-card { width: min(640px, 100%); }
.title-card-head { display: flex; align-items: center; gap: 10px; padding: 22px 20px 6px; }
.title-card-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
.title-card-head .pico { width: 20px; height: 20px; }
.title-card-body { display: flex; flex-direction: column; gap: 16px; padding: 18px 16px 8px; }
.filled-input {
  width: 100%;
  padding: 13px 12px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--panel-text) 9%, transparent);
  color: var(--panel-text);
  font-family: var(--ui-font); font-size: 15px;
  transition: background-color 0.15s, border-color 0.15s;
}
.filled-input::placeholder { color: var(--panel-muted); }
.filled-input:hover { background: color-mix(in srgb, var(--panel-text) 12%, transparent); }
.filled-input:focus { outline: none; border-bottom-color: #5B5FEF; }
textarea.filled-input { min-height: 126px; resize: vertical; line-height: 1.5; unicode-bidi: plaintext; }
input.filled-input { unicode-bidi: plaintext; }
.btn.text { border-color: transparent; background: transparent; }
.btn.text:hover { background: var(--hover); }
.title-card .modal-actions { padding: 10px 12px 12px; gap: 6px; }
.ok-btn { min-width: 64px; background: #4B47B5; }
.ok-btn:hover { background: #5A56C9; }
.changelog-card { width: min(520px, 100%); }
.cl-version { margin: 0 0 6px; font-size: 1rem; font-weight: 700; }
.cl-list { margin: 0; padding-inline-start: 20px; color: var(--panel-muted); line-height: 1.7; font-size: 0.92rem; }

/* ============ Gallery ============ */
.gallery-card { width: min(720px, 100%); }
.gallery-body { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 22px; overflow-y: auto; }
.help { margin: 0; color: var(--panel-muted); font-size: 0.88rem; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px 14px;
  border: 1px solid var(--panel-border); border-radius: 6px;
  background: transparent; color: var(--panel-text);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
.gallery-item:hover { border-color: var(--panel-text); background: var(--hover); }
.gallery-wheel {
  position: relative;
  width: 76px; height: 76px; border-radius: 50%;
  box-shadow: 0 0 0 4px var(--rim), 0 6px 14px rgba(0, 0, 0, 0.2);
}
.gallery-wheel::after { content: ""; position: absolute; inset: 38%; border-radius: 50%; background: #fff; }
.gallery-name { font-family: var(--font); font-weight: 800; font-size: 1rem; }
.gallery-count { color: var(--panel-muted); font-size: 0.82rem; }

/* ============ Confetti & toast ============ */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70;
  max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  border-radius: 4px;
  background: #323232; color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-family: var(--ui-font);
  font-size: 14px; font-weight: 500;
  opacity: 0; transform: translate(-50%, 20px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.show.has-action { pointer-events: auto; }
.toast-action {
  padding: 4px 8px; border: 0; border-radius: 3px;
  background: transparent; color: #FFD166;
  font-weight: 700; text-transform: uppercase;
}
.toast-action:hover { background: rgba(255, 255, 255, 0.1); }

/* ============ Responsive ============ */
@media (max-width: 1240px) {
  .tb-btn .label { display: none; }
  .tb-btn { padding: 0 11px; }
}
@media (max-width: 960px) {
  .layout, .layout.panel-hidden { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 20px; }
  .panel { position: relative; top: 0; }
  #entries { height: 260px; }
  .adv-list { height: 300px; }
  .results { max-height: 360px; }
  .wheels[data-count="1"] .wheel-wrap { width: min(calc(100% - 32px), 620px); }
  .collapse-btn:not(.show) { display: none; }
  .collapse-btn.show { display: none !important; }
}
@media (max-width: 640px) {
  .topbar { height: 50px; padding-inline-end: 6px; }
  .brand { padding-inline: 10px; }
  .toolbar { gap: 0; }
  .tb-btn { padding: 0 8px; }
  .more-label, .tico.caret { display: none; }
  .tico.more-dots { display: block; }
  .brand-name { display: none; }
  .wheels:not([data-count="1"]) .wheel-unit { width: 100%; }
  .wheels:not([data-count="1"]) .wheel-wrap { width: min(calc(100% - 32px), 520px); }
}

@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
  .modal, .modal-card, .tb-menu { animation: none; }
}

/* ============ Logo ============ */
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 7px; }
