@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-opsz-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-opsz-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: italic;
  font-weight: 200 1000;
  font-display: swap;
  src: url("fonts/nunito-latin-wght-italic.woff2") format("woff2");
}

:root {
  --ink: #312e81;
  --ink-soft: #4338ca;
  --accent: #7c3aed;
  --accent-deep: #5b21b6;
  --accent-muted: #9333ea;
  --paper: #faf5ff;
  --paper-deep: #ede9fe;
  --line: rgba(139, 92, 246, 0.22);
  --line-strong: rgba(139, 92, 246, 0.45);
  --shadow: rgba(91, 33, 182, 0.06);
  --danger: #9f1239;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--ink-soft);
  background-color: var(--paper);
  background-image:
    radial-gradient(1100px 780px at 10% -8%, rgba(233, 213, 255, 0.85), transparent 52%),
    radial-gradient(920px 720px at 92% 6%, rgba(196, 181, 253, 0.45), transparent 48%),
    linear-gradient(168deg, var(--paper) 0%, #f3e8ff 42%, var(--paper-deep) 88%, #e9d5ff 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: 1.05rem;
  line-height: 1.65;
  letter-spacing: 0.01em;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 650;
  font-size: 1.2rem;
  color: var(--accent-deep);
  text-decoration: none;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance {
  font-weight: 800;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.strip {
  margin: 0;
  padding: 8px clamp(16px, 5vw, 56px);
  background: var(--accent-deep);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.document {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) clamp(16px, 5vw, 56px) 56px;
}

.hero-kicker {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-muted);
  margin: 0 0 14px;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 7.5vw, 3.4rem);
  font-weight: 650;
  font-style: italic;
  line-height: 1.12;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--accent-deep);
}

.hero-blurb {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.18rem);
  line-height: 1.7;
  color: #6d28d9;
  font-style: italic;
}

.hero-blurb strong {
  color: var(--accent-deep);
  font-weight: 700;
  font-style: normal;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 28px 0 12px;
  color: var(--accent-deep);
  letter-spacing: 0.02em;
}

p,
li {
  margin: 10px 0;
  color: var(--ink-soft);
}

a {
  color: var(--accent);
  font-weight: 700;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

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

.muted {
  font-size: 0.94rem;
  color: var(--accent);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.card {
  margin: 18px 0 0;
  padding: 14px 16px;
  background: linear-gradient(155deg, #f5f3ff 0%, #ede9fe 55%, #e9e0ff 100%);
  border: 1px dashed var(--line-strong);
  box-shadow: 0 6px 18px var(--shadow);
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
  color: var(--accent-deep);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
}

.button:hover {
  border-color: rgba(91, 33, 182, 0.55);
  background: rgba(255, 255, 255, 0.8);
  color: var(--accent-deep);
}

.button-primary {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}

.button-primary:hover {
  background: #4c1d95;
  color: #fff;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent-muted);
  outline-offset: 2px;
}

.button-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.92rem;
}

.section {
  padding-top: 1.75rem;
  margin-top: 2.25rem;
  border-top: 1px solid rgba(139, 92, 246, 0.18);
}

.section > h2:first-child {
  margin-top: 0;
}

.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.game-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-weight: 400;
}

.game-card:hover {
  background: rgba(255, 255, 255, 0.85);
}

.game-card h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
  margin: 0 0 6px;
}

.game-card p {
  margin: 0;
}

.game-card .odds {
  display: block;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.stage {
  position: relative;
  width: min(100%, 440px);
  aspect-ratio: 1;
  margin: 22px auto 0;
  user-select: none;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scratch-under {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  background: #fff;
  text-align: center;
}

.scratch-symbol {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 650;
  font-size: clamp(3rem, 18vw, 5.5rem);
  line-height: 1;
  color: var(--accent-deep);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.result {
  text-align: center;
}

.result-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 650;
  font-size: 1.6rem;
  line-height: 1.25;
  color: var(--accent-deep);
  margin: 0 0 6px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 6px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--accent-deep);
}

td.num,
th.num {
  text-align: right;
}

dialog.gate {
  max-width: min(92vw, 520px);
  padding: 22px 20px;
  border: 1px dashed var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 0;
}

dialog.gate::backdrop {
  background: rgba(49, 46, 129, 0.82);
}

dialog.gate h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 650;
  font-size: 2rem;
  margin: 0 0 10px;
  color: var(--accent-deep);
}

.site-footer {
  padding: 18px clamp(16px, 5vw, 56px) 32px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  text-align: center;
}

.code {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-deep);
  text-align: center;
  margin: 6px 0 12px;
  user-select: all;
}

.input {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  min-width: 0;
  flex: 1 1 180px;
}

.input:focus-visible {
  outline: 3px solid var(--accent-muted);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.doors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.door {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 3 / 4;
  padding: 6px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.6);
  color: var(--accent-deep);
  font: inherit;
  cursor: pointer;
}

.door:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  border-style: dashed;
}

.door-today {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}

.door-opened {
  background: var(--paper-deep);
}

.door:focus-visible {
  outline: 3px solid var(--accent-muted);
  outline-offset: 2px;
}

.door-day {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 650;
  font-size: 1.7rem;
  line-height: 1;
}

.door-price {
  font-weight: 800;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.door-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mine {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mine li {
  margin: 0;
}

.reward-media {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  margin: 0 auto 12px;
}

.reward-text {
  white-space: pre-wrap;
}

/* Admin */
.document.wide {
  max-width: 1200px;
}

.admin .wallet {
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 10px;
  max-width: 560px;
}

.stack label {
  display: grid;
  gap: 4px;
  font-weight: 700;
}

.stack label:has(input[type="checkbox"]) {
  display: block;
  font-weight: 400;
}

.stack .button {
  justify-self: start;
}

.inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 2px 0;
}

.inline .input {
  flex: 0 1 150px;
}

.door-prices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

td.wrap {
  white-space: normal;
  word-break: break-word;
  max-width: 320px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  max-width: 420px;
}

fieldset {
  border: 1px dashed var(--line-strong);
  padding: 10px 12px;
}

.admin td:last-child {
  white-space: normal;
  min-width: 240px;
}
