/* Field web player. One screen: the game first, the app one tap away. Dark on purpose: games are
   mostly dark, and the page should feel like the app, not like a document around a game. */

:root {
  --bg: #0d0b14;
  --surface: rgb(255 255 255 / 0.06);
  --surface-strong: rgb(255 255 255 / 0.1);
  --line: rgb(255 255 255 / 0.1);
  --text: #f4f2fa;
  --muted: rgb(244 242 250 / 0.66);
  --faint: rgb(244 242 250 / 0.45);
  --violet: #7c4dff;
  --violet-deep: #5b2fd6;
  --gold: #ffd166;
  --green: #3ddc97;
  --radius-stage: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgb(124 77 255 / 0.28), transparent 60%),
    radial-gradient(80% 50% at 100% 110%, rgb(91 47 214 / 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, .download { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { display: block; }

/* MARK: Game page — fixed, one screen, never scrolls. */

body.game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* MARK: Top bar */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; color: inherit; text-decoration: none; }
.brand .app-icon { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 4px 12px rgb(124 77 255 / 0.45)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: -0.01em; }
.brand-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-button {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: var(--surface-strong); color: var(--text);
}
.icon-button svg { width: 20px; height: 20px; }
.icon-button .cross { display: none; }
.icon-button.muted .waves { display: none; }
.icon-button.muted .cross { display: block; }
.icon-button:focus-visible, .primary:focus-visible, .download:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* MARK: Download buttons */

.download {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap; font-weight: 650;
}
.download svg { width: 18px; height: 18px; flex: none; }
.download.pill {
  height: 38px; padding: 0 16px; border-radius: 999px;
  background: #fff; color: #120d24; font-size: 15px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25);
}
.download.wide {
  width: 100%; height: 54px; padding: 0 18px; border-radius: 16px;
  background: linear-gradient(135deg, var(--violet), var(--violet-deep)); color: #fff; font-size: 17px;
  box-shadow: 0 10px 28px rgb(91 47 214 / 0.45), inset 0 1px 0 rgb(255 255 255 / 0.2);
}
.download.soon { cursor: default; box-shadow: none; }
.download.pill.soon { background: var(--surface-strong); color: var(--muted); }
.download.wide.soon { background: transparent; color: var(--muted); border: 1.5px dashed rgb(255 255 255 / 0.22); }
a.download:active { transform: scale(0.98); }

/* MARK: Stage */

.play { min-height: 0; display: flex; justify-content: center; gap: 32px; padding: 0 calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left)); }
.stage {
  position: relative; flex: 1; min-width: 0; min-height: 0;
  display: grid; place-items: center;
  touch-action: none;
}
.screen {
  position: relative; overflow: hidden;
  width: 360px; height: 640px;
  border-radius: var(--radius-stage);
  background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px rgb(0 0 0 / 0.55), 0 0 90px hsl(var(--hue, 262) 80% 55% / 0.22);
  isolation: isolate;
}
.screen iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #000; display: block; }

/* MARK: Cards over the game */

.card {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 28px 22px calc(22px + 0px);
  text-align: center;
  background: linear-gradient(180deg, rgb(10 8 20 / 0.35), rgb(10 8 20 / 0.82) 55%, rgb(10 8 20 / 0.92));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: card-in 0.22s ease-out;
}
@keyframes card-in { from { opacity: 0; } to { opacity: 1; } }

.tile {
  width: 96px; height: 96px; border-radius: 26px;
  display: grid; place-items: center; font-size: 54px; line-height: 1;
  background: linear-gradient(145deg, hsl(var(--hue, 262) 75% 62%), hsl(calc(var(--hue, 262) + 30) 70% 42%));
  box-shadow: 0 14px 34px hsl(var(--hue, 262) 80% 40% / 0.5), inset 0 1px 0 rgb(255 255 255 / 0.3);
  margin-bottom: 4px;
}
.card h1 { margin: 0; font-size: clamp(22px, 6.5vw, 28px); line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
.by { margin: -4px 0 0; color: var(--muted); font-size: 15px; }

.chip {
  margin: 2px 0 0; padding: 7px 14px; border-radius: 999px;
  background: var(--surface-strong); color: var(--text); font-size: 15px; font-weight: 600;
}
.chip.target { background: rgb(255 209 102 / 0.16); color: var(--gold); }
.chip.outcome.won { background: rgb(61 220 151 / 0.16); color: var(--green); }
.invite-chip { font-weight: 500; color: var(--muted); }
.invite-chip strong { color: var(--text); letter-spacing: 0.08em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.primary {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 210px; height: 58px; margin-top: 10px; padding: 0 34px;
  border: 0; border-radius: 999px;
  background: #fff; color: #120d24;
  font-size: 19px; font-weight: 700; letter-spacing: -0.01em;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.35);
  transition: transform 0.12s ease;
}
.primary:active { transform: scale(0.97); }
.primary:disabled { cursor: progress; opacity: 0.85; }
.primary .spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgb(18 13 36 / 0.2); border-top-color: #120d24; animation: spin 0.8s linear infinite; }
.primary:disabled .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.result .headline { margin: 0; color: var(--muted); font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.result .headline.celebrate { color: var(--gold); }
.result .score { margin: -2px 0 0; font-size: clamp(56px, 18vw, 76px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.result .best { margin: 0; color: var(--muted); font-size: 15px; }
.upsell {
  width: 100%; margin-top: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line);
}
.upsell p { margin: 0; font-size: 14px; color: var(--muted); text-wrap: balance; }
.result { justify-content: flex-end; }
.result .headline { margin-top: auto; }

/* MARK: Dock (phones) */

.dock {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));
  padding: 10px 10px 10px 16px;
  border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.dock-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.dock-text strong { font-size: 15px; }
.dock-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* MARK: Pitch (wide screens, invites, missing games) */

.pitch { display: none; }
.pitch .app-icon { width: 64px; height: 64px; filter: drop-shadow(0 10px 24px rgb(124 77 255 / 0.5)); }
.pitch h2 { margin: 18px 0 6px; font-size: 32px; line-height: 1.1; letter-spacing: -0.025em; text-wrap: balance; }
.pitch .lead { margin: 0 0 18px; font-size: 17px; color: var(--muted); text-wrap: pretty; }
.points, .steps { margin: 0 0 22px; padding: 0; list-style: none; display: grid; gap: 12px; }
.points li, .steps li { position: relative; padding-left: 34px; font-size: 16px; }
.points li::before {
  content: ""; position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border-radius: 50%;
  background: rgb(124 77 255 / 0.22) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.5 12.5 3.5 3.5 7.5-8' fill='none' stroke='%23b69cff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.steps { counter-reset: step; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: rgb(124 77 255 / 0.25); color: #d6c8ff;
}
.invite {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 18px; padding: 16px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line);
}
.invite .label { font-size: 13px; color: var(--muted); }
.invite .code { font: 800 32px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.14em; -webkit-user-select: all; user-select: all; }
.invite .hint { font-size: 14px; color: var(--muted); }
.fine { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--faint); }

@media (min-width: 880px) {
  .play { padding: 8px 32px 28px; align-items: stretch; }
  .stage { flex: 0 1 auto; width: min(560px, 52vw); }
  .pitch {
    display: flex; flex-direction: column; justify-content: center;
    width: 380px; flex: none; overflow-y: auto; padding: 8px 4px;
  }
  .dock { display: none; }
  body.game { grid-template-rows: auto minmax(0, 1fr); }
  .brand .app-icon { width: 38px; height: 38px; }
}

/* Phones on their side: every pixel to the game. */
@media (max-height: 520px) and (orientation: landscape) {
  .dock, .brand-text small { display: none; }
  body.game { grid-template-rows: auto minmax(0, 1fr); }
  .bar { padding-top: calc(6px + var(--safe-top)); padding-bottom: 6px; }
  .play { padding-bottom: calc(8px + var(--safe-bottom)); }
}

@media (max-width: 440px) {
  .brand-text small { display: none; }
}
@media (max-width: 340px) {
  .dock-text span { display: none; }
}

/* MARK: Invite and not-found pages — ordinary, scrollable. */

body.page { min-height: 100dvh; display: flex; flex-direction: column; }
.sheet { flex: 1; display: flex; justify-content: center; align-items: center; padding: 12px calc(16px + var(--safe-right)) 24px calc(16px + var(--safe-left)); }
body.page .pitch {
  display: flex; flex-direction: column;
  width: 100%; max-width: 440px; padding: 28px 24px;
  border-radius: 28px; background: var(--surface); border: 1px solid var(--line);
}
.foot { display: flex; justify-content: center; gap: 16px; padding: 12px 16px calc(16px + var(--safe-bottom)); font-size: 13px; color: var(--faint); }
.foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .primary, a.download { transition: none; }
}

/* MARK: Home page */

.home { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px calc(16px + var(--safe-right)) 24px calc(16px + var(--safe-left)); }
.hero { max-width: 560px; margin: 12px auto 40px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.hero .app-icon { width: 84px; height: 84px; filter: drop-shadow(0 14px 32px rgb(124 77 255 / 0.55)); }
.hero h1 { margin: 22px 0 10px; font-size: clamp(34px, 9vw, 54px); line-height: 1.04; letter-spacing: -0.035em; text-wrap: balance; }
.hero .lead { margin: 0 0 22px; font-size: 18px; color: var(--muted); text-wrap: pretty; }
.hero .points { text-align: left; margin-bottom: 26px; }
.hero .download.wide { max-width: 380px; }
.library h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.library .hint { margin: 2px 0 16px; color: var(--muted); }
.games { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.game-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; height: 100%;
  padding: 14px; border-radius: 20px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.15s ease;
}
.game-tile:hover, .game-tile:focus-visible { background: var(--surface-strong); transform: translateY(-2px); }
.game-tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.game-tile .tile { width: 64px; height: 64px; border-radius: 18px; font-size: 36px; margin-bottom: 8px; }
.game-tile .name { font-weight: 650; line-height: 1.2; }
.game-tile .by { margin: 0; font-size: 13px; }
