:root {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #f4ebe3;
  --ink: #1f1916;
  --muted: #6b5d55;
  --line: #e8dcd2;
  --accent: #c2364a;
  --accent-ink: #ffffff;
  --accent-soft: #f9dfe1;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --tile-1: #ffe3d6;
  --tile-2: #e5e6ff;
  --tile-3: #dcf3e3;
  --tile-4: #fff0c7;
  --radius: 22px;
  --shadow: 0 1px 2px rgb(60 30 20 / 6%), 0 8px 24px -8px rgb(60 30 20 / 14%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110f;
    --surface: #221a17;
    --surface-2: #2c221e;
    --ink: #f7efe9;
    --muted: #b9a89e;
    --line: #3a2e29;
    --accent: #ff8a94;
    --accent-ink: #2a0d12;
    --accent-soft: #4a2228;
    --ok: #5fd08f;
    --warn: #f0b85a;
    --tile-1: #3d251c;
    --tile-2: #26263f;
    --tile-3: #1d3326;
    --tile-4: #3a3118;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -10px rgb(0 0 0 / 60%);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  font: 17px/1.5 var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 100% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0;
  font: 800 clamp(2.4rem, 9vw, 3.6rem) / 1.02 var(--display);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

p {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 12px;
}

#app:focus {
  outline: none;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  z-index: 10;
}

.skip:focus {
  top: calc(env(safe-area-inset-top) + 0.75rem);
}

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

.screen {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: min(100%, 34rem);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 1.25rem)
    calc(env(safe-area-inset-right) + 1.5rem)
    calc(env(safe-area-inset-bottom) + 1.5rem)
    calc(env(safe-area-inset-left) + 1.5rem);
}

.screen.center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: 800 1.35rem/1 var(--display);
  letter-spacing: -0.03em;
}

.brand.small {
  font-size: 1.1rem;
}

.logo {
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 0.55em 0.55em 0.55em 0.15em;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85em;
}

.hero {
  display: grid;
  gap: 0.9rem;
}

.landing .hero {
  margin-top: auto;
}

.eyebrow {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 30ch;
  text-wrap: pretty;
}

.center .lede {
  margin-inline: auto;
}

.title-sm {
  font-size: 1.6rem;
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}

.landing .actions,
.lobby .actions,
.waiting .actions {
  margin-top: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 52px;
  padding: 0 1.4rem;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform 160ms var(--ease), background-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px var(--accent);
  font-size: 1.1rem;
}

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.back {
  min-height: 44px;
  padding: 0 1rem 0 0.8rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
}

.join {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.join label {
  font-weight: 650;
  font-size: 0.95rem;
}

.join-row {
  display: flex;
  gap: 0.6rem;
}

.join input {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  font: 700 1.25rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.join input::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

.join input:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}

.field-error {
  min-height: 1.4em;
  font-size: 0.92rem;
  color: var(--accent);
  font-weight: 600;
}

.fine {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.waiting {
  gap: 1.25rem;
}

.waiting h1 {
  font-size: clamp(2rem, 8vw, 3rem);
}

.qr-card {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 1.25rem;
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.qr {
  width: min(56vw, 30dvh, 248px);
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  color: #1f1916;
}

.qr svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.qr-card figcaption {
  color: var(--muted);
  text-align: center;
}

.code {
  display: block;
  color: var(--ink);
  font: 800 1.9rem/1.15 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.25em;
  margin-right: -0.25em;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-weight: 650;
}

.pulse,
.spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s var(--ease) infinite;
}

.spinner {
  width: 28px;
  height: 28px;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.presence {
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 650;
}

.presence li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  transition: background-color 200ms var(--ease);
}

[data-online] .dot {
  background: var(--ok);
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.95rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tiles li {
  display: grid;
}

.tile {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 160px;
  padding: 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--tile-1);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms var(--ease);
}

.tiles li:nth-child(2) .tile { background: var(--tile-2); }
.tiles li:nth-child(3) .tile { background: var(--tile-3); }
.tiles li:nth-child(4) .tile { background: var(--tile-4); }

.tile:active {
  transform: scale(0.97);
}

.tile-num {
  font: 800 0.8rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  opacity: 0.6;
  margin-bottom: auto;
  padding-bottom: 1.6rem;
}

.tile-title {
  font: 800 1.15rem/1.15 var(--display);
  letter-spacing: -0.02em;
}

.tile-tagline {
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--muted);
}

.module h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
}

.module-root {
  flex: 1;
}

.placeholder {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tag {
  justify-self: start;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hint {
  font-size: 0.92rem;
  color: var(--muted);
}

.placeholder-actions {
  display: grid;
  gap: 0.6rem;
}

.wave {
  min-height: 1.5em;
  font-weight: 650;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 1.25rem);
  max-width: calc(100% - 2rem);
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 650;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 1rem);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (hover: hover) {
  .btn.primary:hover { box-shadow: 0 14px 30px -12px var(--accent); }
  .tile:hover { transform: translateY(-2px); }
}

@media (min-width: 900px) {
  .screen { width: min(100%, 40rem); padding-top: 3rem; padding-bottom: 3rem; }
  .landing .hero { margin-top: 12vh; }
  .landing .actions { margin-top: 0; }
  .landing .fine { margin-top: auto; }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

.suggest {
  display: grid;
  gap: 0.75rem;
  margin-bottom: -0.75rem; /* pulls the game up to 1rem below, inside the screen's 1.75rem gap */
  padding: 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.95rem;
}

.suggest p {
  margin: 0;
  color: var(--muted);
}

.suggest strong {
  color: var(--ink);
}

.suggest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.suggest-actions .btn {
  flex: 1 1 auto;
  min-height: 44px;
}

/* i18n: lang.js hides the app until a non-English language has been applied (app.js removes the class).
   Failsafe: show it anyway after 2s so a failed strings load can never leave a blank screen. */
.i18n-pending #app {
  visibility: hidden;
  animation: i18n-reveal 0s 2s forwards;
}

@keyframes i18n-reveal { to { visibility: visible; } }

.lang-switch {
  display: inline-flex;
  flex: none;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.lang-switch button {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.lang-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
