: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, textarea, select {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

textarea { resize: vertical; font: inherit; color: inherit; }
input[type="checkbox"] { width: auto; }

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

/* Retro: live room */

.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.5rem; background: var(--border); }
.dot.online { background: var(--slice-4); }
.dot.online + .dot.online { margin-left: -0.2rem; }
.status-bar { top: 4.5rem; }
.room-page { max-width: 72rem; margin: 0 auto; padding: 0 16px 3rem; }
.room-page > .card, .room-page > section { margin-top: 1rem; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; align-items: start; }
.column h3 { margin: 0; }
.my-card { display: flex; gap: 0.5rem; justify-content: space-between; align-items: flex-start; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.my-card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.retro-item { display: flex; gap: 0.5rem; justify-content: space-between; align-items: center; }
/* Who is here: dot, then name, then (facilitator), all left-aligned. */
.people li { justify-content: flex-start; gap: 0; }
.people .dot { flex: none; }

.kicker { margin: 1rem 0 0; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.stepbar { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.stepbar span {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
}
.stepbar span[aria-current="step"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.meeting-status,
.fac-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.fac-bar {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.meeting-status .spacer,
.fac-bar .spacer { flex: 1 1 1rem; }
.fac-bar .tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.timer { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2rem; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; align-items: start; }
.vote-table, .topic-table { width: 100%; border-collapse: collapse; }
.vote-table th, .vote-table td, .topic-table th, .topic-table td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.topic-table tr[aria-current="true"] { background: var(--win-bg); }
.discuss-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; align-items: start; }
#export-box, #export-fallback { width: 100%; min-height: 8rem; font-family: ui-monospace, monospace; }
.vote-count { font-weight: 700; color: var(--accent); }
.group-box h3 { margin: 0; }
.group-box input { margin-top: 0.35rem; }
.group-box .list li { flex-direction: column; align-items: stretch; }
.group-box .list li p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.draggable { cursor: grab; touch-action: none; user-select: none; }
.draggable.dragging { opacity: 0.35; }
.drop-hover { outline: 2px solid var(--accent); outline-offset: 2px; }
.drag-ghost {
  position: fixed;
  z-index: 30;
  max-width: 16rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}
#room-settings { width: min(32rem, calc(100vw - 32px)); }
#handover-to { width: auto; flex: 1 1 10rem; }

/* Polish: phone and tablet layout, spacing in the panels, empty states. */
.header-meta { flex-wrap: wrap; justify-content: flex-end; }
#you { white-space: nowrap; }
.stack > p, .stack > ul { margin: 0; }
.stack > h3, .stack > h4 { margin: 0.5rem 0 0; }
h4 { font-size: 0.95rem; line-height: 1.2; }
.empty { border-bottom: none !important; justify-content: flex-start !important; }
.card.stack textarea[readonly] { min-height: 6rem; }
details > summary { cursor: pointer; padding: 0.15rem 0; }
.my-card .row { flex: none; }
button, select, input[type="date"] { min-height: 2.25rem; }
button.link { min-height: 0; }
table { max-width: 100%; }
.topic-name { overflow-wrap: anywhere; margin-bottom: 0.25rem; }
#vote-panel .vote-table td input { font-size: 0.85rem; padding: 0.2rem 0.4rem; min-height: 0; width: 100%; max-width: 16rem; }
@media (max-width: 640px) {
  /* The notice sits at the bottom so it does not cover the room name, and
     lets taps through to whatever is under it. */
  .notice { top: auto; bottom: 1rem; pointer-events: none; }
  .room-header { padding-top: 0.75rem; }
  .header-meta { justify-content: flex-start; }
  .fac-bar button, .stepbar span { font-size: 0.85rem; }
  .columns, .groups, .discuss-layout { grid-template-columns: minmax(0, 1fr); }
  #vote-panel .vote-table tr:first-child { display: none; }
  #vote-panel .vote-table tr {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }
  #vote-panel .vote-table td { border: 0; padding: 0; }
  #vote-panel .vote-table td:first-child { grid-column: 1 / -1; }
  /* The actions table becomes one block per action. */
  #actions-list .vote-table tr:first-child { display: none; }
  #actions-list .vote-table, #actions-list .vote-table tbody { display: block; }
  #actions-list .vote-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.5rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
  }
  #actions-list .vote-table td { border: 0; padding: 0; }
  #actions-list .vote-table td:nth-child(1),
  #actions-list .vote-table td:nth-child(2) { grid-column: 1 / -1; }
  #actions-list .vote-table td:nth-child(2):empty { display: none; }
  #action-form { flex-direction: column; align-items: stretch; }
  dialog { padding: 1rem; }
  .retro-item { flex-wrap: wrap; }
  #history-list li, #retro-list li { flex-wrap: wrap; justify-content: flex-start; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .columns { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
}

/* A topic row the facilitator can click to discuss. */
.topic-table tr.pickable { cursor: pointer; }
.topic-table tr.pickable:hover td, .topic-table tr.pickable:focus-visible td { background: var(--hover, rgba(127, 127, 127, 0.15)); }
