/* ============================================================
   Imposter — design tokens + base
   ============================================================ */
:root {
  /* Surfaces (desaturated, slight cool tint) */
  --bg:       #0B0C10;
  --bg-elev:  #101218;
  --card:     #15171F;
  --card-2:   #1B1E29;
  --card-3:   #232736;
  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --fg:       #F2F3F7;
  --fg-soft:  #B8BAC6;
  --fg-mute:  #7B7F92;
  --fg-faint: #4A4E5E;

  /* Accents */
  --accent:        #FF3D5A;          /* impostor red */
  --accent-soft:   #FF3D5A1A;        /* 10% */
  --accent-glow:   #FF3D5A33;        /* 20% */
  --accent-hover:  #FF5670;
  --accent-press:  #E62B47;

  --crew:          #6BD3A8;          /* desaturated mint */
  --crew-soft:     #6BD3A81A;
  --warn:          #E5B868;
  --info:          #7AA8FF;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;

  /* Type */
  --font-display: "Space Grotesk", "Inter", -apple-system, system-ui, sans-serif;
  --font-ui:      "Inter", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}
#root {
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
input { -webkit-appearance: none; appearance: none; outline: 0; }
::selection { background: var(--accent); color: #fff; }

/* ============================================================
   App container — mobile-first, capped 560px
   ============================================================ */
.imp-app {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.imp-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 32px;
  scrollbar-width: none;
}
.imp-scroll::-webkit-scrollbar { display: none; }

/* ============================================================
   Typography
   ============================================================ */
.t-display { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }
.t-mono    { font-family: var(--font-mono); }
.t-h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.t-h2 { font-size: 22px; line-height: 1.2;  font-weight: 700; letter-spacing: -0.015em; }
.t-h3 { font-size: 17px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.t-body { font-size: 15px; line-height: 1.45; }
.t-sm   { font-size: 13px; line-height: 1.4; color: var(--fg-soft); }
.t-xs   { font-size: 11px; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-mute); font-weight: 600; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  height: 48px;
  min-width: 44px;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: transform .12s ease, background .15s ease, opacity .15s ease, border-color .15s ease;
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent-press) inset, 0 8px 24px -8px var(--accent-glow);
}
.btn-primary:hover:not([disabled]) { background: var(--accent-hover); }
.btn-primary:active:not([disabled]) { background: var(--accent-press); }

.btn-secondary {
  background: var(--card-2);
  color: var(--fg);
  border: 1px solid var(--hairline-strong);
}
.btn-secondary:hover:not([disabled]) { background: var(--card-3); border-color: rgba(255,255,255,0.18); }

.btn-ghost {
  background: transparent;
  color: var(--fg-soft);
  border: 1px dashed var(--hairline-strong);
}
.btn-ghost:hover:not([disabled]) { color: var(--fg); border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.02); }

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(255, 61, 90, 0.3);
}
.btn-danger:hover:not([disabled]) { background: var(--accent-soft); border-color: var(--accent); }

.btn-tg {
  background: #2AABEE;
  color: #fff;
  height: 52px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.btn-tg:hover:not([disabled]) { background: #229ED9; }

.btn-icon {
  width: 40px; height: 40px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card-2);
  border: 1px solid var(--hairline);
  color: var(--fg-soft);
}
.btn-icon:hover { color: var(--fg); border-color: var(--hairline-strong); }

.btn-block { width: 100%; }
.btn-lg { height: 56px; font-size: 16px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card-elev {
  background: var(--card-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card-pad-lg { padding: 20px; }

/* ============================================================
   Inputs
   ============================================================ */
.input {
  width: 100%;
  height: 48px;
  background: var(--card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 0 14px;
  color: var(--fg);
  font-size: 15px;
  transition: border-color .15s ease, background .15s ease;
}
.input::placeholder { color: var(--fg-mute); }
.input:focus { border-color: var(--accent); background: var(--card-2); }
.input.error { border-color: var(--accent); }

.input-code {
  font-family: var(--font-mono);
  font-size: 28px;
  text-align: center;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* compensate */
  text-transform: uppercase;
  height: 64px;
  font-weight: 600;
}

/* ============================================================
   Tags / badges
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  background: var(--card-3);
  color: var(--fg-soft);
  border: 1px solid var(--hairline);
}
.tag-host    { background: rgba(122, 168, 255, 0.12); color: var(--info); border-color: rgba(122,168,255,0.25); }
.tag-impostor{ background: var(--accent-soft); color: var(--accent); border-color: rgba(255,61,90,0.3); }
.tag-win     { background: var(--crew-soft); color: var(--crew); border-color: rgba(107,211,168,0.3); }
.tag-lose    { background: var(--accent-soft); color: var(--accent); border-color: rgba(255,61,90,0.3); }
.tag-warn    { background: rgba(229,184,104,0.12); color: var(--warn); border-color: rgba(229,184,104,0.3); }

/* ============================================================
   Player chip / avatar
   ============================================================ */
.avatar {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--card-3), var(--card-2));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-status {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 11px; height: 11px;
  border-radius: 999px;
  background: var(--crew);
  border: 2px solid var(--card);
}
.avatar-status.offline { background: var(--fg-faint); }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar {
  display: flex;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 2px;
}
.tabbar button {
  flex: 1;
  height: 38px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color .15s, background .15s;
}
.tabbar button[data-active="true"] {
  color: var(--fg);
  background: var(--card-3);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}

/* ============================================================
   Toast & Modal
   ============================================================ */
.toast-wrap {
  position: absolute;
  left: 16px; right: 16px;
  bottom: 24px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.toast {
  background: rgba(20, 22, 30, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  animation: toastIn .25s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-scrim {
  position: absolute; inset: 0;
  background: rgba(8, 9, 12, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease-out;
}
.modal {
  width: 100%;
  max-width: 360px;
  background: var(--card-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-xl);
  padding: 22px;
  animation: modalIn .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Skeletons
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   Role card (the centerpiece)
   ============================================================ */
.role-card {
  position: relative;
  border-radius: var(--r-2xl);
  height: 320px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  perspective: 1000px;
}
.role-card:active { transform: scale(0.98); }
.role-card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2,.8,.2,1);
}
.role-card[data-revealed="true"] .role-card-inner { transform: rotateY(180deg); }
.role-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r-2xl);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px;
  text-align: center;
  border: 1px solid var(--hairline-strong);
}
.role-face-back { transform: rotateY(180deg); }

.role-face.closed {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.04), transparent 60%),
    repeating-linear-gradient(45deg, var(--card) 0 8px, var(--card-2) 8px 16px);
}
.role-face.crew {
  background:
    radial-gradient(circle at 50% 0%, rgba(107,211,168,0.18), transparent 55%),
    linear-gradient(180deg, var(--card-2), var(--card));
  border-color: rgba(107,211,168,0.25);
}
.role-face.impostor {
  background:
    radial-gradient(circle at 50% 100%, rgba(255,61,90,0.28), transparent 60%),
    linear-gradient(180deg, #1A0E15, #0F0A0E);
  border-color: rgba(255,61,90,0.4);
  animation: impostorPulse 2.2s ease-in-out infinite;
}
@keyframes impostorPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,61,90,0.0), inset 0 0 60px rgba(255,61,90,0.0); }
  50%      { box-shadow: 0 0 40px -10px rgba(255,61,90,0.4), inset 0 0 60px rgba(255,61,90,0.15); }
}
.role-shake { animation: shake .5s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px) rotate(-0.5deg); }
  30% { transform: translateX(6px) rotate(0.5deg); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ============================================================
   Vote card
   ============================================================ */
.vote-card {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.vote-card:hover { border-color: var(--hairline-strong); }
.vote-card[data-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ============================================================
   Slider (range)
   ============================================================ */
.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 32px;
  background: transparent;
}
.range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: var(--card-3);
}
.range::-moz-range-track {
  height: 6px; border-radius: 999px;
  background: var(--card-3);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--accent);
  border: 2px solid #1a0d10;
  margin-top: -8px;
  box-shadow: 0 0 0 4px rgba(255,61,90,0.15);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--accent);
  border: 2px solid #1a0d10;
  box-shadow: 0 0 0 4px rgba(255,61,90,0.15);
  cursor: pointer;
}

/* ============================================================
   Native-styled select
   ============================================================ */
.select {
  width: 100%;
  height: 44px;
  background: var(--card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 0 38px 0 14px;
  color: var(--fg);
  font-size: 14px;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%237B7F92' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.select:focus { border-color: var(--accent); }

/* ============================================================
   Misc
   ============================================================ */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--fg-mute); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--hairline);
}

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px;
  background: var(--bg);
}
.app-header.with-back { padding: 10px 16px 8px; }

.banner {
  border-radius: var(--r-lg);
  padding: 18px;
  text-align: center;
  border: 1px solid var(--hairline-strong);
}
.banner-win  { background: linear-gradient(180deg, rgba(107,211,168,0.18), rgba(107,211,168,0.04)); border-color: rgba(107,211,168,0.35); }
.banner-lose { background: linear-gradient(180deg, rgba(255,61,90,0.18), rgba(255,61,90,0.04));   border-color: rgba(255,61,90,0.35); }
.banner-tie  { background: linear-gradient(180deg, rgba(229,184,104,0.18), rgba(229,184,104,0.04)); border-color: rgba(229,184,104,0.35); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 14px 12px;
}
.stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-num .pct { font-size: 16px; color: var(--fg-mute); margin-left: 2px; }
.stat-lbl { font-size: 11px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-top: 8px; }

.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px; text-align: center; gap: 12px;
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--hairline-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-mute);
}

.error-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(255,61,90,0.3);
  border-radius: var(--r-md);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.4;
}

/* Tap pulse */
@keyframes tapPulse { 0% { transform: scale(1); } 50% { transform: scale(0.97); } 100% { transform: scale(1); } }
.tap { animation: tapPulse .2s ease-out; }

/* Slide-up screen transition */
.screen-in { animation: screenIn .28s cubic-bezier(.2,.8,.2,1); }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Code-letter cells */
.code-cell {
  width: 44px; height: 56px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1.5px solid var(--hairline-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--fg);
}
.code-cell-empty { color: var(--fg-faint); }
.code-cell-active { border-color: var(--accent); }

/* ============================================================
   Logo mark
   ============================================================ */
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 18px;
}
.logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2A1A1F, #15171F);
  border: 1px solid rgba(255,61,90,0.4);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 15px;
  position: relative;
}
.logo-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 16px -4px var(--accent-glow);
  pointer-events: none;
}
