*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #000;
  --surface: #111;
  --surface2: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --text: #fff;
  --muted: rgba(255,255,255,0.45);
  --accent: #fff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --nav-h: 72px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;
  --focus: #5dadec;
  color-scheme: dark;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif; overscroll-behavior: none; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }

#app { position: fixed; inset: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---- SCREENS ---- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); transition: opacity .22s ease, transform .22s ease; overflow: hidden; }
.screen.hidden { opacity: 0; pointer-events: none; transform: translateY(12px); }

/* ---- TYPOGRAPHY ---- */
.big-balance { font-size: clamp(48px, 12vw, 80px); font-weight: 700; letter-spacing: -2px; line-height: 1; }
.label { font-size: 12px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
h2 { font-size: 20px; font-weight: 600; }

/* ---- SCROLL AREA ---- */
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--nav-h) + var(--safe-bot) + 16px); }

/* ---- TOP BAR ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 16px) 24px 12px; flex-shrink: 0; }
.topbar-coins { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; }
.coin-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }

/* ---- BOTTOM NAV ---- */
.nav { position: absolute; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + var(--safe-bot)); padding-bottom: var(--safe-bot); display: flex; align-items: center; justify-content: space-around; background: rgba(0,0,0,0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border); z-index: 100; }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0 10px; min-height: 56px; cursor: pointer; opacity: .45; transition: opacity .15s; border: none; background: none; color: #fff; }
.nav-btn.active { opacity: 1; }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn span { font-size: 10px; font-weight: 500; letter-spacing: .5px; }

/* ---- CARDS (table/venue cards) ---- */
.card-list { padding: 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.venue-card { border-radius: 20px; padding: 24px; display: flex; align-items: center; gap: 16px; cursor: pointer; position: relative; overflow: hidden; min-height: 96px; transition: transform .15s; }
.venue-card:active { transform: scale(.98); }
.venue-card.locked { cursor: default; opacity: .7; }
.venue-card .v-icon { font-size: 40px; flex-shrink: 0; }
.venue-card .v-info { flex: 1; }
.venue-card .v-name { font-size: 18px; font-weight: 700; color: #000; }
.venue-card .v-meta { font-size: 13px; color: rgba(0,0,0,0.72); margin-top: 3px; }
.venue-card .lock-icon { position: absolute; top: 16px; right: 16px; font-size: 18px; }

/* venue gradients */
.venue-cash     { background: linear-gradient(135deg, #d8f0c8 0%, #b8d8d0 100%); }
.venue-private  { background: linear-gradient(135deg, #f0d8e8 0%, #c8a8d8 100%); }
.venue-garage   { background: linear-gradient(135deg, #e8d5b7 0%, #c9a97a 100%); }
.venue-naderi   { background: linear-gradient(135deg, #e6c9a4 0%, #8a5a32 100%); }
.venue-jazz     { background: linear-gradient(135deg, #c9b8e8 0%, #8b6dbd 100%); }
.venue-velvet   { background: linear-gradient(135deg, #d4b8e8 0%, #5a3a78 100%); }
.venue-caspian  { background: linear-gradient(135deg, #b8d8e8 0%, #4a86a0 100%); }
.venue-penthouse{ background: linear-gradient(135deg, #ffe08a 0%, #f0b429 100%); }
.venue-skyline  { background: linear-gradient(135deg, #6a5a8a 0%, #1a1530 100%); color: #fff; }
.venue-island   { background: linear-gradient(135deg, #b8e8c8 0%, #5abf7a 100%); }
.venue-vault    { background: linear-gradient(135deg, #e0c8f8 0%, #4a3258 100%); color: #fff; }

/* Dark venue cards override text color */
.venue-skyline .v-name, .venue-vault .v-name,
.venue-skyline .tier-name, .venue-vault .tier-name { color: #fff; }
.venue-skyline .v-meta, .venue-vault .v-meta,
.venue-skyline .tier-stake, .venue-vault .tier-stake { color: rgba(255,255,255,0.7); }

/* ---- AUTH ---- */
.auth-lang {
  position: absolute; top: calc(var(--safe-top) + 16px);
  inset-inline-end: 20px;
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 3px;
  border-radius: var(--r-pill);
  z-index: 5;
}
.lang-toggle {
  background: none; border: none;
  color: rgba(255,255,255,0.55);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  min-width: 36px;
  transition: background .15s, color .15s;
}
.lang-toggle.active { background: #fff; color: #000; }
.auth-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 28px; gap: 28px; }
.auth-logo { font-size: 44px; font-weight: 800; letter-spacing: -2px; }
.auth-sub { font-size: 14px; color: var(--muted); text-align: center; }
.auth-tabs { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; width: 100%; }
.auth-tab { flex: 1; padding: 10px; border-radius: 9px; border: none; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; }
.auth-tab.active { background: #fff; color: #000; }
.auth-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.auth-avatar-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.avatar-preview { width: 80px; height: 80px; border-radius: 50%; background: var(--surface2); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-hint { font-size: 12px; color: var(--muted); }

.input { width: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: #fff; font-size: 16px; outline: none; transition: border-color .15s; -webkit-appearance: none; }
.input:focus { border-color: rgba(255,255,255,0.3); }
.input::placeholder { color: var(--muted); }

.btn-primary { width: 100%; padding: 16px; background: #fff; color: #000; border: none; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity .15s; }
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.btn-outline { width: 100%; padding: 14px; background: transparent; color: #fff; border: 1px solid var(--border); border-radius: 14px; font-size: 15px; font-weight: 600; cursor: pointer; }
.auth-err { font-size: 13px; color: #ff5a5a; text-align: center; min-height: 18px; }

.daily-bonus-btn { margin-top: 16px; padding: 12px 20px; background: rgba(255,200,50,0.1); border: 1px solid rgba(255,200,50,0.3); color: #ffd25a; border-radius: 14px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.daily-bonus-btn:active { opacity: .7; }

/* ============== HOME (carousel + leaderboard) ============== */
.home-toprow {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 24px 0;
  flex-shrink: 0;
}
.gem-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 16px; font-weight: 600;
  background: none; border: none; color: #5dadec; cursor: pointer;
}
.timer-pill {
  position: relative; background: none; border: none; padding: 0;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.timer-pill .timer-dot {
  position: absolute; top: 0; right: 0;
  width: 9px; height: 9px; border-radius: 50%;
  background: #ff3b30; border: 1.5px solid #000;
}

.home-balance-block {
  padding: 24px 24px 0;
  flex-shrink: 0;
}
.big-balance {
  font-size: clamp(40px, 11vw, 68px);
  font-weight: 200;
  letter-spacing: -2px;
  line-height: 1;
  color: #fff;
  transition: color 0.6s ease;
  white-space: nowrap;
}
.big-balance.balance-win { color: #7cf0a0; }
.big-balance.balance-lose { color: #ff8080; }

/* Tier carousel */
.tier-carousel-wrap {
  flex-shrink: 0;
  padding: 32px 0 24px;
}
.tier-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 0 24px;
}
.tier-carousel::-webkit-scrollbar { display: none; }

.tier-card {
  flex: 0 0 280px;
  height: 220px;
  border-radius: 28px;
  scroll-snap-align: start;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .25s cubic-bezier(.2,.7,.3,1);
}
.tier-card:active { transform: scale(.98); }
.tier-card.locked { cursor: default; opacity: .8; }
.tier-card-inner {
  height: 100%; padding: 28px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
}
.tier-icon { font-size: 56px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)); }
.tier-lock { position: absolute; top: 24px; right: 24px; font-size: 22px; }
.tier-meta { color: #000; }
.tier-name { font-size: 26px; font-weight: 600; letter-spacing: -.5px; line-height: 1.1; }
.tier-stake { font-size: 14px; color: rgba(0,0,0,0.72); margin-top: 6px; }

@media (min-width: 600px) {
  .tier-card { flex: 0 0 320px; height: 220px; }
}

/* ============== Season Screen ============== */
.season-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px 16px;
  flex-shrink: 0;
}
.back-btn-arrow, .help-btn {
  background: none; border: none; color: #fff;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer;
}
.help-btn {
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  font-size: 14px; font-weight: 600;
  width: 36px; height: 36px;
  margin: 4px;
}
.season-title { font-size: 18px; font-weight: 600; }

.season-xp-block { padding: 0 24px 8px; flex-shrink: 0; }
.season-xp-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
}
.season-xp-label { color: #ffb84d; font-size: 16px; font-weight: 600; }
.season-time {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,0.6); font-size: 14px;
}
.season-xp-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.season-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffb84d, #ffd25a);
  border-radius: 3px;
  transition: width .35s ease;
}

.season-content {
  flex: 1; overflow-y: auto;
  padding: 24px 24px calc(var(--safe-bot) + 24px);
}

.rank-current {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  padding: 24px 0 32px;
}
.rank-icon-big { font-size: 64px; line-height: 1; }
.rank-name-big { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.rank-next { font-size: 13px; color: rgba(255,255,255,0.55); margin-top: 4px; }
.rank-next span { color: #ffb84d; font-weight: 600; }

.rank-list { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; }
.rank-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  opacity: 0.5;
}
.rank-row.reached { opacity: 1; }
.rank-row.current {
  border-color: #ffb84d;
  background: rgba(255,184,77,0.08);
}
.rank-row-icon { font-size: 24px; }
.rank-row-info { flex: 1; }
.rank-row-name { font-size: 15px; font-weight: 600; }
.rank-row-xp { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }
.rank-check { color: #7cf0a0; font-weight: 700; }

.season-rewards {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 24px;
}
.reward-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  font-size: 15px;
}
.reward-xp { color: #ffb84d; font-weight: 700; font-size: 14px; }
.reward-xp-lose { color: rgba(255,255,255,0.35); font-size: 12px; font-weight: 500; }

/* Rank requirements (in season screen) */
.rank-requirements {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 12px;
}
.req-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: rgba(255,255,255,0.55);
}
.req-row.met { color: #7cf0a0; }
.req-check {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 1.5px solid rgba(255,255,255,0.3);
}
.req-row.met .req-check { background: #7cf0a0; color: #000; border-color: transparent; }

/* Rank pill on home top */
.rank-pill {
  background: none; border: none; padding: 4px; cursor: pointer;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}

/* ============== Music Bar (3D card carousel) ============== */
.music-bar {
  padding: 24px 0 8px;
  flex-shrink: 0;
  transition: opacity .25s;
}
.music-bar.muted .music-card { opacity: 0.35; }
.music-bar.muted .music-bar-label { opacity: 0.5; }

.music-bar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px 10px;
}
.music-bar-label {
  font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255,255,255,0.4); font-weight: 500;
}
.music-mute {
  background: rgba(255,255,255,0.06); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.music-mute:active { background: rgba(255,255,255,0.15); }

.music-carousel {
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; scrollbar-width: none;
  padding: 4px 24px;
  perspective: 800px;
}
.music-carousel::-webkit-scrollbar { display: none; }

.music-card {
  flex: 0 0 220px;
  height: 90px;
  border-radius: 18px;
  scroll-snap-align: start;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  transition: transform .25s cubic-bezier(.2,.7,.3,1.2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -3px 6px rgba(0,0,0,0.25),
    0 6px 14px rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.05);
  transform-style: preserve-3d;
}
.music-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 30% 0%, rgba(255,255,255,0.15), transparent 70%);
  border-radius: 18px;
  pointer-events: none;
}
.music-card:active { transform: scale(.96) translateZ(-4px); }
.music-card.playing {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 8px 24px rgba(0,0,0,0.55),
    0 0 0 2px rgba(255,255,255,0.7);
}

.music-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 22px; color: #fff; flex-shrink: 0;
  font-weight: 400;
  letter-spacing: -1px;
}
.music-info { flex: 1; min-width: 0; position: relative; z-index: 1; }
.music-genre-label {
  font-size: 10px; color: rgba(255,255,255,0.7);
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 2px; font-weight: 500;
}
.music-genre-name {
  font-size: 14px; font-weight: 600;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.1px;
}

/* Equalizer animation when playing */
.music-equalizer {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; gap: 2px; align-items: flex-end; height: 14px;
  opacity: 0;
}
.music-card.playing .music-equalizer { opacity: 1; }
.music-equalizer span {
  width: 3px; background: #fff; border-radius: 2px;
}
.music-equalizer span:nth-child(1) { animation: eq1 0.8s ease-in-out infinite; }
.music-equalizer span:nth-child(2) { animation: eq2 0.7s ease-in-out infinite; }
.music-equalizer span:nth-child(3) { animation: eq3 0.6s ease-in-out infinite; }
@keyframes eq1 { 0%,100% { height: 4px; } 50% { height: 14px; } }
@keyframes eq2 { 0%,100% { height: 14px; } 50% { height: 6px; } }
@keyframes eq3 { 0%,100% { height: 8px; } 50% { height: 12px; } }

/* Leaderboard */
.leaderboard-section {
  flex: 1;
  padding: 12px 24px 0;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + var(--safe-bot) + 16px);
}
.leaderboard-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 18px; font-weight: 500; color: #fff;
  margin-bottom: 12px;
}
.leaderboard-rank { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.leaderboard-rank .trophy { font-size: 20px; }

.leaderboard-list { display: flex; flex-direction: column; gap: 14px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
}
.lb-row.me { background: rgba(255,255,255,0.04); border-radius: 14px; padding: 6px 8px; margin: 0 -8px; }
.lb-medal { font-size: 24px; min-width: 28px; text-align: center; }
.lb-rank-num { font-size: 16px; font-weight: 600; color: var(--muted); }
.lb-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); overflow: hidden; flex-shrink: 0;
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 16px; font-weight: 500; }
.lb-xp { font-size: 13px; color: var(--muted); margin-top: 1px; }

/* ---- HOME (legacy) ---- */
.home-header { padding: calc(var(--safe-top) + 20px) 24px 0; }
.home-balance-label { font-size: 12px; font-weight: 500; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.games-section { padding: 32px 24px 0; }
.games-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.game-row { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: var(--surface); border-radius: 18px; border: 1px solid var(--border); cursor: pointer; transition: transform .15s; }
.game-row:active { transform: scale(.98); }
.game-row.locked { opacity: .4; cursor: not-allowed; }
.game-row-left { display: flex; align-items: center; gap: 14px; }
.game-icon { font-size: 28px; }
.game-name { font-size: 17px; font-weight: 600; }
.game-tag { font-size: 11px; color: var(--muted); margin-top: 2px; }
.game-arrow { color: var(--muted); font-size: 18px; }
.coming-tag { font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; background: var(--surface2); color: var(--muted); padding: 4px 10px; border-radius: 20px; }

/* ============== Profile (Statistics + Music) ============== */
.profile-screen { color: #fff; }
.profile-toprow {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 24px 0;
  flex-shrink: 0;
}
.profile-toprow .gem-pill { background: none; border: none; cursor: pointer; }
.settings-btn {
  background: none; border: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: .8;
}
.settings-btn:active { opacity: 1; }

.profile-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(var(--nav-h) + var(--safe-bot) + 16px);
}

.profile-summary {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 24px 28px;
  gap: 10px;
}
.profile-avatar-wrap {
  width: 84px; height: 84px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface2);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
.profile-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.profile-username { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.profile-meta { font-size: 13px; color: rgba(255,255,255,0.5); }

.section-title {
  font-size: 28px; font-weight: 600; letter-spacing: -.5px;
  padding: 8px 24px 16px;
}

/* ===== Avatar pencil edit ===== */
.profile-avatar-wrap { position: relative; }
.avatar-edit-pen {
  position: absolute; right: -2px; bottom: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 2px solid #000;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ===== Profile rows (Friends, Emotes, etc.) ===== */
.profile-rows {
  padding: 8px 20px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.profile-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pf-pill {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  cursor: pointer;
  transition: background .15s;
}
.pf-pill:active { background: rgba(255,255,255,0.06); }
.pf-emoji { font-size: 24px; flex-shrink: 0; display: flex; align-items: center; }
.pf-pill-info { flex: 1; min-width: 0; }
.pf-pill-num {
  font-size: 18px; font-weight: 600; letter-spacing: -.3px; line-height: 1;
}
.pf-of { font-size: 14px; color: rgba(255,255,255,0.4); font-weight: 500; }
.pf-pill-label {
  font-size: 12px; color: rgba(255,255,255,0.5);
  margin-top: 4px; letter-spacing: .1px;
}
.pf-arrow { color: rgba(255,255,255,0.3); font-size: 18px; flex-shrink: 0; }

.pf-add-friends {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 24px;
  color: #fff;
  font-size: 14px; font-weight: 700; letter-spacing: 1.5px;
  cursor: pointer;
  transition: background .15s;
}
.pf-add-friends:active { background: rgba(255,255,255,0.05); }

.pf-rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  cursor: pointer;
}
.pf-rank-info { flex-shrink: 0; }
.pf-rank-name { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.pf-rank-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-left: 8px;
}
.pf-rank-bar-fill {
  height: 100%;
  background: rgba(255,255,255,0.6);
  border-radius: 3px;
  transition: width .35s;
}

/* ===== Radar Chart ===== */
.radar-card {
  position: relative;
  margin: 0 20px;
  padding: 24px 12px 24px;
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,0.08);
  height: 360px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.radar-svg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  padding: 24px;
}
.radar-corner {
  position: absolute;
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 6px 12px;
  transition: all .25s;
}
.radar-corner.on {
  color: #2a2f24;
  background: #b3d9a4;
  border-color: transparent;
}
.radar-corner-tl { top: 14px; left: 14px; }
.radar-corner-tr { top: 14px; right: 14px; }
.radar-corner-bl { bottom: 14px; left: 14px; }
.radar-corner-br { bottom: 14px; right: 14px; }

.radar-axis {
  position: absolute;
  text-align: center;
  pointer-events: none;
}
.radar-axis-name { font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.radar-axis-sub { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.radar-axis-top { top: 50px; left: 50%; transform: translateX(-50%); }
.radar-axis-bottom { bottom: 50px; left: 50%; transform: translateX(-50%); }
.radar-axis-left { left: 50px; top: 50%; transform: translateY(-50%); }
.radar-axis-right { right: 50px; top: 50%; transform: translateY(-50%); }

.archetype-pill {
  display: none;
}

/* ===== Stat cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 20px 0;
}
.stat-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.stat-card-head { display: flex; align-items: center; gap: 8px; }
.stat-card-icon { font-size: 18px; }
.stat-card-label {
  flex: 1; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.65);
  letter-spacing: -.1px;
}
.stat-card-help {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 10px; line-height: 16px; text-align: center;
  color: rgba(255,255,255,0.4);
}
.stat-card-value {
  font-size: 30px; font-weight: 600;
  letter-spacing: -1px; line-height: 1;
}
.stat-card-bar {
  height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: hidden;
  display: flex;
}
.stat-card-fill { height: 100%; border-radius: 3px; transition: width .35s; }
.stat-card-fill.mint { background: linear-gradient(90deg, #7cf0a0, #ff7ab0); }
.stat-card-fill.amber { background: linear-gradient(90deg, #7cf0a0, #88aaaa); }

.more-stats-btn {
  width: calc(100% - 40px);
  margin: 18px 20px 8px;
  padding: 18px;
  background: rgba(255,255,255,0.04);
  border: none;
  border-radius: 999px;
  color: #fff;
  font-size: 16px; font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
}
.more-stats-btn:active { opacity: .7; }

/* ---- PROFILE (legacy) ---- */
.profile-top { display: flex; flex-direction: column; align-items: center; padding: calc(var(--safe-top) + 32px) 24px 24px; gap: 12px; }
.profile-avatar { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; background: var(--surface2); border: 2px solid var(--border); }
.profile-username { font-size: 24px; font-weight: 700; }
.profile-coins-row { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.profile-stats { padding: 0 24px; display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: var(--surface); border-radius: 16px; border: 1px solid var(--border); }
.stat-label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 15px; font-weight: 600; }
.profile-gear { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; }

/* ============== BACKGAMMON BOARD (Apple-grade) ============== */
.nard-screen { background: #000; display: flex; flex-direction: column; color: #fff; }
.nard-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 16px 4px;
  flex-shrink: 0;
  min-height: 36px;
}
.match-title { font-size: 13px; }
.match-score { font-size: 10px; }
.nard-topbar .back-btn { font-size: 22px; color: #fff; padding: 4px 10px; line-height: 1; }
.mute-btn {
  background: none; border: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: .85;
}
.mute-btn:active { opacity: 1; }
.match-info { text-align: center; flex: 1; }
.match-title { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.55); letter-spacing: .2px; }
.match-score {
  font-size: 11px; color: rgba(255,255,255,0.4);
  margin-top: 2px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 500;
}

.nard-board {
  flex: 1 1 auto; display: flex; flex-direction: column;
  align-items: stretch; justify-content: center;
  padding: 4px 6px; gap: 6px; min-height: 0;
  overflow: hidden;
}

/* Player strips — compact: avatar + name·pip on a single row */
.player-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px; gap: 10px; flex-shrink: 0;
  min-height: 44px;
}
.player-bar-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player-bar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
  position: relative;
}
.player-bar-avatar img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 50%;
  display: block;
}
.player-bar-info > div:not(.player-bar-avatar) {
  display: flex; align-items: baseline; gap: 8px; min-width: 0;
}
.player-bar-name { font-size: 14px; font-weight: 600; letter-spacing: -.1px; line-height: 1; }
.player-bar-pip { font-size: 11px; color: rgba(255,255,255,0.45); letter-spacing: .3px; }
.player-bar:not(.acting) .player-bar-name { color: rgba(255,255,255,0.65); }
.player-bar.acting .player-bar-avatar {
  animation: actingPulse 1.6s ease-in-out infinite;
}
@keyframes actingPulse {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 0 rgba(255,255,255,0.3); }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 0 8px rgba(255,255,255,0); }
}
.timer-ring-svg {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px); height: calc(100% + 12px);
  pointer-events: none;
  transform: rotate(-90deg);
  overflow: visible;
  z-index: 2;
}
.timer-ring-svg circle {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 100ms linear, stroke 200ms;
}

/* Bar/borne mini indicators */
.bar-extras { display: flex; gap: 8px; align-items: center; }
.bar-borne {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  font-size: 12px; font-weight: 600;
  color: rgba(255,255,255,0.7);
}

/* ===== Board with rich wood texture + depth ===== */
.board-wood {
  width: 100%;
  flex: 1 1 auto;
  min-height: 320px;
  margin: 0 auto;
  position: relative;
  border-radius: 18px;
  padding: 10px;
  /* Layered: subtle grain + warm highlight + wood gradient */
  background:
    /* fine vertical grain */
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.06) 0 1px,
      transparent 1px 4px
    ),
    /* organic noise pattern via SVG turbulence (data URI) */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.2  0 0 0 0 0.1  0 0 0 0.32 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    /* warm highlight at center */
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(255,180,120,0.10), transparent 70%),
    /* base wood gradient */
    linear-gradient(135deg, #5a3018 0%, #3a1d0c 50%, #5a3018 100%);
  background-size: auto, 200px 200px, auto, auto;
  background-blend-mode: normal, overlay, normal, normal;
  border: 3px solid #14080a;
  box-shadow:
    inset 0 2px 0 rgba(255,210,160,0.15),
    inset 0 -2px 0 rgba(0,0,0,0.55),
    inset 0 0 32px rgba(0,0,0,0.55),
    0 12px 32px rgba(0,0,0,0.65),
    0 4px 8px rgba(0,0,0,0.4);
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  grid-template-rows: 1fr 1fr;
}

.quadrant { display: grid; grid-template-columns: repeat(6, 1fr); position: relative; }
.quadrant.top-left, .quadrant.top-right { align-items: start; }
.quadrant.bot-left, .quadrant.bot-right { align-items: end; }

.point {
  position: relative;
  height: 100%;
  cursor: pointer;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.point-tri {
  position: absolute; left: 5%; right: 5%;
  height: 96%;
  z-index: 1;
}
.point.top .point-tri {
  top: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.point.bottom .point-tri {
  bottom: 0;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
}
.point.light .point-tri {
  background: linear-gradient(180deg, #d4ad7a 0%, #b8946a 70%, #9a7850 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.point.bottom.light .point-tri {
  background: linear-gradient(0deg, #d4ad7a 0%, #b8946a 70%, #9a7850 100%);
}
.point.dark .point-tri {
  background: linear-gradient(180deg, #2a160a 0%, #1a0c04 100%);
  box-shadow: inset 0 1px 0 rgba(255,180,120,0.06);
}
.point.bottom.dark .point-tri {
  background: linear-gradient(0deg, #2a160a 0%, #1a0c04 100%);
}

/* Highlight legal — green dot for normal move, red for hit */
.point.legal::before {
  content: '';
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 10px; height: 10px; border-radius: 50%;
  background: #7cf0a0;
  box-shadow: 0 0 12px 3px rgba(124,240,160,0.7);
  animation: legalDot 1.4s ease-in-out infinite;
  z-index: 4;
}
.point.legal.hit::before {
  background: #ff5050;
  box-shadow: 0 0 14px 4px rgba(255,80,80,0.85);
  animation: hitDot 0.9s ease-in-out infinite;
  width: 12px; height: 12px;
}
.point.top.legal::before { top: 100%; margin-top: -16px; }
.point.bottom.legal::before { bottom: 100%; margin-bottom: -16px; }
@keyframes legalDot {
  0%,100% { opacity: .85; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.3); }
}
@keyframes hitDot {
  0%,100% { opacity: .9;  transform: translateX(-50%) scale(1); }
  50%     { opacity: 1;   transform: translateX(-50%) scale(1.4); }
}

.point.selected .point-tri {
  outline: 2px solid #5dadec;
  outline-offset: -2px;
}

/* Checker stack */
.checkers {
  position: absolute; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center;
  z-index: 3; pointer-events: none;
}
.point.top .checkers { top: 4px; }
.point.bottom .checkers { bottom: 4px; flex-direction: column-reverse; }

.checker {
  --c-size: clamp(24px, 5.5vw, 36px);
  width: var(--c-size); height: var(--c-size);
  border-radius: 50%;
  margin: -3px 0 0;
  position: relative;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: grab;
  transition: transform .25s cubic-bezier(.2,.7,.3,1.2);
}
.point.top .checkers .checker:first-child,
.point.bottom .checkers .checker:first-child { margin-top: 0; }

/* Refined checkers — bone/ivory white, deep onyx black, with real depth */
.checker.white {
  background:
    radial-gradient(circle at 30% 25%, #ffffff 0%, #f5ecdc 35%, #e2cfa8 70%, #b89870 100%);
  box-shadow:
    inset 0 -3px 4px rgba(140,90,40,0.35),
    inset 0 2px 1px rgba(255,255,255,0.95),
    inset 0 0 0 1px rgba(180,140,90,0.25),
    0 3px 6px rgba(0,0,0,0.55),
    0 1px 2px rgba(0,0,0,0.3);
}
.checker.white::after {
  content: '';
  position: absolute; inset: 22%;
  border-radius: 50%;
  border: 1px solid rgba(120, 90, 60, 0.22);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.5), transparent 70%);
  pointer-events: none;
}
.checker.black {
  background:
    radial-gradient(circle at 30% 25%, #5a5a5a 0%, #2a2a2a 40%, #0c0c0c 80%, #000 100%);
  box-shadow:
    inset 0 -3px 4px rgba(0,0,0,0.7),
    inset 0 2px 1px rgba(255,255,255,0.22),
    inset 0 0 0 1px rgba(70,70,70,0.4),
    0 3px 6px rgba(0,0,0,0.65),
    0 1px 2px rgba(0,0,0,0.4);
}
.checker.black::after {
  content: '';
  position: absolute; inset: 22%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.10), transparent 70%);
  pointer-events: none;
}

.checker-count {
  position: relative; z-index: 2;
  font-size: 10px; font-weight: 700;
  letter-spacing: -.2px;
}
.checker.white .checker-count { color: #000; }
.checker.black .checker-count { color: #fff; }

.checker.dragging { cursor: grabbing; transform: scale(1.18); z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.checker.movable { animation: checkerNudge 2s ease-in-out infinite; }
@keyframes checkerNudge { 0%,90%,100% { transform: translateY(0); } 95% { transform: translateY(-2px); } }
.checker.just-hit { animation: hitFlash 0.9s ease-out; box-shadow: 0 0 0 2px #ff4d4d, 0 0 16px 4px rgba(255,77,77,0.8); }
@keyframes hitFlash {
  0%   { transform: scale(1.6); box-shadow: 0 0 0 4px #ff4d4d, 0 0 24px 8px rgba(255,77,77,1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}

/* Spine (middle bar) — slim and elegant, glows when checkers are on it */
.board-spine {
  grid-row: 1 / span 2;
  grid-column: 2;
  background: linear-gradient(180deg, #2a160a 0%, #1a0c04 50%, #2a160a 100%);
  border-left: 1px solid rgba(0,0,0,0.6);
  border-right: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 1px 0 0 rgba(255,180,120,0.06), inset -1px 0 0 rgba(255,180,120,0.06);
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  transition: box-shadow .3s ease;
}
.board-spine.has-bar {
  box-shadow:
    inset 1px 0 0 rgba(255,200,140,0.10),
    inset -1px 0 0 rgba(255,200,140,0.10),
    inset 0 0 24px rgba(255, 80, 80, 0.25);
  animation: spineBarPulse 1.8s ease-in-out infinite;
}
@keyframes spineBarPulse {
  0%, 100% { box-shadow:
    inset 1px 0 0 rgba(255,200,140,0.10),
    inset -1px 0 0 rgba(255,200,140,0.10),
    inset 0 0 18px rgba(255, 80, 80, 0.18); }
  50%      { box-shadow:
    inset 1px 0 0 rgba(255,200,140,0.10),
    inset -1px 0 0 rgba(255,200,140,0.10),
    inset 0 0 26px rgba(255, 80, 80, 0.45),
    0 0 16px rgba(255, 80, 80, 0.3); }
}

/* Bar checker stacks (in spine) — larger and more visible */
.spine-bar-checkers {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  pointer-events: auto;
  z-index: 6;
}
.spine-bar-checkers.top { top: 8px; }
.spine-bar-checkers.bottom { bottom: 8px; flex-direction: column-reverse; }
/* Override per-checker for spine — bigger than the in-point checkers */
.spine-bar-checkers .checker { --c-size: 30px; margin: -4px 0 0; }
.spine-bar-checkers .checker:first-child { margin-top: 0; }
.spine-bar-checkers .checker.movable { animation: barUrgent 1.2s ease-in-out infinite; }
@keyframes barUrgent {
  0%, 100% { transform: scale(1); box-shadow:
    inset 0 -3px 4px rgba(140,90,40,0.35),
    inset 0 2px 1px rgba(255,255,255,0.95),
    0 3px 6px rgba(0,0,0,0.55),
    0 0 0 2px rgba(255, 220, 130, 0.55),
    0 0 12px 3px rgba(255, 220, 130, 0.45); }
  50%      { transform: scale(1.06); box-shadow:
    inset 0 -3px 4px rgba(140,90,40,0.35),
    inset 0 2px 1px rgba(255,255,255,0.95),
    0 3px 6px rgba(0,0,0,0.55),
    0 0 0 3px rgba(255, 220, 130, 0.75),
    0 0 18px 6px rgba(255, 220, 130, 0.55); }
}

/* Big, prominent hit-notification banner shown at top of the board */
.hit-banner {
  position: absolute; left: 50%; top: 18%;
  transform: translateX(-50%) translateY(-10px);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 16px; font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 40px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity .2s ease, transform .35s cubic-bezier(.2,1.6,.4,1);
  white-space: nowrap;
}
.hit-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hit-banner.you-got-hit {
  background: rgba(220, 60, 60, 0.95);
  border-color: rgba(255, 180, 180, 0.4);
  box-shadow: 0 10px 30px rgba(220,60,60,0.45), 0 0 36px rgba(220,60,60,0.4);
}
.hit-banner.you-hit {
  background: rgba(124, 220, 120, 0.95);
  color: #0a3a0a;
  border-color: rgba(220, 255, 200, 0.5);
  box-shadow: 0 10px 30px rgba(80,200,80,0.45), 0 0 36px rgba(80,200,80,0.4);
}

/* Doubling cube disabled in UI (engine retains state at 1). */
.cube-holder { display: none; }

/* Bear-off tray indicator (right side) */
.bearoff-tray {
  position: absolute;
  right: -10px;
  width: 12px;
  background: linear-gradient(135deg, #2a1208, #1a0a04);
  border-radius: 4px;
  border: 1px solid #0a0402;
}
.bearoff-tray.top { top: 8px; bottom: 50%; }
.bearoff-tray.bottom { top: 50%; bottom: 8px; }

/* Board flipping for BLACK hero — rotate the wood and counter-rotate text */
.board-wood.board-flipped {
  transform: rotate(180deg);
}
.board-wood.board-flipped .checker-count {
  display: inline-block;
  transform: rotate(180deg);
}
.board-wood.board-flipped .cube-holder {
  transform: translate(-50%, -50%) rotate(180deg);
}
/* Subtle hero-checker affordance — soft glow + slow breathing on movable hero checkers */
.checker.tap-hint {
  animation: tapHint 1.8s ease-in-out infinite;
  cursor: pointer;
}
@keyframes tapHint {
  0%, 100% { box-shadow:
              inset 0 -3px 4px rgba(140,90,40,0.35),
              inset 0 2px 1px rgba(255,255,255,0.95),
              0 3px 6px rgba(0,0,0,0.55),
              0 0 0 0 rgba(255, 220, 130, 0); }
  50%      { box-shadow:
              inset 0 -3px 4px rgba(140,90,40,0.35),
              inset 0 2px 1px rgba(255,255,255,0.95),
              0 3px 6px rgba(0,0,0,0.55),
              0 0 0 3px rgba(255, 220, 130, 0.55),
              0 0 14px 4px rgba(255, 220, 130, 0.35); }
}
.checker.black.tap-hint {
  animation: tapHintBlack 1.8s ease-in-out infinite;
}
@keyframes tapHintBlack {
  0%, 100% { box-shadow:
              inset 0 -3px 4px rgba(0,0,0,0.7),
              inset 0 2px 1px rgba(255,255,255,0.22),
              0 3px 6px rgba(0,0,0,0.65),
              0 0 0 0 rgba(170, 220, 255, 0); }
  50%      { box-shadow:
              inset 0 -3px 4px rgba(0,0,0,0.7),
              inset 0 2px 1px rgba(255,255,255,0.22),
              0 3px 6px rgba(0,0,0,0.65),
              0 0 0 3px rgba(170, 220, 255, 0.55),
              0 0 14px 4px rgba(170, 220, 255, 0.35); }
}

/* Flying-checker overlay used for move animations */
.checker.flyer {
  position: fixed !important;
  z-index: 1500;
  pointer-events: none;
  transition: transform .42s cubic-bezier(.2, .8, .25, 1);
  margin: 0 !important;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
}
.checker.flyer.fly-hit { transition-duration: .55s; transition-timing-function: cubic-bezier(.4,1.8,.5,1); }
.checker.flyer.fly-off { transition-duration: .50s; }

/* "Your turn" banner — briefly fades in then out */
.turn-banner {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.92);
  background: rgba(255,255,255,0.96);
  color: #000;
  font-size: 16px; font-weight: 700;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity .2s ease, transform .35s cubic-bezier(.2,1.6,.4,1);
  letter-spacing: -0.2px;
}
.turn-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Win celebration overlay sparkle background */
.result-overlay.win::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 35%, rgba(255,210,90,0.18), transparent 35%),
    radial-gradient(circle at 75% 65%, rgba(124,240,160,0.16), transparent 38%);
  pointer-events: none;
}

/* Drag floater */
.drag-floater {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  width: 40px; height: 40px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Compact action strip below the board — dice on the left, buttons stack on the right.
   Total height kept tight so the board gets the rest. */
.nard-actions {
  flex-shrink: 0;
  padding: 4px 14px calc(var(--safe-bot) + 4px);
  display: flex; flex-direction: row; gap: 12px;
  align-items: center;
  justify-content: center;
  min-height: 76px;
}
.dice-host {
  width: 140px;
  height: 52px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.action-btns {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1; min-width: 0;
}
@media (max-height: 700px) {
  .nard-actions { min-height: 64px; padding-top: 2px; padding-bottom: calc(var(--safe-bot) + 2px); }
  .dice-host { height: 44px; width: 120px; }
}
@media (max-height: 620px) {
  .nard-actions { min-height: 54px; }
  .dice-host { height: 38px; width: 110px; }
}
.dice-host canvas { display: block; }
.action-btns {
  width: 100%;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}
.action-msg, .cube-offer-msg {
  text-align: center; font-size: 13px; color: rgba(255,255,255,0.55);
  padding: 6px; font-weight: 500;
}
.bot-action-msg {
  text-align: center; font-size: 13px; color: rgba(255,255,255,0.7);
  padding: 6px 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.6);
  animation: thinkingDot 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinkingDot {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.cube-offer-msg { color: #ffd25a; font-weight: 600; }

/* ===== 3D Cube Dice ===== */
.dice-display {
  display: flex; gap: 18px; justify-content: center; align-items: center;
  padding: 6px 0;
  perspective: 600px;
}
.die-3d {
  width: 48px; height: 48px;
  display: inline-block;
  position: relative;
  transform-style: preserve-3d;
}
.die-cube {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
}
.die-face {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #ffffff 0%, #ececec 100%);
  border-radius: 9px;
  padding: 5px;
  box-shadow:
    inset 0 -2px 0 rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 0 0 1px rgba(0,0,0,0.06);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  backface-visibility: hidden;
}
.die-face .pip {
  width: 6px; height: 6px;
  background: radial-gradient(circle at 35% 30%, #555, #0a0a0a);
  border-radius: 50%;
  align-self: center; justify-self: center;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.2);
}

/* 6 face positions around the cube (translateZ = half size = 24px) */
.face-1 { transform: translateZ(24px); }
.face-2 { transform: rotateY(90deg) translateZ(24px); }
.face-3 { transform: rotateX(-90deg) translateZ(24px); }
.face-4 { transform: rotateX(90deg) translateZ(24px); }
.face-5 { transform: rotateY(-90deg) translateZ(24px); }
.face-6 { transform: rotateY(180deg) translateZ(24px); }

/* Static (settled) — show face N */
.die-cube.show-1 { transform: rotateX(0)        rotateY(0); }
.die-cube.show-2 { transform: rotateX(0)        rotateY(-90deg); }
.die-cube.show-3 { transform: rotateX(-90deg)   rotateY(0); }
.die-cube.show-4 { transform: rotateX(90deg)    rotateY(0); }
.die-cube.show-5 { transform: rotateX(0)        rotateY(90deg); }
.die-cube.show-6 { transform: rotateX(0)        rotateY(180deg); }

/* Idle wobble — when waiting for tap */
.die-cube.idle { animation: dieIdle 3s ease-in-out infinite; }
@keyframes dieIdle {
  0%, 90%, 100% { transform: rotateX(-8deg) rotateY(8deg); }
  45% { transform: rotateX(8deg) rotateY(-12deg); }
}

/* Tumble: lands on each face. Big rotation count = many flips visible. */
.die-cube.rolling-to-1 { animation: roll1 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }
.die-cube.rolling-to-2 { animation: roll2 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }
.die-cube.rolling-to-3 { animation: roll3 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }
.die-cube.rolling-to-4 { animation: roll4 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }
.die-cube.rolling-to-5 { animation: roll5 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }
.die-cube.rolling-to-6 { animation: roll6 0.95s cubic-bezier(.16,.7,.35,1.04) forwards; }

/* All keyframes start in air, tumble, settle on the face */
@keyframes roll1 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(180deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(540deg) rotateY(900deg); }
  100% { transform: translateY(0)     rotateX(720deg) rotateY(1440deg); }
}
@keyframes roll2 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(180deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(540deg) rotateY(810deg); }
  100% { transform: translateY(0)     rotateX(720deg) rotateY(1350deg); }
}
@keyframes roll3 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(135deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(450deg) rotateY(900deg); }
  100% { transform: translateY(0)     rotateX(630deg) rotateY(1440deg); }
}
@keyframes roll4 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(225deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(630deg) rotateY(900deg); }
  100% { transform: translateY(0)     rotateX(810deg) rotateY(1440deg); }
}
@keyframes roll5 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(180deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(540deg) rotateY(990deg); }
  100% { transform: translateY(0)     rotateX(720deg) rotateY(1530deg); }
}
@keyframes roll6 {
  0%   { transform: translateY(-50px) rotateX(0)      rotateY(0); opacity: 0; }
  15%  { transform: translateY(0)     rotateX(180deg) rotateY(360deg); opacity: 1; }
  60%  { transform: translateY(-6px)  rotateX(540deg) rotateY(720deg); }
  100% { transform: translateY(0)     rotateX(720deg) rotateY(1260deg); }
}

/* Roll prompt — waiting for tap */
.dice-prompt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}
.dice-prompt-label { font-size: 15px; color: rgba(255,255,255,0.65); font-weight: 500; }
.die-face {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #fff 0%, #e8e8e8 100%);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 6px;
  gap: 2px;
  box-shadow:
    inset 0 -2px 0 rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 3px 8px rgba(0,0,0,0.4);
}
.die-face .pip {
  background: #1a1a1a;
  border-radius: 50%;
  width: 6px; height: 6px;
  align-self: center; justify-self: center;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.act-roll {
  background: #fff !important; color: #000 !important;
  font-weight: 700;
  border: none;
  padding: 14px;
  border-radius: 18px;
}
.act-cube { background: #ffd25a !important; color: #000 !important; font-weight: 700; }

/* Toast / hint banner — positioned LOW so it never overlaps the cube */
.move-hint {
  position: absolute; left: 50%; bottom: 6%;
  top: auto;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 8px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
  border: 1px solid rgba(255,255,255,0.1);
  z-index: 25;
  white-space: nowrap;
}
.move-hint.show { opacity: 1; }
.move-hint.hit-flash { background: rgba(220,60,60,0.92); border-color: rgba(255,150,150,0.3); }

/* ============== POKER TABLE (Refined Sleeper-style) ============== */
.poker-screen { background: #000; display: flex; flex-direction: column; }
.table-topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 12px) 20px 4px; flex-shrink: 0; }
.back-btn { background: none; border: none; color: #fff; padding: 4px 8px; font-size: 24px; cursor: pointer; line-height: 1; }
.xp-badge { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.xp-arrow { color: var(--muted); font-size: 12px; }
.table-name { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }

.felt { flex: 1; display: flex; flex-direction: column; padding: 0 16px; min-height: 0; overflow: hidden; }

/* Players strip */
.players-strip { display: flex; justify-content: space-around; align-items: flex-start; padding: 16px 0 8px; gap: 4px; }
.player-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 0; transition: opacity .25s; position: relative; }
.player-tile.folded { opacity: .25; }
.player-tile.acting .avatar-wrap { box-shadow: 0 0 0 2px #fff; }
.avatar-wrap { width: 52px; height: 52px; border-radius: 50%; background: transparent; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; flex-shrink: 0; transition: box-shadow .2s; }
.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-emoji { font-size: 38px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.dealer-tag { position: absolute; bottom: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: #000; font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 1.5px solid #000; }
.player-name { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; line-height: 1.1; }
.player-chips { font-size: 13px; font-weight: 600; color: var(--muted); }
.player-tile.acting .player-name, .player-tile.acting .player-chips { color: #fff; }
.player-tile.folded .player-name, .player-tile.folded .player-chips { color: rgba(255,255,255,0.35); }
.bet-pill { background: #ffd25a; color: #000; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; min-width: 22px; text-align: center; margin-top: 2px; box-shadow: 0 2px 6px rgba(255,210,90,0.3); }

/* Community cards section */
.community-section { display: flex; flex-direction: column; align-items: stretch; justify-content: center; flex: 1; gap: 6px; padding: 10px 0; }
.community-cards-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.community-cards { display: flex; gap: 6px; }
.pot-side { font-size: 14px; font-weight: 600; color: #fff; min-width: 32px; text-align: right; }
.pot-side.zero { color: rgba(255,255,255,0.3); }

/* Playing cards */
.card { width: 56px; height: 80px; background: #fff; border-radius: 12px; display: flex; flex-direction: column; padding: 8px 9px; position: relative; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.35); transition: background .3s, color .3s, transform .35s ease; }
.card .rank { font-size: 22px; font-weight: 700; line-height: 1; align-self: flex-start; letter-spacing: -1px; }
.card .suit { font-size: 18px; line-height: 1; align-self: flex-start; margin-top: auto; }
.card.red .rank, .card.red .suit { color: #ff3030; }
.card.black .rank, .card.black .suit { color: #111; }
.card.unused { background: #2a2a2a; }
.card.unused .rank, .card.unused .suit { color: rgba(255,255,255,0.35); }
.card.facedown {
  background:
    repeating-linear-gradient(45deg, #fff 0 4px, #1a1a1a 4px 8px);
}
.card.facedown .rank, .card.facedown .suit { display: none; }
.card.dealt { animation: dealIn .35s ease both; }
@keyframes dealIn { from { transform: translateY(-24px) scale(.7); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* Action area */
.action-area { display: flex; flex-direction: column; gap: 8px; padding: 0 4px; flex-shrink: 0; min-height: 56px; justify-content: center; }
.next-hand-btn { width: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--border); color: #fff; border-radius: 22px; font-size: 16px; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.next-hand-btn:active { opacity: .75; }

.action-row { display: flex; gap: 8px; align-items: center; }
.act-btn {
  flex: 1; padding: 14px 8px; border-radius: 22px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: #1a1a1a; color: #fff;
  transition: opacity .15s, background .15s;
}
.act-btn:active { opacity: .7; }
.act-fold { background: #1a1a1a; color: rgba(255,255,255,0.7); }
.act-raise-up { flex: 0 0 48px; padding: 14px 0; background: #1a1a1a; color: #fff; font-size: 16px; }

.raise-popover {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  background: #1a1a1a; border: 1px solid var(--border); border-radius: 18px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 50;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
}
.raise-popover .raise-amounts { display: flex; gap: 8px; flex-wrap: wrap; }
.raise-popover .raise-amount-btn { flex: 1; min-width: 60px; padding: 10px; background: #2a2a2a; border: none; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.raise-popover .raise-amount-btn.active { background: #fff; color: #000; }
.raise-popover .raise-slider-row { display: flex; align-items: center; gap: 10px; }
.raise-popover input[type=range] { flex: 1; accent-color: #fff; }
.raise-popover .raise-confirm { width: 100%; padding: 12px; background: #fff; color: #000; border: none; border-radius: 14px; font-size: 14px; font-weight: 700; cursor: pointer; }

/* Hero strip */
.hero-strip { display: flex; justify-content: space-between; align-items: flex-end; padding: 8px 0 calc(var(--safe-bot) + 8px); gap: 12px; flex-shrink: 0; }
.hero-cards-stacked { display: flex; position: relative; }
.hero-cards-stacked .card { width: 76px; height: 106px; box-shadow: 0 6px 16px rgba(0,0,0,0.5); }
.hero-cards-stacked .card:nth-child(2) { margin-left: -16px; transform: rotate(3deg); transform-origin: bottom left; }
.hero-cards-stacked .card .rank { font-size: 28px; }
.hero-cards-stacked .card .suit { font-size: 22px; }

.hero-info { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 100px; }
.hero-info-tag { font-size: 11px; color: var(--muted); }
.hero-info-avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: transparent; display: flex; align-items: center; justify-content: center; }
.hero-info-avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero-info-avatar .avatar-emoji { font-size: 26px; }
.hero-info-chips { font-size: 16px; font-weight: 700; }

/* Stats overlay (Win % / Hand %) */
.stats-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #1a1a1a; border-radius: 24px; padding: 28px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  z-index: 150; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  min-width: 220px;
}
.stats-panel .stat-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stats-panel .stat-block-label { font-size: 14px; color: var(--muted); font-weight: 500; }
.stats-panel .stat-block-value { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.stats-panel .stat-block-value.win-rate { color: #7cf0a0; }
.stats-panel .stat-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }

.stats-toggle {
  position: absolute; right: 20px; top: calc(var(--safe-top) + 14px);
  background: rgba(255,255,255,0.08); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}

/* Result overlay */
.result-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.92); backdrop-filter: blur(20px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 200; padding: 32px; text-align: center; }
.result-emoji { font-size: 64px; }
.result-title { font-size: 28px; font-weight: 800; }
.result-sub { font-size: 15px; color: var(--muted); }
.result-amount { font-size: 40px; font-weight: 800; }
.result-amount.win { color: #7cf0a0; }
.result-amount.lose { color: #ff8080; }
.blind-info { font-size: 11px; color: rgba(255,255,255,0.3); text-align: center; }

.hidden { display: none !important; }

/* Toasts */
.toast { position: fixed; top: calc(var(--safe-top) + 60px); left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.12); backdrop-filter: blur(12px); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 500; z-index: 999; pointer-events: none; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

/* ============== Matchmaking (PvP entry) ============== */
.mm-screen { background: linear-gradient(180deg, #0f0f0f 0%, #050505 100%); }

.mm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px 12px;
  flex-shrink: 0;
}
.mm-balance { font-size: 17px; font-weight: 500; color: rgba(255,255,255,0.95); }

.mm-card {
  margin: 0 16px;
  padding: 28px 24px 32px;
  background: linear-gradient(180deg, rgba(30,30,30,0.7) 0%, rgba(18,18,18,0.7) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  align-items: center;
}
.mm-label {
  font-size: 14px; font-weight: 500;
  color: #b3d9a4;
  letter-spacing: .2px;
  margin-bottom: 6px;
}
.mm-value {
  font-size: 44px; font-weight: 700;
  letter-spacing: -1px; line-height: 1;
  color: #b3d9a4;
  margin-bottom: 18px;
  font-variant-numeric: tabular-nums;
}
.mm-value.white { color: #fff; }

.mm-slider {
  width: 100%;
  height: 36px;
  display: flex; align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.mm-tick {
  flex: 1;
  height: 18px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  transition: height .2s, background .2s;
}
.mm-tick.active {
  height: 32px;
  background: #fff;
}

.mm-foot {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--safe-bot) + 16px);
  display: flex; flex-direction: column;
  gap: 12px;
  padding: 0 16px;
}
.mm-status {
  min-height: 22px;
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.55);
}
.mm-priv { line-height: 1.6; }
.mm-priv b { color: #fff; font-size: 16px; letter-spacing: 2px; }
.mm-link { color: rgba(255,255,255,0.4); font-size: 11px; word-break: break-all; }

.mm-public-btn {
  width: 100%; padding: 16px;
  background: transparent;
  border: 1.5px solid rgba(179, 217, 164, 0.4);
  border-radius: var(--r-pill);
  color: #b3d9a4;
  font-size: 14px; font-weight: 600;
  letter-spacing: 1.5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  transition: background .15s;
  font-family: inherit;
}
.mm-public-btn:active { background: rgba(179, 217, 164, 0.08); }
.mm-public-btn:not(.active) { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.18); }
.mm-public-btn:not(.active) svg path { stroke: rgba(255,255,255,0.6); }

.mm-start-btn {
  width: 100%; padding: 18px;
  background: #fff; color: #000;
  border: none;
  border-radius: var(--r-pill);
  font-size: 15px; font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
}
.mm-start-btn:active { opacity: .9; transform: scale(.98); }

/* Lobby back header */
.lobby-header { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-top) + 16px) 24px 0; flex-shrink: 0; }
.lobby-header h1 { flex: 1; }

/* Refill / daily bonus card */
.refill-card {
  margin: 12px 24px 0;
  padding: 14px;
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 10px;
}
.refill-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.refill-title { font-size: 14px; font-weight: 600; }
.refill-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.refill-btn {
  padding: 10px 18px; background: #fff; color: #000;
  border: none; border-radius: 14px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.bonus-btn {
  width: 100%; padding: 14px;
  background: rgba(255,200,50,0.10);
  border: 1px solid rgba(255,200,50,0.3);
  color: #ffd25a;
  border-radius: 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}

/* Spinner */
.spinner { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spin { width: 32px; height: 32px; border: 2px solid var(--border); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Insufficient funds */
.lock-msg { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Active player timer ring */
.timer-ring { position: absolute; top: -3px; left: -3px; right: -3px; bottom: -3px; border-radius: 50%; border: 3px solid transparent; border-top-color: #fff; animation: spin 15s linear; }

/* Winner highlight */
@keyframes winPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } 50% { box-shadow: 0 0 0 8px rgba(255,255,255,0.25); } }
.seat-avatar.winner { animation: winPulse 1s ease 3; border-color: #7cf0a0; }

/* Hand rank display */
.hand-rank { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: center; }

/* ============================================================
   GLOBAL POLISH — accessibility, motion, focus, RTL, small screens
   ============================================================ */

/* Force consistent dark visuals even if OS forces light mode */
@media (prefers-color-scheme: light) {
  html, body { background: #000; color: #fff; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .checker.movable, .point.legal::before, .die-cube.idle,
  .thinking-dots span, .music-equalizer span,
  .player-bar.acting .player-bar-avatar { animation: none !important; }
}

/* Visible keyboard focus (no effect on mouse/touch thanks to :focus-visible) */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus-visible, a:focus-visible, [role="button"]:focus-visible,
.tier-card:focus-visible, .nav-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* Hover affordances — desktop only, never on touch */
@media (hover: hover) and (pointer: fine) {
  .nav-btn:hover { opacity: .75; }
  .nav-btn.active:hover { opacity: 1; }
  .btn-primary:hover { opacity: .92; }
  .btn-outline:hover { background: rgba(255,255,255,0.05); }
  .venue-card:hover { transform: translateY(-2px); }
  .tier-card:hover { transform: translateY(-3px); }
  .game-row:hover { background: rgba(255,255,255,0.04); }
  .pf-pill:hover, .pf-rank-row:hover { background: rgba(255,255,255,0.05); }
  .music-card:hover { transform: translateY(-2px); }
}

/* Prevent iOS auto-zoom on any input (already 16px on .input, cover everything) */
input, select, textarea { font-size: 16px; }

/* ============== RTL: mirror absolutely-positioned elements ============== */
[dir="rtl"] .venue-card .lock-icon { right: auto; left: 16px; }
[dir="rtl"] .tier-lock { right: auto; left: 24px; }
[dir="rtl"] .avatar-edit-pen { right: auto; left: -2px; }
[dir="rtl"] .timer-pill .timer-dot { right: auto; left: 0; }
[dir="rtl"] .stats-toggle { right: auto; left: 20px; }
[dir="rtl"] .stats-panel .stat-close { right: auto; left: 14px; }
[dir="rtl"] .music-equalizer { right: auto; left: 14px; }
[dir="rtl"] .radar-corner-tl { left: auto; right: 14px; }
[dir="rtl"] .radar-corner-tr { right: auto; left: 14px; }
[dir="rtl"] .radar-corner-bl { left: auto; right: 14px; }
[dir="rtl"] .radar-corner-br { right: auto; left: 14px; }
[dir="rtl"] .radar-axis-left { left: auto; right: 50px; }
[dir="rtl"] .radar-axis-right { right: auto; left: 50px; }
[dir="rtl"] .pf-rank-bar { margin-left: 0; margin-right: 8px; }

/* Backgammon board stays as-is (geometry is direction-agnostic; bear-off side is conventional) */
[dir="rtl"] .nard-board, [dir="rtl"] .board-wood { direction: ltr; }

/* Dice host left-aligned numerals (otherwise look odd in RTL) */
.dice-host { direction: ltr; }

/* Mirror chevron-arrows in RTL */
[dir="rtl"] .game-arrow, [dir="rtl"] .pf-arrow {
  transform: scaleX(-1);
}

/* Persian digits look weird mixed with Latin — let the system handle */
[dir="rtl"] { font-feature-settings: "ss01" on; }

/* ============== Small phones (< 360px) ============== */
@media (max-width: 360px) {
  .topbar { padding-inline: 16px; }
  .home-toprow { padding-inline: 16px; }
  .card-list { padding: 14px 16px; }
  .home-balance-block { padding-inline: 16px; }
  .tier-carousel { padding: 0 16px; }
  .tier-card { flex: 0 0 calc(100vw - 64px); }
  .music-carousel { padding: 4px 16px; }
  .music-card { flex: 0 0 calc(100vw - 80px); }
  .season-content { padding: 20px 16px calc(var(--safe-bot) + 24px); }
  .leaderboard-section { padding-inline: 16px; }
  .big-balance { letter-spacing: -1.5px; }
}

/* ============== Update banner (SW update prompt) ============== */
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + 12px);
  z-index: 1500;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 18px;
  background: rgba(20,20,20,0.95);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-pill);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 14px; color: #fff;
  animation: bannerIn .3s cubic-bezier(.2,.7,.3,1.2);
}
.update-banner button {
  background: #fff; color: #000; border: none;
  padding: 8px 14px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
@keyframes bannerIn {
  from { transform: translate(-50%, -16px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ============== Empty/loading states ============== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.empty-state .empty-emoji {
  font-size: 36px; display: block; margin-bottom: 12px;
  opacity: 0.7;
}
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
  border-radius: var(--r-md);
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============== Safe-area horizontal padding for landscape notch ============== */
@media (orientation: landscape) {
  .topbar, .home-toprow, .season-topbar, .profile-toprow, .nard-topbar {
    padding-left: max(var(--safe-l), 20px);
    padding-right: max(var(--safe-r), 20px);
  }
  .nav { padding-left: var(--safe-l); padding-right: var(--safe-r); }
}

/* ============== Hide-by-default class for JS toggles ============== */
.hidden { display: none !important; }
