/* The app's look in the browser: same palette (Palette in Theme.swift), Outfit, dark glow background. */

@font-face { font-family: Outfit; font-weight: 300; font-display: swap; src: url(/assets/fonts/Outfit-Light.ttf) format("truetype"); }
@font-face { font-family: Outfit; font-weight: 400; font-display: swap; src: url(/assets/fonts/Outfit-Regular.ttf) format("truetype"); }
@font-face { font-family: Outfit; font-weight: 500; font-display: swap; src: url(/assets/fonts/Outfit-Medium.ttf) format("truetype"); }
@font-face { font-family: Outfit; font-weight: 600; font-display: swap; src: url(/assets/fonts/Outfit-SemiBold.ttf) format("truetype"); }

:root {
  --bg: #0E0D12;
  --glow: #2B2340;
  --card: #1A1820;
  --chip: #1C1A23;
  --chip-active: #F2F0F7;
  --icon-button: #211F29;
  --track: #2A2733;
  --text: #F2F0F7;
  --muted: #8A8597;
  --secondary: #77727F;
  --on-accent: #16141C;
  --lavender: #B9A4F5;
  --butter: #F4D27A;
  --pink: #F2A0C0;
  --mint: #8FE3C3;
  --blue: #8EC9F5;
  --peach: #F2B79A;
  --coral: #F59E8E;
  --gutter: 20px;
  --card-radius: 16px;
  --tile-radius: 14px;
  --pill: 54px;
  --swipe-width: 212px;
  --swipe-height: 66px;
  --spring: cubic-bezier(.34, 1.4, .64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Outfit, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; }

/* Layout: a phone-width column, full height, scrolling content with a pinned bottom. */
#app { min-height: 100%; }
.screen {
  --screen-glow: var(--glow);
  position: relative;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) var(--gutter) calc(env(safe-area-inset-bottom) + 10px);
}
.screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 95vmax 95vmax at 50% -5%, var(--screen-glow), transparent 70%), var(--bg);
}
.screen.glow-mafia { --screen-glow: #3A2238; }
.screen.glow-bingo { --screen-glow: #3A2E1C; }
.screen.glow-night { --screen-glow: #241F3A; }
.screen.glow-blue { --screen-glow: #1E2A48; }
.screen.glow-red { --screen-glow: #4A2A2A; }
.screen.glow-salad { --screen-glow: #1F3A2E; }
.screen.glow-charades { --screen-glow: #3A2238; }
.content { flex: 1; display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.bottom {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding-top: 18px; margin: 0 calc(-1 * var(--gutter)); padding-left: var(--gutter); padding-right: var(--gutter);
  padding-bottom: calc(env(safe-area-inset-bottom) + 10px); margin-bottom: calc(-1 * (env(safe-area-inset-bottom) + 10px));
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Type, matching Typography.swift */
.display { font-size: 34px; font-weight: 300; line-height: 1.12; margin: 0; letter-spacing: -0.2px; }
.title { font-size: 22px; font-weight: 400; margin: 0; }
.headline { font-size: 17px; font-weight: 500; }
.body { font-size: 16px; }
.callout { font-size: 14px; }
.detail { font-size: 13px; font-weight: 300; }
.caption { font-size: 11px; }
.muted { color: var(--muted); }
.secondary { color: var(--secondary); }
.lavender { color: var(--lavender); }
.butter { color: var(--butter); }
.pink { color: var(--pink); }
.mint { color: var(--mint); }
.tabular { font-variant-numeric: tabular-nums; }
p { margin: 0; }

/* Surfaces */
.card { background: var(--card); border-radius: var(--card-radius); }
.pad { padding: 16px; }
.list { padding: 6px 0; }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; }

/* Buttons */
.pill {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--pill); border-radius: 999px;
  background: var(--lavender); color: var(--on-accent);
  font-size: 17px; font-weight: 500;
  transition: transform .15s;
}
.pill:active:not(:disabled) { transform: scale(.97); }
.pill.secondary { background: var(--icon-button); color: var(--text); }
.pill.danger { background: var(--pink); color: var(--on-accent); }
.pill:disabled { opacity: .45; }
.link-button { min-height: 44px; padding: 0 6px; color: var(--lavender); font-size: 14px; }
.circle-button {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
}
.circle-button > span {
  width: var(--size, 30px); height: var(--size, 30px); border-radius: 50%;
  background: var(--icon-button); display: grid; place-items: center;
}
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--icon-button); font-size: 13px; white-space: nowrap;
}
.tag.tinted { color: var(--on-accent); }

/* Connection dot before the first header item, like LinkDot.swift */
.link-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.link-dot.connected { background: var(--mint); box-shadow: 0 0 6px rgba(143, 227, 195, .7); }
.link-dot.weak, .link-dot.reconnecting { background: var(--butter); box-shadow: 0 0 6px rgba(244, 210, 122, .7); }

/* Avatars */
.avatar { position: relative; display: inline-block; flex: none; line-height: 0; }
.avatar svg { display: block; overflow: visible; }
.avatar-turn { animation: wiggle .32s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes wiggle { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.host-badge {
  position: absolute; right: 0; bottom: 0; border-radius: 50%;
  background: var(--butter); color: var(--on-accent);
  border: 2px solid; display: grid; place-items: center;
}
.ring { border-radius: 50%; padding: 6px; }
.ring.on { background: var(--lavender); }

/* Player grid (lobby) and picker */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 8px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.cell { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.cell .name { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick { position: relative; }
.pick .avatar-wrap { border-radius: 50%; padding: 7px; position: relative; transition: background .2s; }
.pick:disabled { opacity: .35; }
.badge {
  position: absolute; top: 0; right: 0; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--chip-active); color: var(--on-accent); font-size: 12px; font-weight: 600;
  display: grid; place-items: center;
}
.waiting-slot { width: 50px; height: 50px; border-radius: 50%; border: 1.2px dashed rgba(138, 133, 151, .6); display: grid; place-items: center; color: var(--muted); margin: 6px; }

/* Code entry */
.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.code-box {
  min-height: 64px; border-radius: var(--tile-radius); background: var(--card);
  display: grid; place-items: center; font-size: 28px; border: 1.5px solid transparent;
}
.code-box.next { border-color: var(--lavender); }
.code-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad-key { min-height: 56px; border-radius: var(--tile-radius); background: var(--card); font-size: 26px; display: grid; place-items: center; }
.pad-key:active { background: var(--icon-button); }

/* Text field */
.field {
  width: 100%; min-height: 58px; padding: 0 18px; border-radius: var(--card-radius);
  background: var(--icon-button); border: 0; font-size: 22px; outline: none;
}
.field::placeholder { color: var(--secondary); }
.field.center { text-align: center; }

/* Swipe to confirm */
.swipe {
  position: relative; width: var(--swipe-width); height: var(--swipe-height); border-radius: 999px;
  background: var(--track); user-select: none; -webkit-user-select: none; touch-action: none; flex: none;
}
.swipe.disabled { opacity: .45; }
.swipe .label {
  position: absolute; inset: 0; padding-left: 70px; padding-right: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; white-space: nowrap; overflow: hidden;
}
.swipe .knob {
  position: absolute; top: 4px; left: 4px; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; color: var(--on-accent); cursor: grab;
}
.swipe .knob.settle { transition: transform .35s var(--spring); }

/* Drawer (sheet from the bottom) */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; animation: fade .2s; }
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 480px; margin: 0 auto;
  background: var(--card); border-radius: 28px 28px 0 0;
  padding: 10px var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
  animation: rise .32s var(--spring); max-height: 92dvh; overflow-y: auto;
}
.drawer .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--track); margin: 0 auto 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }
.danger-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: var(--pink); background: rgba(242, 160, 192, .14); }

/* Banners */
.banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 52px); z-index: 10;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: var(--icon-button); border: 1px solid rgba(244, 210, 122, .4); font-size: 14px; white-space: nowrap;
}
.app-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--card); border-radius: var(--card-radius); font-size: 14px;
}
.app-banner img { width: 36px; height: 36px; border-radius: 9px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--lavender); opacity: .25; animation: dot 1.6s infinite; }
.dots i:nth-child(2) { animation-delay: .4s; }
.dots i:nth-child(3) { animation-delay: .8s; }
@keyframes dot { 0%, 20% { opacity: .25; } 25%, 100% { opacity: 1; } }

/* Mafia role card: flips over on press, like the app (spring, tilted -4°). */
.role-card {
  width: 230px; height: 300px; perspective: 900px; transform: rotate(-4deg);
  user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; cursor: pointer;
}
.role-card-flip {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transform: rotateY(180deg); transition: transform .45s cubic-bezier(.34, 1.36, .64, 1);
}
.role-card.peeking .role-card-flip { transform: rotateY(0deg); }
.role-card-face {
  position: absolute; inset: 0; border-radius: 28px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; text-align: center;
}
.role-card-front { color: var(--on-accent); }
.role-card-back {
  transform: rotateY(180deg); color: var(--lavender);
  background: linear-gradient(#2E2940, #1E1B28); border: 1.5px solid rgba(185, 164, 245, .35);
}
@media (prefers-reduced-motion: reduce) {
  .role-card-flip, .role-card.peeking .role-card-flip { transform: none; }
  .role-card-face { transition: opacity .15s ease-in-out !important; transition-duration: .15s !important; }
  .role-card-back { transform: none; }
  .role-card .role-card-front { opacity: 0; }
  .role-card.peeking .role-card-front { opacity: 1; }
  .role-card.peeking .role-card-back { opacity: 0; }
}

/* Game art */
.game-icon { object-fit: contain; flex: none; }

/* Confetti for winners */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 8px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

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