/* Layout: a white page where the map is the one dark, glowing object, with the steps and post tiles below it. */
:root {
  --paper: #ffffff;
  --grape-night: #1d0a4d;
  --grape-deep: #2f1270;
  --grape: #4b2496;
  --violet: #7b4fc9;
  --butter: #ffdc5e;
  --milk: #ffffff;
  --lilac: #d9c8f5;
  --line: rgba(75, 36, 150, 0.2);
  --ink: linear-gradient(120deg, var(--violet), var(--grape) 55%, var(--grape-deep));
  --stage: linear-gradient(150deg, var(--violet) 0%, var(--grape) 22%, var(--grape-deep) 55%, var(--grape-night) 100%);
  --body: 'Open Sans', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--grape-deep);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  background: var(--paper);
}

/* Purple gradient text. Falls back to the solid colour above where unsupported. */
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .total, .demo-note, .caption-text, .swipe-hint, h2, h3, .steps p,
  .tile-name, .tile-count, .tile-action, footer p,
  .admin > p, .admin-title, .admin-field > label, .admin-total, .admin-token > label, .admin-status {
    background-image: var(--ink);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.wrap {
  max-width: 1120px;
  margin-inline: auto;
  padding-block: 40px 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 24px;
}

.hero { text-align: center; display: grid; gap: 16px; justify-items: center; }

h1 { margin: 0; }
.headline { display: block; width: min(100%, 620px); height: auto; margin-inline: auto; }

.total { margin: 0; font-weight: 600; }
.total strong { font-weight: 800; font-size: 1.5em; font-variant-numeric: tabular-nums; }

.demo-note {
  margin: 0;
  padding: 8px 12px;
  border: 1px dashed var(--violet);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

.stage { display: grid; gap: 12px; min-width: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tabs button {
  font: 600 0.875rem var(--body);
  color: var(--grape);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.tabs button:hover { border-color: var(--violet); }
.tabs button[aria-pressed='true'] {
  background: var(--ink);
  border-color: transparent;
  color: var(--milk);
}

/* Lit hearts need the dark, so the map keeps the poster's purple. */
.map {
  position: relative;
  background: var(--stage);
  border-radius: 16px;
  overflow: hidden;
}
.map-frame { position: relative; min-width: 0; }
.map-inner { position: relative; }

/* Sits on the frame, not the map, so it stays put while a phone pans the world map. */
.song-play {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--butter);
  color: var(--grape-deep);
  box-shadow: 0 2px 10px rgba(29, 10, 77, 0.5);
  cursor: pointer;
}
.song-play:hover:not(:disabled) { background: var(--milk); }
.song-play:disabled { opacity: 0.6; cursor: default; }
.song-play:focus-visible { outline-color: var(--butter); }

/* The owner chose audio-only: the player runs unseen, which YouTube's embed rules don't allow.
   It only appears when a browser blocks the start and someone has to tap YouTube's own button. */
.song-panel {
  position: absolute;
  left: 12px;
  bottom: 64px;
  width: 200px;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--grape-night);
  box-shadow: 0 4px 16px rgba(29, 10, 77, 0.6);
  opacity: 0;
  pointer-events: none;
}
.song-panel.is-open { opacity: 1; pointer-events: auto; }
.song-panel iframe { display: block; width: 100%; height: 100%; border: 0; }
.song-fallback {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--butter);
  color: var(--grape-deep);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}
.song-fallback:hover { background: var(--milk); color: var(--grape-deep); }
canvas { display: block; width: 100%; height: auto; }
.swipe-hint { display: none; margin: 0; text-align: center; font-size: 0.8125rem; font-weight: 600; }

.chip {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 600 0.75rem/1.25 var(--body);
  color: var(--milk);
  background: rgba(29, 10, 77, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--butter); }
.chip b { font-weight: 800; color: var(--butter); }

.caption {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.caption-text { margin: 0; font-weight: 600; min-width: 0; }
.caption-text b { font-weight: 800; font-variant-numeric: tabular-nums; }
.caption-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.cta, .ghost {
  font: 800 0.875rem var(--body);
  padding: 9px 16px;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
}
.cta { background: var(--ink); color: var(--milk); border: 1px solid transparent; }
.cta:hover { color: var(--milk); filter: brightness(1.15); }
.ghost { background: var(--paper); color: var(--grape); border: 1px solid var(--violet); }
.ghost:hover { color: var(--milk); background: var(--ink); }

.join { display: grid; gap: 20px; padding-top: 24px; min-width: 0; }

h2 { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.25; text-wrap: balance; }
h3 { margin: 0; font-size: 1.0625rem; font-weight: 800; line-height: 1.3; }

a { color: var(--grape); text-underline-offset: 3px; }
a:hover { color: var(--violet); }
.steps a { font-weight: 600; }

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}
.steps li { counter-increment: step; display: grid; gap: 6px; align-content: start; min-width: 0; }
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--milk);
  font-weight: 800;
}
.steps p { margin: 0; font-size: 0.9375rem; }

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.tile {
  display: grid;
  gap: 4px;
  height: 100%;
  padding: 12px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  text-decoration: none;
}
.tile canvas { width: 100%; height: auto; margin-bottom: 4px; }
.tile-name { font-weight: 800; font-size: 1.0625rem; line-height: 1.3; }
.tile-count { font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.tile-count b { font-weight: 800; font-size: 1.5rem; }
.tile-action { margin-top: 6px; font-size: 0.875rem; font-weight: 600; }
.tile-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-self: end; }
.tile-link {
  padding: 4px 12px;
  border: 1px solid var(--violet);
  border-radius: 999px;
  color: var(--grape);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}
.tile-link:hover { background: var(--ink); color: var(--milk); }

footer { padding-top: 8px; font-size: 0.8125rem; text-align: center; }
footer p { margin: 0; }

:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

@media (max-width: 720px) {
  .wrap { padding-block: 24px; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .steps li { grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; row-gap: 2px; }
  .steps li::before { grid-row: span 2; margin-bottom: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 10px 12px 14px; }
  /* The world map is too wide to read at phone width, so it pans inside its frame. */
  .map.is-world { overflow-x: auto; }
  .map.is-world .map-inner { width: 200%; }
  .swipe-hint { display: block; }
  .caption-actions, .cta, .ghost { width: 100%; text-align: center; }
}

.admin { max-width: 560px; }
.admin p { margin: 0; }
.admin-title { font-size: clamp(1.75rem, 6vw, 2.25rem); font-weight: 800; line-height: 1.2; margin: 0; }
#form { display: grid; gap: 20px; }
.admin-fields { display: grid; gap: 10px; }
.admin-field { display: grid; grid-template-columns: minmax(0, 1fr) 92px 92px; gap: 8px; align-items: center; font-weight: 600; }
.admin-head { font-size: 0.8125rem; font-weight: 700; color: var(--grape); text-align: right; }
.admin-field input, #token {
  width: 100%;
  font: 600 1rem var(--body);
  color: var(--grape-deep);
  background: var(--paper);
  border: 1px solid var(--violet);
  border-radius: 10px;
  padding: 8px 10px;
}
.admin-field input { text-align: right; font-variant-numeric: tabular-nums; }
.admin-total { font-weight: 600; }
.admin-total strong { font-weight: 800; font-variant-numeric: tabular-nums; }
.admin-token { display: grid; gap: 8px; justify-items: start; border-top: 1px solid var(--line); padding-top: 16px; font-weight: 600; }
.admin-check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.admin-status { font-weight: 600; min-height: 1.5em; }
.admin .cta { justify-self: start; }
.admin .cta:disabled { opacity: 0.6; cursor: default; }

