/* ─── Fonts (self-hosted) ───────────────────────────────────────────────────── */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('../fonts/QGYvz_MVcBeNP4NJuktqUYLkn8BJ.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('../fonts/QGYvz_MVcBeNP4NJtEtqUYLknw.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url('../fonts/rP2Hp2ywxg089UriCZ2IHTWEBlwu8Q.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url('../fonts/rP2Hp2ywxg089UriCZOIHTWEBlw.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ─── Tokens ───────────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg: #F2F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-press: #CBD5E1;

  /* Text */
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-hint: #94A3B8;

  /* Accents */
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --blue-soft: #EFF6FF;

  --green: #10B981;
  --green-dark: #059669;
  --green-soft: #ECFDF5;

  --red: #EF4444;
  --red-dark: #DC2626;
  --red-soft: #FEF2F2;

  --orange: #F97316;
  --orange-dark: #C2410C;
  --orange-soft: #FFF7ED;

  --purple: #7C3AED;
  --purple-dark: #5B21B6;
  --purple-soft: #F5F3FF;

  --teal: #0D9488;
  --teal-dark: #115E59;
  --teal-soft: #F0FDFA;

  /* Dynamic — overridden by JS per selected game */
  --ambient-tint: rgba(37, 99, 235, 0.14);
  --active-accent: #2563EB;

  /* Typography */
  --font-title: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.10), 0 4px 8px rgba(15,23,42,0.06);
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea, select {
  font-family: var(--font-body);
  font-size: 16px; /* prevent iOS zoom */
}

/* ─── App shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  padding: 18px 18px 24px;
  padding-top: max(59px, env(safe-area-inset-top));
}

.capacitor-native .app-shell,
.capacitor-native .game-inner {
  padding-top: 47px;
}

.capacitor-native .top-bar {
  padding-top: 47px;
}

.capacitor-native .login-shell {
  padding-top: 47px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* ─── Press-effect button ──────────────────────────────────────────────────── */
.btn-press {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  border-bottom: 4px solid transparent;
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 80ms ease, border-bottom-width 80ms ease;
  touch-action: manipulation;
  cursor: pointer;
  outline: none;
}

.btn-press:active {
  transform: translateY(2px);
  border-bottom-width: 2px !important;
}

.btn-press:disabled,
.btn-press[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue-dark);
  border-bottom-color: var(--blue-dark);
}

.btn-green {
  background: var(--green);
  color: #fff;
  border-color: var(--green-dark);
  border-bottom-color: var(--green-dark);
}

.btn-white {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
  border-bottom-color: var(--border-press);
}

/* ─── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* ─── Avatar ───────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }

/* ─── Profile pill (HUD) ───────────────────────────────────────────────────── */
.profile-pill {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-bottom: 3.5px solid var(--border-press);
  border-radius: 14px;
  padding: 5px 12px 5px 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.profile-pill:active {
  transform: translateY(2px);
  border-bottom-width: 1.5px;
}

.profile-pill .player-name {
  font-weight: 800;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.15;
}

.profile-pill .player-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.15;
}

/* ─── Counter pill (HUD) ───────────────────────────────────────────────────── */
.counter-pill {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-bottom: 3.5px solid var(--border-press);
  border-radius: 14px;
  padding: 7px 11px;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.25s ease, background-color 0.25s ease;
  position: relative;
}

.counter-pill:active {
  transform: translateY(2px);
  border-bottom-width: 1.5px;
}

/* ─── Online dot with radar animation ─────────────────────────────────────── */
.online-dot-wrap {
  position: relative;
  width: 8px;
  height: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
  z-index: 2;
}

.online-ping {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.6;
  animation: radarPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
  0%        { transform: scale(0.8); opacity: 0.75; }
  80%, 100% { transform: scale(2.3); opacity: 0; }
}

/* ─── Bottom sheet ─────────────────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 40;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(105%);
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 14px 18px 28px;
  z-index: 50;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.15);
}

.bottom-sheet.open {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  background: var(--border-press);
  border-radius: 999px;
  margin: 0 auto 16px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 19px;
  color: var(--text-primary);
}

.sheet-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-weight: 800;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ─── Input ────────────────────────────────────────────────────────────────── */
.input-field {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
}

.input-field::placeholder { color: var(--text-hint); font-weight: 600; }

.input-field:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ─── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-blue  { background: var(--blue-soft);   color: var(--blue); }
.badge-green { background: var(--green-soft);  color: var(--green-dark); }
.badge-red   { background: var(--red-soft);    color: var(--red-dark); }
.badge-gray  { background: #F1F5F9;            color: var(--text-secondary); }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.capacitor-native .toast {
  top: 47px;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--text-primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Spinner ──────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
