@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #2A2420;
  --ink-deep: #1B1613;
  --surface: #211B18;
  --surface-2: #2C2521;
  --line: rgba(255, 252, 245, 0.14);
  --cream: #FFFCF5;
  --muted: rgba(255, 252, 245, 0.68);
  --green: #00C753;
  --green-deep: #0E3D22;
  --green-light: #78F874;
  --danger: #F4A19B;
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink-deep);
  color: var(--cream);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  background: var(--ink) url("../assets/bg.webp") center / cover no-repeat;
}

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 33vw);
  align-items: center;
  padding: 0 3vw 0 2vw;
  gap: 2vw;
}

.wheel-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-width: 0;
}
#wheel {
  height: min(88vh, 62vw);
  width: min(88vh, 62vw);
  display: block;
  overflow: visible;
}

.side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2.4vh;
  min-width: 0;
}
.lockup { height: clamp(34px, 6.2vh, 72px); width: auto; display: block; }

h1 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(18px, 1.75vw, 40px);
  letter-spacing: 0.26em;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--cream);
  overflow-wrap: anywhere;
}

.prize { display: flex; flex-direction: column; gap: 0.6vh; }
.eyebrow {
  font-size: clamp(11px, 0.95vw, 20px);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green);
}
.prize-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 144;
  font-size: clamp(22px, 2.6vw, 56px);
  line-height: 1.15;
  letter-spacing: -0.005em;
  word-spacing: 0.06em;
  color: var(--cream);
  overflow-wrap: anywhere;
}

.spin {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: clamp(16px, 1.9vw, 42px);
  letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--green);
  padding: 0.7em 1.3em;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0.2em 0 var(--green-deep), 0 0.5em 1.4em rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
  white-space: nowrap;
}
.spin:hover:not(:disabled) { background: #1AD266; }
.spin:active:not(:disabled) {
  transform: translateY(0.2em);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 var(--green-deep), 0 0.2em 0.8em rgba(0, 0, 0, 0.35);
}
.spin:disabled { cursor: default; background: #2F5A41; color: rgba(255, 252, 245, 0.6); box-shadow: 0 0.2em 0 #17261E; }
.spin:focus-visible, .tool:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .field:focus-visible, summary:focus-visible {
  outline: 3px solid var(--green-light);
  outline-offset: 3px;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: clamp(13px, 1.1vw, 24px);
  letter-spacing: 0.04em;
}

.tools {
  position: fixed;
  top: 2vh;
  right: 2vw;
  display: flex;
  gap: 0.6vw;
}
.tool {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--cream);
  background: rgba(27, 22, 19, 0.82);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font: 600 14px/1 var(--font-sans);
  letter-spacing: 0.04em;
}
.tool:hover { border-color: rgba(0, 199, 83, 0.6); }
.tool:disabled { opacity: 0.4; cursor: default; }
.tool svg { width: 18px; height: 18px; fill: currentColor; }

.hints {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.6vh;
  margin: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255, 252, 245, 0.5);
}

/* Winner reveal */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at 50% 45%, #0F3A22 0%, #17251C 38%, #14100E 100%);
  cursor: pointer;
  animation: reveal-in 0.35s ease-out both;
}
@keyframes reveal-in { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
.reveal-inner { max-width: 90vw; display: flex; flex-direction: column; align-items: center; gap: 2.4vh; }
.reveal-logo { width: clamp(64px, 11vh, 130px); height: auto; }
.reveal-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 144;
  font-size: clamp(40px, 11vw, 230px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--cream);
  overflow-wrap: anywhere;
}
.reveal-name.long { font-size: clamp(34px, 7vw, 150px); }
.reveal-name.xlong { font-size: clamp(30px, 4.6vw, 100px); }
.reveal-sub {
  font-weight: 700;
  font-size: clamp(20px, 2.8vw, 60px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
}
.reveal-prize {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(22px, 3vw, 64px);
  color: var(--cream);
  padding-top: 1.4vh;
  border-top: 1px solid var(--line);
  min-width: 30vw;
}
.reveal-hint { font-size: 14px; letter-spacing: 0.08em; color: rgba(255, 252, 245, 0.5); }

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.reveal-inner { position: relative; z-index: 1; }
.tools, .hints { transition: opacity 0.4s ease; }
body.idle .tools, body.idle .hints { opacity: 0; pointer-events: none; }
body.idle { cursor: none; }

/* Setup panel */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  z-index: 30;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  font-size: 15px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.01em; }
.panel-body { overflow-y: auto; padding: 8px 20px 40px; }
.panel section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.panel section:last-child { border-bottom: 0; }
.panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
}
.count { color: var(--muted); font-weight: 600; letter-spacing: 0.04em; margin-left: 6px; text-transform: none; }

.field {
  width: 100%;
  background: var(--ink-deep);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font: 500 15px/1.3 var(--font-sans);
}
.field:focus { border-color: rgba(0, 199, 83, 0.7); outline: none; }
.field:focus-visible { outline: 2px solid var(--green-light); outline-offset: 1px; }
textarea.field { resize: vertical; margin-bottom: 8px; }

.btn {
  appearance: none;
  cursor: pointer;
  color: var(--cream);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  font: 600 14px/1 var(--font-sans);
  white-space: nowrap;
}
.btn:hover { border-color: rgba(0, 199, 83, 0.6); }
.btn-primary { background: var(--green); color: var(--ink); border-color: var(--green); }
.btn-primary:hover { background: #1AD266; }
.btn-danger { background: #5A2623; border-color: #93302D; color: #FFE9E7; }
.btn-danger:hover { background: #7A302C; }

.rows { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 6px; }
.row .num { width: 22px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row.out .field { opacity: 0.45; text-decoration: line-through; }
.row .tag { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--green); white-space: nowrap; }
.icon-btn {
  appearance: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cream);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}
.icon-btn:hover:not(:disabled) { border-color: rgba(0, 199, 83, 0.6); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.add-row { display: flex; gap: 8px; }
.paste { margin-top: 10px; }
.paste summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.notice { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #93302D; border-radius: 8px; background: #3A1E1C; color: #FFE9E7; font-size: 14px; }
.winner-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 10px; background: var(--ink-deep); border: 1px solid var(--line); border-radius: 8px; }
.winner-row .w-name { font-weight: 600; }
.winner-row .w-prize { color: var(--muted); font-size: 13px; }
.confirm-text { margin: 0 0 10px; }
.confirm-actions { display: flex; gap: 8px; }

@media (max-aspect-ratio: 1/1) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; padding: 70px 4vw 40px; align-items: start; }
  .side { align-items: center; text-align: center; order: -1; }
  #wheel { height: min(60vh, 92vw); width: min(60vh, 92vw); }
}
@media (max-height: 820px) {
  .hints { font-size: 12px; }
  .tool { padding: 7px 11px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
}
