/* Birthday Golf design system (PLAN.md section 10).
   Three font sizes only: --fs-mega, --fs-title, --fs-body. No rounded corners. 48px tap targets. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1B1F3B;
  --ink-2: #262B52;
  --ink-3: #323867;
  --butter: #FFE58A;
  --butter-dim: rgba(255, 229, 138, .62);
  --line: rgba(255, 229, 138, .16);
  --tangerine: #FF7A1A;
  --accent: var(--tangerine); /* the viewer's team colour after the draw (set on :root by applyTeamColours) */
  --accent-ink: var(--ink);
  --mint: #9FE2BF;
  --pink: #FF5FA2;
  --fs-mega: clamp(56px, 20vw, 112px);
  --fs-title: 22px;
  --fs-body: 17px;
  --gap: 16px;
  --tap: 48px;
  --col: 560px;
  --tabbar-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

[hidden] { display: none !important; }

html { font-size: var(--fs-body); }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--ink);
  color: var(--butter);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.35;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.locked { overflow: hidden; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button { touch-action: manipulation; cursor: pointer; }

img { display: block; max-width: 100%; }

h1, h2, h3, p { margin: 0; }

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

/* Type: exactly three sizes. Weight may vary. */
.mega { font-size: var(--fs-mega); font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.title { font-size: var(--fs-title); font-weight: 700; line-height: 1.15; }
.body { font-size: var(--fs-body); font-weight: 400; }
.bold { font-weight: 700; }
.muted { color: var(--butter-dim); }
.good { color: var(--mint); }
.bad { color: var(--pink); }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Layout */
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: var(--gap); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spread { justify-content: space-between; }

#root { min-height: 100vh; min-height: 100dvh; }

.shell { min-height: 100vh; min-height: 100dvh; }

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: var(--sat) max(var(--gap), var(--sar)) 0 max(var(--gap), var(--sal));
}
.header-inner {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header .me-btn {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin-left: -6px;
  padding: 0;
  background: none;
  border: 0;
  display: grid;
  place-items: center;
}
.header .name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--butter-dim);
}
.header .status { flex: none; color: var(--butter-dim); min-height: var(--tap); display: flex; align-items: center; padding-left: 12px; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.header .status[data-kind="spin"] { color: var(--butter); }
.header .status .spin { animation: bg-spin .9s linear infinite; transform-origin: 50% 50%; }
@keyframes bg-spin { to { transform: rotate(360deg); } }
/* Your own photo top left: no team border. */
.header .me-btn .avatar { outline: none !important; }

.main {
  padding-bottom: calc(var(--tabbar-h) + var(--sab));
}

.screen {
  max-width: var(--col);
  margin: 0 auto;
  padding: var(--gap) max(var(--gap), var(--sar)) var(--gap) max(var(--gap), var(--sal));
}

.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--butter);
  overflow-y: auto;
  overflow-x: clip;
  overscroll-behavior: contain;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}
.flow-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--ink);
  overflow-y: auto;
  overflow-x: clip;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--ink-2);
  border-top: 1px solid var(--line);
  padding: 0 var(--sar) var(--sab) var(--sal);
}
.tabbar-inner {
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 8px max(8px, calc(var(--gap) - 8px));
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 2px;
  font-stretch: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
  color: var(--butter);
  border: 2px solid transparent;
  font-weight: 700;
}
.tab[aria-current="page"] {
  background: var(--accent);
  color: var(--ink);
}

.connecting {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--gap);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  background: var(--accent);
  color: var(--ink);
  border: 2px solid var(--accent);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--butter); border-color: var(--butter); }
.btn.good { background: var(--mint); border-color: var(--mint); color: var(--ink); }
.btn.bad { background: var(--pink); border-color: var(--pink); color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { filter: brightness(.9); }

.link {
  min-height: var(--tap);
  padding: 0 12px;
  background: none;
  border: 0;
  color: var(--butter);
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 600;
}

/* Surfaces */
.card { background: var(--ink-2); padding: var(--gap); }
.card.flat { border: 1px solid var(--line); background: transparent; }

.tile {
  display: grid;
  place-items: center;
  min-height: var(--tap);
  padding: 8px;
  background: var(--ink-2);
  color: var(--butter);
  border: 2px solid var(--line);
  font-weight: 700;
  text-align: center;
}
.tile.on, .tile[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tile.square { aspect-ratio: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--butter);
  font-weight: 600;
  white-space: nowrap;
}
.chip.good { color: var(--ink); background: var(--mint); border-color: var(--mint); }
.chip.bad { color: var(--ink); background: var(--pink); border-color: var(--pink); }
.chip.hot { color: var(--ink); background: var(--accent); border-color: var(--accent); }

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

.avatar {
  --av-bw: 3px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  /* Team colour after the draw (--pc), random per-name colour (--nc) before it. */
  background: var(--pc, var(--nc, var(--butter)));
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 800;
  line-height: 1;
  user-select: none;
  /* Border drawn over the photo, inside the square, so sizes never change. */
  outline: var(--av-bw) solid var(--pc, var(--nc, var(--butter)));
  outline-offset: calc(-1 * var(--av-bw));
}
.avatar.initials { outline: none; }
.avatar.big { font-size: var(--fs-title); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
/* The draw reel must not reveal who is paired: its faces keep their pre-draw colours. */
.reel-window .avatar[data-player] { --pc: initial; }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  background: var(--ink-2);
  color: var(--butter);
  border: 2px solid var(--line);
}
.input::placeholder { color: var(--butter-dim); }

/* Sip grid */
.sipgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sipgrid .tile { aspect-ratio: 1; font-size: var(--fs-title); }
.sipgrid .tile.more { grid-column: 1 / -1; aspect-ratio: auto; min-height: var(--tap); font-size: var(--fs-body); }

/* Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 10, 28, .72);
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 101;
  max-width: var(--col);
  margin: 0 auto;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ink-2);
  color: var(--butter);
  border-top: 3px solid var(--butter);
  padding: var(--gap) var(--gap) calc(var(--gap) + var(--sab));
  outline: none;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); }

/* Toast */
.toast-region {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: calc(var(--sat) + 8px) var(--gap) 0;
  pointer-events: none;
  display: flex;
  justify-content: center;
}
.toast {
  max-width: var(--col);
  padding: 12px 16px;
  background: var(--ink-3);
  border: 2px solid var(--butter);
  color: var(--butter);
  font-weight: 700;
}
.toast.good { background: var(--mint); border-color: var(--mint); color: var(--ink); }
.toast.bad { background: var(--pink); border-color: var(--pink); color: var(--ink); }

/* Sign-up */
.signup .screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; gap: var(--gap); }
.signup .names { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.signup .namebtn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 8px;
  background: var(--ink-2);
  color: var(--butter);
  border: 2px solid var(--line);
  text-align: left;
  min-width: 0;
}
.signup .namebtn .nm { min-width: 0; display: flex; flex-direction: column; gap: 2px; font-weight: 700; overflow-wrap: anywhere; }
.signup .namebtn .nm .done { color: var(--mint); font-weight: 600; }
.signup .center-col { display: flex; flex-direction: column; align-items: center; gap: var(--gap); text-align: center; }
.signup .dots { display: flex; gap: 16px; justify-content: center; padding: 8px 0; }
.signup .dot { width: 20px; height: 20px; border: 3px solid var(--butter); background: transparent; }
.signup .dot.on { background: var(--butter); }
.signup .keypad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-auto-rows: 64px;
  gap: 12px;
  justify-content: center;
}
.signup .key {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  background: var(--ink-2);
  border: 2px solid var(--line);
  color: var(--butter);
  font-size: var(--fs-title);
  font-weight: 700;
}
.signup .key:active { background: var(--accent); color: var(--ink); }
.signup .msg { min-height: 1.35em; font-weight: 700; }
.signup .preview { width: 200px; height: 200px; object-fit: cover; background: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Destructive ghost button, e.g. "Remove photo". */
.btn.ghost.bad-text { color: var(--pink); border-color: var(--pink); }
