/* Tokens and shared controls */
:root {
  color-scheme: light;
  --ink: #211834;
  --purple: #5a32bd;
  --lavender: #f5f0fe;
  --muted: #625873;
  --line: #e6def1;
  --white: #fffdfb;
  --radius: 14px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--lavender);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 88% 14%, #ebe0fc, transparent 40%),
    radial-gradient(ellipse at 3% 82%, #fce9df, transparent 48%);
}
button, input, textarea { font: inherit; }
button, summary { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { min-height: 44px; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
:where(button, a, input, textarea, summary):focus-visible {
  outline: 3px solid #8058d6;
  outline-offset: 3px;
}
.quiet, .text-button {
  background: transparent;
  color: var(--purple);
  font-weight: 750;
  border: 1px solid #dcd0ee;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .875rem;
}
.quiet:hover, .text-button:hover { background: #eee4fa; }
.text-button { border-color: transparent; }
.primary, .secondary {
  width: 100%;
  min-height: 50px;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 800;
  border: 1px solid var(--purple);
  background: var(--purple);
  color: white;
}
.primary:hover:enabled { background: #4b25ab; }
.secondary { background: transparent; color: var(--purple); margin-top: 10px; }
.secondary:hover:enabled { background: #f4eafd; }
label { display: block; font-weight: 750; font-size: .875rem; margin-bottom: 8px; }
input, textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid #d6cbe4;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  margin-bottom: 18px;
  font-size: 16px; /* Prevent iOS from zooming into fields. */
}
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
input[type=datetime-local] { min-height: 50px; }
input[type=checkbox] { accent-color: var(--purple); }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.fine { font-size: .8rem; color: var(--muted); text-align: center; margin: 14px 0 0; line-height: 1.5; }
.sub { line-height: 1.55; color: var(--muted); margin: 12px 0 22px; overflow-wrap: anywhere; }
.eyebrow, footer { font-weight: 800; font-size: .68rem; letter-spacing: .14em; color: var(--purple); margin: 0 0 14px; line-height: 1.5; }
.eyebrow span { display: inline-block; width: 8px; height: 8px; background: #cf644a; border-radius: 50%; margin-right: 8px; }

/* Page shell. The game stays above the fold on phones. */
.top {
  min-height: 72px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ddd2eb;
  gap: 12px;
}
.brand { text-decoration: none; display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; }
.brand-icon { background: var(--purple); color: white; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: bold 37px/1 Georgia; padding-top: 4px; }
main {
  flex: 1;
  width: min(1040px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-content: center;
  align-items: center;
  gap: 64px;
  padding: 48px 0;
}
.hero { position: relative; }
.hero h1, h2 { font-family: Georgia, serif; letter-spacing: -.05em; margin: 0; line-height: 1.07; }
.hero h1 { font-size: clamp(3.2rem, 5vw, 4.6rem); position: relative; z-index: 1; }
.hero em { color: var(--purple); font-weight: normal; }
.intro { max-width: 370px; line-height: 1.65; color: var(--muted); font-size: 1.05rem; margin: 24px 0; }
.steps { display: flex; gap: 18px; font-size: .85rem; font-weight: 750; }
.steps b { color: var(--purple); font-size: .7rem; margin-right: 4px; }
.art { position: relative; width: 120px; height: 110px; margin-top: 20px; transform: rotate(8deg); pointer-events: none; }
.quote { width: 66px; height: 55px; border: 2px solid var(--ink); border-radius: 18px; box-shadow: 3px 3px var(--ink); position: absolute; font: bold 64px/1.23 Georgia; text-align: center; }
.quote-one { top: 5px; left: 2px; transform: rotate(-18deg); background: #ffbea6; }
.quote-two { right: 1px; bottom: 14px; transform: rotate(12deg); background: #dfcdfa; }
.star { position: absolute; right: -6px; top: 2px; color: var(--purple); font-size: 1.7rem; }
.game { background: var(--white); padding: 32px; border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 55px #47277b12; min-width: 0; }
.game h2, dialog h2 { font-size: clamp(2rem, 4vw, 2.75rem); overflow-wrap: anywhere; }
footer { text-align: center; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); margin: 0; color: var(--muted); font-size: .6rem; }
main.in-room { display: block; width: min(660px, calc(100% - 32px)); padding: 28px 0; }

/* Room setup and optional settings */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: #f0e9f9; margin: 0 0 24px; }
.tabs button { border: none; background: transparent; border-radius: 10px; padding: 10px; color: var(--muted); flex: 1; min-width: 0; font-size: .9rem; font-weight: 800; }
.tabs button[aria-pressed=true] { background: white; color: var(--purple); box-shadow: 0 1px 5px #3217651c; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.mode-options button { text-align: left; border: 1px solid var(--line); background: white; padding: 12px; border-radius: 12px; color: var(--ink); }
.mode-options button[aria-pressed=true] { border-color: var(--purple); background: #f4eefd; box-shadow: inset 0 0 0 1px var(--purple); }
.mode-options strong, .mode-options small { display: block; }
.mode-options strong { font-size: .875rem; }
.mode-options small { margin-top: 5px; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.mode-help { font-size: .875rem; margin: 0 0 20px; }
.settings { border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0; padding: 0 14px; }
.settings summary { padding: 14px 0; font-size: .875rem; font-weight: 750; min-height: 48px; }
.settings[open] summary { margin-bottom: 4px; }
.settings .tabs { margin-bottom: 14px; }
.settings .sub { font-size: .875rem; }
.settings-content { padding-bottom: 14px; }
.custom-fields { margin: 16px 0; }
.prompt-row { display: flex; gap: 8px; align-items: start; }
.prompt-row input { flex: 1; }
.prompt-row button { flex-shrink: 0; padding: 10px 12px; }
.return-room { text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8f4fe; width: 100%; color: var(--purple); margin-bottom: 20px; font-weight: 750; }
.return-room small { display: block; font-weight: 400; margin-top: 4px; color: var(--muted); }

/* Lobby and player management */
.code-box { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; background: #f2eafa; border-radius: var(--radius); margin: 20px 0; }
.code-box small { display: block; color: var(--muted); font-size: .7rem; margin-bottom: 4px; }
.code-box b { letter-spacing: .18em; font-size: 1.3rem; }
.section-label { font-size: .875rem; font-weight: 750; margin: 20px 0 4px; }
.players { list-style: none; margin: 0 0 18px; padding: 0; }
.players li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.avatar { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%; background: #eee6fa; color: var(--purple); font-size: .85rem; font-weight: 800; }
.player-label { min-width: 0; flex: 1; }
.player-label strong { font-size: .9rem; overflow-wrap: anywhere; }
.player-label small { display: block; font-size: .75rem; color: var(--muted); margin-top: 3px; }
.player-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.kick { color: #99432e; font-size: .8rem; }
.name-form { padding: 14px; background: #f5f0fe; border-radius: var(--radius); margin: 12px 0 20px; }
.name-form input { margin-bottom: 8px; }
.inline-actions { display: flex; gap: 8px; }
.room-exit { display: block; margin: 12px auto 0; }
.waiting-note { background: #f4eefd; border-radius: var(--radius); padding: 16px; text-align: center; color: var(--purple); font-weight: 650; line-height: 1.5; }

/* Writing and reveal */
.progress { display: block; width: 100%; accent-color: var(--purple); height: 7px; border: none; border-radius: 20px; overflow: hidden; background: #eee6fa; margin: 16px 0 26px; }
.progress::-webkit-progress-bar { background: #eee6fa; }
.progress::-webkit-progress-value { background: var(--purple); border-radius: 20px; }
.progress::-moz-progress-bar { background: var(--purple); }
.answer-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .75rem; margin: -10px 0 20px; }
.answer-meta output { white-space: nowrap; }
.deadline-note { padding: 12px 14px; background: #f4eefd; border-radius: 12px; font-size: .85rem; line-height: 1.5; color: var(--muted); margin: 16px 0; }
.deadline-note strong { color: var(--ink); }
.success-mark { width: 48px; height: 48px; display: grid; place-items: center; color: #286348; background: #e7f3eb; border-radius: 50%; font-size: 24px; margin-bottom: 18px; }
.story { padding: 8px 0; overflow-wrap: anywhere; font: 1.2rem/1.9 Georgia, serif; }
.story p { margin: 0 0 16px; }
.line { display: inline; background: #f0e7fb; border: 0; border-radius: 5px; color: #472394; font: inherit; text-align: left; padding: 3px 5px; min-height: auto; white-space: normal; overflow-wrap: anywhere; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.line:hover, .line[aria-expanded=true] { background: #e5d4fa; }
.author { display: block; color: var(--muted); font: .85rem/1.4 system-ui, sans-serif; min-height: 1.4em; margin-top: 12px; }
.controls { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 20px 0; }
.controls .quiet { white-space: normal; }
.meetup-link { display: block; text-align: center; text-decoration: none; padding: 14px; border-radius: 12px; background: #eee6fa; font-weight: 750; color: var(--purple); margin: 18px 0; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 650; line-height: 1.5; }
.consent input { width: 20px; height: 20px; flex-shrink: 0; margin: 2px 0 0; }
#sms-form, #sms-verify-form { margin-top: 20px; }

/* Feedback and modal dialogs */
#notice { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); z-index: 5; margin: 0; border-radius: 12px; background: var(--ink); color: white; padding: 13px 18px; line-height: 1.5; box-shadow: 0 4px 16px #32176540; pointer-events: none; }
.form-error { color: #97371f; background: #fff0e9; border-radius: 10px; padding: 12px; margin: 12px 0; font-size: .9rem; }
dialog { border: 1px solid var(--line); border-radius: 24px; background: var(--white); width: min(475px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; color: var(--ink); padding: 28px; }
dialog::backdrop { background: #21183470; }
dialog .close { float: right; }
dialog li { line-height: 1.55; margin-top: 14px; }
dialog ol { padding-left: 22px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .secondary { margin: 0; }

@media (max-width: 800px) {
  main { max-width: 540px; grid-template-columns: 1fr; padding: 28px 0; gap: 24px; }
  .hero h1 { font-size: clamp(2.2rem, 7vw, 3.2rem); }
  .hero .eyebrow, .art, .steps { display: none; }
  .intro { font-size: .95rem; margin: 12px 0 0; max-width: 420px; }
  .game { padding: 26px; }
}
@media (max-width: 480px) {
  .top { min-height: 64px; padding-left: 16px; padding-right: 16px; }
  .top .quiet { padding: 8px 10px; font-size: .78rem; }
  main { width: calc(100% - 28px); padding: 22px 0; gap: 22px; }
  .hero { padding: 0 6px; }
  .hero h1 { font-size: 2.2rem; }
  .intro { font-size: .9rem; line-height: 1.5; }
  .game { padding: 22px 18px; border-radius: 20px; }
  .game h2 { font-size: 2rem; }
  main.in-room { width: calc(100% - 24px); padding: 18px 0; }
  .eyebrow { font-size: .63rem; margin-bottom: 12px; }
  .sub { font-size: .925rem; margin-bottom: 18px; }
  .code-box { padding: 12px; gap: 8px; }
  .code-box b { font-size: 1.15rem; }
  .code-box .quiet { padding: 10px; }
  .sticky-action { position: sticky; bottom: 0; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); margin: 0 -2px; background: var(--white); z-index: 2; }
  .story { font-size: 1.1rem; line-height: 2; }
  .players li { gap: 8px; }
  .avatar { width: 30px; height: 30px; flex-basis: 30px; }
  .player-actions .text-button { padding: 8px; }
  dialog { padding: 24px 20px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .15s, border-color .15s; }
}

.timezone { margin: -10px 0 16px; text-align: left; }
