:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #ddd8cc;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --danger: #b42318;
  --win-bg: #fff4d6;
  --focus: #2563eb;
  --slice-1: #e8a33d;
  --slice-2: #357893;
  --slice-3: #c2553a;
  --slice-4: #5a9e6f;
  --slice-5: #8064b4;
  --slice-6: #d9775c;
  --slice-7: #3f6e9e;
  --slice-8: #b98a2e;
  --slice-text: #ffffff;
  --slice-text-dark: #1f2328;
  --wheel-font: system-ui, sans-serif;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1e2125;
    --text: #e8e6e1;
    --muted: #a0a6ae;
    --border: #33373d;
    --accent: #f08a4b;
    --accent-text: #15171a;
    --danger: #f97066;
    --win-bg: #3a2f14;
    --focus: #60a5fa;
    --slice-1: #c9892b;
    --slice-2: #2f6e88;
    --slice-3: #b14a31;
    --slice-4: #43805a;
    --slice-5: #7559a8;
    --slice-6: #b65c44;
    --slice-7: #355d87;
    --slice-8: #8f6a1f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1e2125;
  --text: #e8e6e1;
  --muted: #a0a6ae;
  --border: #33373d;
  --accent: #f08a4b;
  --accent-text: #15171a;
  --danger: #f97066;
  --win-bg: #3a2f14;
  --focus: #60a5fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }

a { color: var(--accent); }

button, input {
  font: inherit;
  color: inherit;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.big { font-size: 1.25rem; padding: 0.75rem 2.5rem; }
button.icon { padding: 0.25rem 0.55rem; background: transparent; }
button.link { border: none; background: none; padding: 0.2rem 0.4rem; color: var(--accent); }

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

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.landing { max-width: 32rem; margin: 10vh auto; padding: 0 16px; }
.landing .card { margin-top: 1.5rem; }

.room-header {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 16px 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.title-row { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.title-row h1 { margin: 0; overflow-wrap: anywhere; }
.header-meta { display: flex; align-items: center; gap: 0.5rem; }

.layout {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 16px 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
@media (max-width: 640px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}

.stage { display: flex; flex-direction: column; gap: 1rem; }

.wheel-area {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 1;
}
.wheel-area canvas { width: 100%; height: 100%; display: block; }
.pointer {
  position: absolute;
  top: 50%;
  right: -6px;
  translate: 0 -50%;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 26px solid var(--text);
  z-index: 1;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.3));
}
.pointer-label {
  position: absolute;
  bottom: -2.25rem;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 600;
}

.result { text-align: center; }
.result p { margin: 0; }
.result-name {
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0.25rem 0 0.75rem !important;
  overflow-wrap: anywhere;
}
.result .row { justify-content: center; }

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.tabs button {
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  padding: 0.6rem 0.9rem;
  color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.list, .tick-list, .history { list-style: none; margin: 0; padding: 0; }
.list li, .tick-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.tick-list label { display: flex; gap: 0.6rem; align-items: center; cursor: pointer; width: 100%; }
.tick-list input { width: auto; }
#setup-list { max-height: 22rem; overflow-y: auto; }

#add-form { margin-bottom: 0.75rem; flex-wrap: nowrap; }

.history li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.history li.win { background: var(--win-bg); font-weight: 600; border-radius: 6px; }
.history time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
#history-more { margin-top: 0.75rem; }

.segmented { display: inline-flex; margin-bottom: 0.75rem; }
.segmented button { border-radius: 0; }
.segmented button:first-child { border-radius: 8px 0 0 8px; }
.segmented button:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px dashed var(--border); }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
  width: min(26rem, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin-bottom: 0; }

.notice {
  position: fixed;
  top: 1rem;
  left: 50%;
  translate: -50% 0;
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  z-index: 20;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}

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

[hidden] { display: none !important; }

#new-wheel-button { margin-top: 1rem; }

.privacy { margin-top: 2rem; }
.privacy h2 { margin-bottom: 0.25rem; }
.privacy p { margin: 0 0 0.5rem; }

/* Decoration that only the "Early 2000s website" theme shows. */
.retro-banner, .retro-footer { display: none; }

.theme-choices { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.theme-choices label { display: flex; gap: 0.6rem; align-items: center; cursor: pointer; }
.theme-choices input { width: auto; }

/* --- Theme: Early 2000s website ---
   A 2001 personal homepage. Set by data-theme-name="y2k" on <html>; it is
   always light, so it overrides the automatic dark mode above. */
:root[data-theme-name="y2k"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --muted: #333333;
  --border: #808080;
  --accent: #0000ee;
  --accent-text: #ffffff;
  --danger: #cc0000;
  --win-bg: #ffff99;
  --focus: #000000;
  --slice-1: #ff0000;
  --slice-2: #0000ff;
  --slice-3: #ffff00;
  --slice-4: #009900;
  --slice-5: #ff00ff;
  --slice-6: #00ffff;
  --slice-7: #ff9900;
  --slice-8: #9900cc;
  --slice-text: #ffffff;
  --slice-text-dark: #000000;
  --wheel-font: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  --radius: 0;
  color-scheme: light;
}

[data-theme-name="y2k"] body {
  font: 15px/1.45 Verdana, Geneva, Tahoma, sans-serif;
  /* A starry night sky, tiled. */
  background-color: #000066;
  background-image:
    radial-gradient(circle, #ffffff 1px, transparent 1.6px),
    radial-gradient(circle, #ffff66 1px, transparent 1.6px);
  background-size: 48px 48px, 80px 80px;
  background-position: 0 0, 24px 40px;
}

[data-theme-name="y2k"] h1 {
  font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  color: #000099;
  text-shadow: 2px 2px 0 #ffcc00;
}
[data-theme-name="y2k"] h2,
[data-theme-name="y2k"] h3 { font-family: "Times New Roman", Times, serif; color: #990000; }

[data-theme-name="y2k"] a { color: #0000ee; }
[data-theme-name="y2k"] a:visited { color: #551a8b; }

/* The page itself sits in a bordered "table" on the sky. */
[data-theme-name="y2k"] main.landing,
[data-theme-name="y2k"] #room {
  background: #ffffff;
  border: 4px ridge #c0c0c0;
}
[data-theme-name="y2k"] main.landing { margin: 1.5rem auto; padding: 1rem 16px 1.25rem; }
[data-theme-name="y2k"] #room { max-width: 72rem; margin: 1rem auto; }
@media (max-width: 640px) {
  [data-theme-name="y2k"] main.landing,
  [data-theme-name="y2k"] #room { margin: 0.5rem 4px; }
}
[data-theme-name="y2k"] .room-header { border-bottom: 2px groove #c0c0c0; padding-bottom: 0.75rem; }

[data-theme-name="y2k"] .card {
  background: #ffffcc;
  border: 3px ridge #c0c0c0;
}

/* Bevelled grey buttons, blue for the main action. */
[data-theme-name="y2k"] button {
  background: #c0c0c0;
  color: #000000;
  border: 2px outset #ffffff;
  border-radius: 0;
  font-family: Tahoma, Verdana, sans-serif;
}
[data-theme-name="y2k"] button:hover:not(:disabled) { border-color: #ffffff; background: #d4d0c8; }
[data-theme-name="y2k"] button:active:not(:disabled) { border-style: inset; }
[data-theme-name="y2k"] button.primary {
  background: linear-gradient(#3a6ea5, #0a246a);
  color: #ffffff;
  border: 2px outset #6f9fd8;
  font-weight: 700;
}
[data-theme-name="y2k"] button.primary:hover:not(:disabled) { background: linear-gradient(#4a80bb, #10308a); border-color: #6f9fd8; }
[data-theme-name="y2k"] button.danger { background: #c0c0c0; color: #cc0000; border-color: #ffffff; }
[data-theme-name="y2k"] button.icon { background: #c0c0c0; }
[data-theme-name="y2k"] button.link {
  background: none;
  border: none;
  color: #0000ee;
  text-decoration: underline;
  font-family: inherit;
}
[data-theme-name="y2k"] :focus-visible { outline: 2px dotted #000000; outline-offset: 2px; }

[data-theme-name="y2k"] input {
  border: 2px inset #c0c0c0;
  border-radius: 0;
  background: #ffffff;
  color: #000000;
}

[data-theme-name="y2k"] .tabs { border-bottom: 2px solid #808080; gap: 2px; }
[data-theme-name="y2k"] .tabs button {
  background: #c0c0c0;
  border: 2px outset #ffffff;
  border-bottom: none;
  color: #000000;
}
[data-theme-name="y2k"] .tabs button[aria-selected="true"] { background: #ffffcc; color: #000099; }

[data-theme-name="y2k"] .list li,
[data-theme-name="y2k"] .tick-list li,
[data-theme-name="y2k"] .history li { border-bottom: 1px dotted #808080; }
[data-theme-name="y2k"] .history li.win { border-radius: 0; }

[data-theme-name="y2k"] .segmented button:first-child,
[data-theme-name="y2k"] .segmented button:last-child { border-radius: 0; }
[data-theme-name="y2k"] .segmented button[aria-pressed="true"] { background: #0a246a; color: #ffffff; border-style: inset; }

[data-theme-name="y2k"] .result-name {
  font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  color: #cc0000;
}

/* Dialogs as an old desktop window, with a blue title bar. */
[data-theme-name="y2k"] dialog {
  background: #d4d0c8;
  border: 2px outset #ffffff;
  border-radius: 0;
  padding: 0 1rem 1rem;
  font-family: Tahoma, Verdana, sans-serif;
}
[data-theme-name="y2k"] dialog h2 {
  margin: 0 -1rem 0.25rem;
  padding: 0.3rem 0.6rem;
  background: linear-gradient(90deg, #0a246a, #a6caf0);
  color: #ffffff;
  font: 700 0.95rem Tahoma, Verdana, sans-serif;
}

[data-theme-name="y2k"] .notice {
  background: #ffffe1;
  color: #000000;
  border: 1px solid #000000;
  border-radius: 0;
}

[data-theme-name="y2k"] .retro-banner {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  background: #000000;
  color: #00ff00;
  font: 700 1rem "Courier New", Courier, monospace;
  padding: 0.3rem 0;
  border-bottom: 3px ridge #c0c0c0;
}
[data-theme-name="y2k"] .retro-banner span {
  display: inline-block;
  padding-left: 100%;
  animation: retro-marquee 18s linear infinite;
}
@keyframes retro-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

[data-theme-name="y2k"] .retro-footer {
  display: block;
  max-width: 40rem;
  margin: 1rem auto 2rem;
  padding: 0 16px;
  text-align: center;
  color: #ffffff;
  font: 0.85rem "Times New Roman", Times, serif;
}
[data-theme-name="y2k"] .retro-footer p { margin: 0.4rem 0; }
[data-theme-name="y2k"] .construction {
  display: inline-block;
  padding: 0.2rem 1rem;
  color: #000000;
  font: 700 0.85rem Verdana, sans-serif;
  text-transform: uppercase;
  background: #ffcc00;
  border: 6px solid #000000;
  border-image: repeating-linear-gradient(45deg, #ffcc00 0 8px, #000000 8px 16px) 6;
}
[data-theme-name="y2k"] .hit-counter {
  display: inline-block;
  padding: 0 0.3rem;
  background: #000000;
  color: #00ff00;
  border: 2px inset #808080;
  font: 700 1rem "Courier New", Courier, monospace;
  letter-spacing: 0.15em;
}

@media (prefers-reduced-motion: reduce) {
  [data-theme-name="y2k"] .retro-banner span { animation: none; padding-left: 0.5rem; }
}
