/* Light by default; dark follows the system unless the toggle forces a theme. */
:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-2: #f4f4f5;
  --hover: #ececee;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --accent: #ffd23f;
  --accent-hover: #ffc80a;
  --accent-ink: #1a1500;
  --accent-text: #a16207;
  --accent-soft: rgba(234, 179, 8, .1);
  --coral: #e11d48;
  --teal: #0d9488;
  --ok: #16a34a;
  --ok-line: rgba(22, 163, 74, .35);
  --topbar: rgba(250, 250, 250, .85);
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 1px 3px rgba(24, 24, 27, .06);
  --radius: 10px;
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f; --panel: #131418; --panel-2: #1b1d22; --hover: #23262c; --line: #26282f; --line-strong: #363a43;
    --text: #f4f4f5; --muted: #a1a1aa; --accent-text: #ffd23f; --accent-soft: rgba(255, 210, 63, .08);
    --coral: #ff5d73; --teal: #2ec4b6; --ok: #4ade80; --ok-line: rgba(74, 222, 128, .4);
    --topbar: rgba(11, 12, 15, .85); --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0f; --panel: #131418; --panel-2: #1b1d22; --hover: #23262c; --line: #26282f; --line-strong: #363a43;
  --text: #f4f4f5; --muted: #a1a1aa; --accent-text: #ffd23f; --accent-soft: rgba(255, 210, 63, .08);
  --coral: #ff5d73; --teal: #2ec4b6; --ok: #4ade80; --ok-line: rgba(74, 222, 128, .4);
  --topbar: rgba(11, 12, 15, .85); --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); }
code, .mono { font-family: var(--mono); font-size: .85em; }
kbd { font: 600 .7em var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; margin-left: 6px; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Controls */
.btn {
  font: 500 .9rem var(--font); color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; box-shadow: var(--shadow);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--hover); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ok { color: var(--ok); }
.btn.bad { color: var(--coral); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { font-size: 1rem; padding: 12px 22px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; font: 14px/1.45 var(--mono); }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent-text); }
input:disabled, textarea:disabled, select:disabled { opacity: .5; }
label { display: grid; gap: 5px; font-size: .9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.pill { font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.live { color: var(--ok); border-color: var(--ok-line); }
.note { font-size: .85rem; background: var(--accent-soft); border: 1px solid rgba(234, 179, 8, .35); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 26px; height: 26px; flex: none; background: url(../logo-mark.svg) center / contain no-repeat; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark { background-image: url(../logo-mark-dark.svg); } }
:root[data-theme="dark"] .brand-mark { background-image: url(../logo-mark-dark.svg); }
.theme-toggle { width: 36px; height: 36px; padding: 0; }
.theme-toggle svg { width: 18px; height: 18px; }

/* App shell */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--topbar); backdrop-filter: saturate(1.4) blur(10px); z-index: 20; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.app { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; padding: 20px; max-width: 1440px; margin: 0 auto; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.stage-head { display: flex; gap: 12px; align-items: center; }
.title-input { flex: 1; min-width: 0; font: 600 1.5rem var(--font); background: transparent; border-color: transparent; padding: 4px 6px; letter-spacing: -.02em; }
.title-input:hover { border-color: var(--line); }
.wheel-box { position: relative; width: 100%; max-width: 620px; aspect-ratio: 1; margin: 0 auto; }
.wheel-box canvas { position: absolute; inset: 0; margin: auto; }
.ticker { text-align: center; font-weight: 600; font-size: 1.5rem; min-height: 2.2rem; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.winner-card { background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 18px 22px; text-align: center; }
.wc-prize { font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.wc-name { font-weight: 700; letter-spacing: -.02em; font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.1; margin: 4px 0; overflow-wrap: anywhere; }
.wc-timer { font: 600 .95rem var(--mono); }
.proof { display: grid; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.proof > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.proof code { overflow-wrap: anywhere; color: var(--text); }
.label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.done-note { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
#editEntriesBtn { display: none; }
.log { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.log h3 { font-size: 1rem; }
.log ol { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; font-size: .85rem; }
.log li { padding: 5px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.log li span { min-width: 0; overflow-wrap: anywhere; }
.log li time { font-family: var(--mono); color: var(--muted); flex: none; }

.side { display: grid; gap: 14px; align-content: start; position: sticky; top: 72px; }
.tabs { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; gap: 2px; }
.tabs button { flex: 1; font: 500 .85rem var(--font); color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 8px 4px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tab-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.steps { margin: 0; padding: 0 0 0 1.2em; display: grid; gap: 14px; }
.steps li::marker { color: var(--accent-text); font-weight: 700; }
.steps p { margin: 2px 0 8px; font-size: .85rem; color: var(--muted); }
.prize-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.prize-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.prize-list li.done { color: var(--muted); text-decoration: line-through; }
.prize-list li.next { color: var(--accent-text); font-weight: 500; }
/* Ad slots stay hidden until AdSense is live: add class "live" to show them. */
.ad-slot:not(.live) { display: none; }
.ad-slot { min-height: 250px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; opacity: 0; transition: .2s; pointer-events: none; z-index: 70; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 16px; }
dialog dt kbd { margin: 0; opacity: 1; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .side { position: static; min-width: 0; }
  .topbar { padding: 10px 16px; }
  #openOverlay { display: none; }
}
@media (max-width: 960px) {
  #editEntriesBtn { display: inline-flex; }
}
@media (hover: none) {
  .controls kbd { display: none; }
}
@media (max-width: 600px) {
  #syncStatus { display: none; }
  .proof > div { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 520px) {
  .controls .btn { flex: 1 1 100%; }
  .title-input { font-size: 1.25rem; }
  .label { width: 80px; }
}

/* Style tab */
.sub { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 6px 0 -2px; }
.sub:first-child { margin-top: 0; }
input[type="color"] { width: 100%; height: 38px; padding: 3px; cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches .sw { position: relative; }
.swatches input[type="color"] { width: 40px; height: 40px; }
.swatches .sw button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; padding: 0; display: none; }
.swatches .sw:hover button, .swatches .sw:focus-within button { display: block; }
.swatches .add { width: 40px; height: 40px; border: 1px dashed var(--line); border-radius: 8px; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.color-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 8px; }
.img-slot { display: grid; grid-template-columns: 56px 1fr; gap: 6px 12px; align-items: center; }
.img-slot p { margin: 2px 0 0; }
.img-slot .thumb { width: 56px; height: 56px; border-radius: 8px; border: 1px dashed var(--line); background: var(--bg) center / cover no-repeat; grid-row: span 2; }
.img-slot .thumb.has { border-style: solid; }
.img-slot .img-actions { display: flex; gap: 6px; grid-column: 2; }
.img-slot .img-actions .btn { padding: 6px 10px; font-size: .85rem; }
.wheel-box.has-bg { background: center / cover no-repeat; border-radius: 16px; }
@media (max-width: 900px) {
  .topbar .btn { min-height: 40px; }
  .topbar .theme-toggle { width: 40px; }
}
@media (max-width: 600px) {
  .stage-head { flex-wrap: wrap; }
  .stage-head .title-input { flex: 1 1 100%; }
}

/* Ko-fi tip button: same link and colour as Ko-fi's widget, without its document.write script. */
.kofi-btn { display: inline-flex; align-items: center; gap: 8px; background: #72a4f2; color: #fff; font: 600 .9rem var(--font); padding: 8px 14px; border-radius: 8px; text-decoration: none; box-shadow: var(--shadow); white-space: nowrap; }
.kofi-btn:hover { background: #5b93ec; }
.kofi-btn img { width: 20px; height: auto; }
.support-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; justify-items: start; box-shadow: var(--shadow); }
.support-card p { margin: 0; font-size: .85rem; color: var(--muted); }
