:root {
  --bg: #0e1120;
  --bg-2: #151a2e;
  --panel: #1a2038;
  --line: #2c3456;
  --text: #eef0f8;
  --muted: #9ba3c4;
  --brass: #f0b84a;
  --brass-hi: #ffd98a;
  --brass-lo: #a8741c;
  --steel: #c9cfdf;
  --bad: #ff5c7a;
  --good: #3ddc97;
  --radius: 18px;
  --display: "Bungee", system-ui, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -200px, #26305a 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--brass);
  text-decoration: none;
}
.brand svg { width: 26px; height: 26px; }

h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 8px;
}
h1 { font-size: clamp(30px, 8vw, 40px); }
h2 { font-size: 20px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 18px;
}

label { display: block; font-weight: 600; margin: 16px 0 6px; }
label:first-child { margin-top: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: 14px; }

input[type="text"], input[type="url"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--brass); }
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.03em;
  color: #241703;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, var(--brass-lo));
  border: 0;
  border-radius: 14px;
  padding: 15px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #6d4b10, 0 8px 24px rgba(240, 184, 74, 0.25);
  transition: transform 0.08s, box-shadow 0.08s;
  text-decoration: none;
  margin-top: 18px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #6d4b10; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.secondary {
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: none;
  font-family: var(--body);
  font-weight: 700;
  font-size: 16px;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.error { color: var(--bad); font-weight: 600; margin-top: 12px; min-height: 1.5em; }

/* Mode picker */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.mode {
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.mode:active { transform: scale(0.98); }
.mode[aria-pressed="true"] { border-color: var(--brass); background: #22284a; }
.mode .icon { font-size: 28px; line-height: 1; }
.mode b { display: block; font-family: var(--display); font-weight: 400; font-size: 18px; margin: 8px 0 2px; }
.mode span { color: var(--muted); font-size: 14px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.seg button {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 4px;
  cursor: pointer;
}
.seg button span { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.seg button[aria-checked="true"] { border-color: var(--brass); background: #22284a; }

.expiry {
  display: table;
  margin: 4px auto 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brass-hi);
  background: rgba(240, 184, 74, 0.12);
}
.expiry.soon { color: var(--bad); background: rgba(255, 92, 122, 0.14); }

/* ---------- Padlock ---------- */
/* Kept narrower than the screen on purpose: the wheels capture swipes, so the
   page needs free space beside the lock for scrolling. */
.padlock {
  position: relative;
  width: min(300px, 76%);
  margin: 8px auto 0;
  user-select: none;
  -webkit-user-select: none;
}
.shackle {
  display: block;
  width: 62%;
  margin: 0 auto -6px;
  position: relative;
  z-index: 0;
  transform-origin: 18% 100%;
  transition: transform 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.padlock.open .shackle { transform: translateY(-34px); }
.lock-body {
  position: relative;
  z-index: 1;
  border-radius: 26px;
  padding: 22px 18px 20px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.35), transparent 40%),
    linear-gradient(180deg, var(--brass-hi), var(--brass) 45%, var(--brass-lo));
  box-shadow:
    inset 0 -6px 0 rgba(0, 0, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 18px 40px rgba(0, 0, 0, 0.45);
}
.lock-body .rivets { display: flex; justify-content: space-between; padding: 0 4px 10px; }
.lock-body .rivets i {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2c9, var(--brass-lo));
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.wheels {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #1b1405;
  border-radius: 14px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.8);
  position: relative;
}
/* the reading line across the middle row */
.wheels::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  top: 50%;
  height: var(--cell);
  transform: translateY(-50%);
  border-top: 2px solid rgba(255, 60, 60, 0.75);
  border-bottom: 2px solid rgba(255, 60, 60, 0.75);
  pointer-events: none;
  border-radius: 4px;
}
.padlock.compact { width: min(240px, 64%); }
.wheels { --cell: 48px; }
.padlock.compact .wheels { --cell: 40px; gap: 6px; padding: 8px; }
.padlock.compact .strip span { font-size: 28px; }
.wheel {
  position: relative;
  flex: 1;
  max-width: 62px;
  height: calc(var(--cell) * 3);
  overflow: hidden;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
  background: linear-gradient(90deg, #8d939f, #eef1f6 30%, #ffffff 50%, #d9dde6 70%, #7b818d);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.wheel:active { cursor: grabbing; }
.wheel:focus-visible { outline: 3px solid #7fb2ff; outline-offset: 2px; }
/* curved-drum shading */
.wheel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, 0.75));
  pointer-events: none;
  z-index: 1;
}
.strip { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.strip.animate { transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.strip span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--cell);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 34px;
  color: #1c2030;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}
.padlock.shake .lock-body { animation: shake 0.45s; }
.padlock.shake .wheels::after { border-color: var(--bad); }
.padlock.open .wheels::after { border-color: var(--good); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-1.5deg); }
  40% { transform: translateX(9px) rotate(1.5deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.wheel-hint { text-align: center; color: var(--muted); font-size: 14px; margin-top: 12px; }

/* ---------- Riddle ---------- */
.riddle-card {
  position: relative;
  background: #f6ecd6;
  color: #2b2113;
  border-radius: 6px;
  padding: 26px 22px 22px;
  margin-top: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
  transform: rotate(-0.6deg);
}
.riddle-card::before {
  content: "?";
  position: absolute;
  top: -18px; left: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--display);
  font-size: 20px;
  color: #241703;
  background: var(--brass);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
.riddle-form.shake { animation: shake 0.45s; }
.riddle-form.shake input { border-color: var(--bad); }

/* ---------- Results ---------- */
.result-icon { font-size: 64px; line-height: 1; margin: 12px 0; }
.prize {
  margin-top: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.prize img, .prize video, .prize iframe {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  margin-top: 12px;
  background: #000;
}
.prize iframe { aspect-ratio: 16 / 9; height: auto; }
.prize a { color: var(--brass-hi); }
.prize .text:empty { display: none; }

.share-link {
  font-family: var(--mono);
  font-size: 15px;
  background: var(--bg-2);
  border: 1px dashed var(--brass);
  border-radius: 12px;
  padding: 12px;
  word-break: break-all;
  margin-top: 12px;
  user-select: all;
}

.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stat b { font-weight: 700; }

.cta { text-align: center; border-color: var(--brass-lo); background: linear-gradient(180deg, #232a4d, var(--panel)); }
.cta .btn { margin-top: 8px; }
a.link { color: var(--brass); font-weight: 600; }

/* ---------- Help links & guide ---------- */
a.help { color: var(--brass); font-size: 14px; font-weight: 600; text-decoration: none; }
a.help::after { content: " →"; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#riddleFields a.help { display: inline-block; margin-top: 8px; }

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.toc a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.guide section { scroll-margin-top: 16px; }
.guide h3 { font-size: 16px; margin: 18px 0 6px; }
.guide a:not(.btn):not(.brand) { color: var(--brass); }
.steps { margin: 8px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 8px; }
.idea { padding: 12px 0; border-bottom: 1px solid var(--line); }
.idea:last-child { border-bottom: 0; }
.idea p { margin: 4px 0 0; color: var(--muted); }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
details:last-child { border-bottom: 0; }
summary { cursor: pointer; font-weight: 700; }
details p { margin: 8px 0 0; color: var(--muted); }

footer { text-align: center; margin-top: 36px; color: var(--muted); font-size: 14px; }
footer a { color: var(--brass); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px; height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (max-width: 360px) {
  .wheels { --cell: 44px; gap: 6px; }
  .strip span { font-size: 30px; }
}
