/* Self-contained typography: the release includes the official variable WOFF2 subsets. */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/quicksand-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/quicksand-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   SUDOKU BLOOM — Pastel Soft & Sweet Professional Design System
   Mobile-First & Fully Responsive Architecture
   ========================================================================== */

:root {
  /* Soft Pastel Color Palette */
  --bg-page: #fff5f8;
  --bg-subtle: #fdf0f5;
  --bg-surface: #ffffff;
  --bg-surface-hover: #fff9fb;
  
  --border-color: #fce7f3;
  --border-subtle: #fff1f7;
  --border-strong: #f9a8d4;
  --border-focus: #f472b6;

  /* Typography Colors — Rich Warm Plum Ink */
  --text-primary: #3d2639;
  --text-secondary: #644b5f;
  --text-muted: #94788c;
  --text-faint: #c4aabf;

  /* Brand Accents — Sweet Sakura & Blossom */
  --brand-primary: #ec4899;
  --brand-primary-hover: #db2777;
  --brand-primary-subtle: #fdf2f8;
  --brand-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 50%, #db2777 100%);
  --brand-gradient-soft: linear-gradient(135deg, #fce7f3 0%, #ede9fe 100%);
  
  /* Semantics */
  --success: #10b981;
  --success-subtle: #ecfdf5;
  --success-text: #047857;
  --warning: #f59e0b;
  --warning-subtle: #fffbeb;
  --warning-text: #b45309;
  --danger: #f43f5e;
  --danger-subtle: #fff1f2;
  --danger-text: #be123c;
  --duel: #a855f7;
  --duel-subtle: #faf5ff;
  --duel-text: #7e22ce;

  /* Difficulties */
  --diff-easy: #34d399;
  --diff-medium: #fbbf24;
  --diff-medium-plus: #f59e0b;
  --diff-hard: #fb923c;
  --diff-very-hard: #f97316;
  --diff-expert: #f87171;
  --diff-master: #a78bfa;
  --diff-extreme: #f472b6;

  /* Board Highlights */
  --cell-bg-alt: #fff9fb;
  --cell-bg-peer: #fdf2f8;
  --cell-bg-selected: #fce7f3;
  --cell-bg-same: #fbd8ec;
  --cell-border-color: #fce7f3;
  --cell-border-box: #5a4053;
  --cell-text-given: #3d2639;
  --cell-text-input: #db2777;

  /* Geometry & Radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(219, 39, 119, 0.05);
  --shadow-md: 0 6px 18px rgba(219, 39, 119, 0.08), 0 2px 6px rgba(219, 39, 119, 0.04);
  --shadow-lg: 0 12px 28px rgba(219, 39, 119, 0.11), 0 4px 10px rgba(219, 39, 119, 0.05);
  --shadow-xl: 0 20px 38px rgba(219, 39, 119, 0.15), 0 8px 16px rgba(219, 39, 119, 0.06);

  /* Typography */
  --font-display: 'Quicksand', 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

/* --------------------------------------------------------------------------
   Reset & Touch Optimization
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(circle at 100% 0%, #ffe4ec 0%, transparent 40%),
                    radial-gradient(circle at 0% 100%, #f5f0ff 0%, transparent 40%);
  background-attachment: fixed;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a, button, input, select, textarea {
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Boot Splash & Spinner
   -------------------------------------------------------------------------- */
.boot-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 16px;
}

.boot-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.boot-text {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font-display);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Layout Primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

.page {
  padding-top: 24px;
  padding-bottom: 72px;
  flex: 1;
}

.card {
  position: relative;
  z-index: 1;
  background-color: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.card + .card {
  margin-top: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .ic {
  color: var(--brand-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.card-link {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand-primary);
  transition: color 0.15s ease;
}

.card-link:hover {
  color: var(--brand-primary-hover);
  text-decoration: underline;
}

/* Page Header */
.page-header {
  margin-bottom: 22px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Top Navigation Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 245, 248, 0.92);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid rgba(252, 231, 243, 0.9);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  flex-shrink: 0;
}

.logo-petal {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 6px;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35);
  transform: rotate(-6deg);
}

.logo-petal svg {
  width: 19px;
  height: 19px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  margin-left: 16px;
  flex-wrap: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--brand-primary);
  background-color: var(--brand-primary-subtle);
}

.nav-link.active {
  color: #ffffff;
  background: var(--brand-gradient);
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.3);
}

.nav-icon {
  width: 17px;
  height: 17px;
}

.header-user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 5px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.user-pill:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

.user-pill-name {
  font-weight: 700;
  font-size: 13.5px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-level-pill {
  background-color: var(--brand-primary-subtle);
  color: var(--brand-primary);
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   Mobile Bottom Navigation Bar
   -------------------------------------------------------------------------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 245, 248, 0.94);
  backdrop-filter: blur(20px) saturate(1.7);
  -webkit-backdrop-filter: blur(20px) saturate(1.7);
  border-top: 1px solid rgba(252, 231, 243, 0.95);
  padding: 5px 8px calc(6px + env(safe-area-inset-bottom)) 8px;
  box-shadow: 0 -4px 20px rgba(219, 39, 119, 0.07);
}

.bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s ease;
  min-width: 52px;
}

.bottom-nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.bottom-nav-icon svg {
  width: 20px;
  height: 20px;
}

.bottom-nav-item.active {
  color: var(--brand-primary);
  font-weight: 800;
}

.bottom-nav-item.active .bottom-nav-icon {
  color: var(--brand-primary);
  transform: translateY(-2px);
}

.mobile-nav-hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, #f472b6, #ec4899);
  color: #ffffff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.25);
}

.avatar-xs { width: 26px; height: 26px; font-size: 11.5px; }
.avatar-sm { width: 34px; height: 34px; font-size: 13.5px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl { width: 68px; height: 68px; font-size: 24px; }

.avatar-rival { background: linear-gradient(135deg, #c084fc, #a855f7); }
.avatar-gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  line-height: 1.25;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.45);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--brand-primary-subtle);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--brand-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background-color: #e11d48;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-md);
}

.btn-xl {
  padding: 15px 32px;
  font-size: 16.5px;
  font-weight: 800;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-icon {
  display: inline-flex;
  width: 13px;
  height: 13px;
}

.badge-icon svg {
  width: 100%;
  height: 100%;
}

.diff-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.badge-success { background-color: var(--success-subtle); color: var(--success-text); border-color: rgba(16, 185, 129, 0.25); }
.badge-warning { background-color: var(--warning-subtle); color: var(--warning-text); border-color: rgba(245, 158, 11, 0.25); }
.badge-danger { background-color: var(--danger-subtle); color: var(--danger-text); border-color: rgba(244, 63, 94, 0.25); }
.badge-duel { background-color: var(--duel-subtle); color: var(--duel-text); border-color: rgba(168, 85, 247, 0.25); }
.badge-brand { background-color: var(--brand-primary-subtle); color: var(--brand-primary-hover); border-color: rgba(236, 72, 153, 0.25); }
.badge-streak { background-color: #fff7ed; color: #c2410c; border-color: rgba(249, 115, 22, 0.25); }
.badge-subtle { background-color: var(--bg-subtle); color: var(--text-muted); border-color: var(--border-color); }

/* --------------------------------------------------------------------------
   XP Progress Bar & Progress Rings
   -------------------------------------------------------------------------- */
.xp-bar-container {
  width: 100%;
}

.xp-bar {
  height: 10px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.xp-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.xp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 5px;
}

.xp-needed strong {
  color: var(--brand-primary);
}

/* SVG Rings */
.ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ring-svg {
  display: block;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-caption {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ring-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--brand-primary);
  font-family: var(--font-display);
}

.ring-mini-val {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.ring-mini-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.ring-mini-icon .ic,
.ring-mini-icon .ic svg {
  display: block;
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Dashboard Views & Components
   -------------------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
  align-items: start;
}

.dash-col-main, .dash-col-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Active Session Banner */
.active-session-banner {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--brand-primary-subtle);
  border-color: var(--border-strong);
  padding: 16px 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.active-session-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7);
  animation: pulse-ring 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(236, 72, 153, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
}

.active-session-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--brand-primary);
}

.active-session-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.active-session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hero Player Card */
.hero-card {
  margin-bottom: 20px;
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, #fff7fb 100%);
  border-color: var(--border-color);
}

.hero-profile {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 1;
  min-width: 260px;
}

.hero-details {
  flex: 1;
}

.hero-greeting {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-username {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 2px 0 8px;
}

.hero-xp {
  max-width: 440px;
}

.hero-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  z-index: 1;
  background-color: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.metric-card.accent-success .metric-icon { background-color: var(--success-subtle); color: var(--success); }
.metric-card.accent-warning .metric-icon { background-color: var(--warning-subtle); color: var(--warning); }
.metric-card.accent-brand .metric-icon { background-color: var(--brand-primary-subtle); color: var(--brand-primary); }
.metric-card.accent-danger .metric-icon { background-color: var(--danger-subtle); color: var(--danger); }
.metric-card.accent-duel .metric-icon { background-color: var(--duel-subtle); color: var(--duel); }

.metric-value {
  font-size: 21px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1.1;
}

.metric-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -3px;
}

/* Heatmap Component */
.heatmap-container, .heatmap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 13px);
  grid-auto-columns: 13px;
  gap: 3.5px;
  width: max-content;
}

.hm-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  transition: transform 0.1s ease;
}

.hm-cell:hover {
  transform: scale(1.3);
  z-index: 2;
}

.hm-l1 { background-color: #fbcfe8; border-color: #f9a8d4; }
.hm-l2 { background-color: #f472b6; border-color: #ec4899; }
.hm-l3 { background-color: #db2777; border-color: #be185d; }
.hm-l4 { background-color: #9d174d; border-color: #831843; }

.hm-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  justify-content: flex-end;
}

.hm-legend-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

/* Home Personal Rank Card */
.home-rank-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.home-rank-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff5f9 0%, #ffffff 100%);
  border: 1.5px solid var(--brand-primary-subtle);
  border-radius: var(--radius-md);
}

.home-rank-badge-wrap {
  flex-shrink: 0;
}

.home-rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.home-rank-badge.gold {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  border: 2px solid #f59e0b;
}

.home-rank-badge.silver {
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  color: #4b5563;
  border: 2px solid #9ca3af;
}

.home-rank-badge.bronze {
  background: linear-gradient(135deg, #ffedd5, #fed7aa);
  color: #c2410c;
  border: 2px solid #fb923c;
}

.home-rank-badge.normal {
  background: linear-gradient(135deg, var(--brand-primary-subtle), #ffffff);
  color: var(--brand-primary);
  border: 2px solid var(--border-color);
}

.home-rank-hero-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.home-rank-hero-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.home-rank-hero-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.home-rank-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.home-rank-stat-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.home-rank-stat-pill .stat-pill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--brand-primary);
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.home-rank-stat-pill .stat-pill-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.home-rank-stat-pill .stat-pill-text strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.home-rank-stat-pill .stat-pill-text small {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Leaderboard List */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
}

.lb-row:hover {
  background-color: var(--bg-subtle);
}

.lb-row-me {
  background-color: var(--brand-primary-subtle);
}

.lb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--text-muted);
  width: 28px;
}

.lb-rank.rank-1 { color: #f59e0b; font-weight: 800; }
.lb-rank.rank-2 { color: #a855f7; font-weight: 800; }
.lb-rank.rank-3 { color: #fb923c; font-weight: 800; }

.lb-name {
  font-weight: 700;
  font-size: 13.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-level {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}

.lb-xp {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--brand-primary);
  white-space: nowrap;
}

/* Recent Games List */
.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.history-row:last-child {
  border-bottom: none;
}

.history-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-status.won { background-color: var(--success-subtle); color: var(--success); }
.history-status.lost { background-color: var(--danger-subtle); color: var(--danger); }

.history-body {
  flex: 1;
  min-width: 0;
}

.history-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.history-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-exp {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.history-exp.plus { color: var(--success-text); }
.history-exp.minus { color: var(--danger-text); }
.history-exp.neutral { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Play View & Game Setup
   -------------------------------------------------------------------------- */
.setup-section {
  margin-bottom: 24px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Game Setup Wizard (Step 1: Mode -> Step 2: Details/Diff -> Sticky Launch)
   -------------------------------------------------------------------------- */
.play-wizard-page {
  max-width: 860px;
}

.wizard-step-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
  background-color: var(--brand-primary-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

/* Step 1: Mode Cards */
.wizard-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wizard-mode-card {
  position: relative;
  z-index: 1;
  background-color: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.wizard-mode-card:hover {
  border-color: var(--brand-primary);
  background-color: #fff6fa;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.wizard-mode-card.selected {
  border-color: var(--brand-primary);
  background-color: #fff4f9;
  box-shadow: 0 0 0 2px var(--brand-primary), var(--shadow-md);
}

.wizard-mode-icon-slot {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--brand-primary-subtle);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.wizard-mode-icon-slot svg {
  width: 22px;
  height: 22px;
}

.wizard-mode-card:hover .wizard-mode-icon-slot {
  transform: scale(1.08) rotate(-4deg);
  background: var(--brand-gradient);
  color: #ffffff;
}

.wizard-mode-body {
  flex: 1;
  min-width: 0;
}

.wizard-mode-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.wizard-mode-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16.5px;
  margin: 0;
  color: var(--text-primary);
}

.wizard-mode-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.35;
}

.wizard-mode-arrow {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.wizard-mode-arrow svg {
  width: 18px;
  height: 18px;
}

.wizard-mode-card:hover .wizard-mode-arrow {
  transform: translateX(4px);
  color: var(--brand-primary);
}

/* Step 2: Nav Bar & Difficulty Grid */
.wizard-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.btn-back-step {
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
}

.btn-back-step:hover {
  background-color: var(--brand-primary-subtle);
}

.rot-180 {
  transform: rotate(180deg);
}

.wizard-current-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 12.5px;
}

.wizard-subtitle {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  margin: 0 0 10px 0;
  color: var(--text-primary);
}

.wizard-diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.wizard-diff-card {
  position: relative;
  z-index: 1;
  background-color: var(--bg-surface, #ffffff);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.wizard-diff-card:hover {
  border-color: var(--diff-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.wizard-diff-card.selected {
  border-color: var(--diff-color);
  background-color: #ffffff;
  box-shadow: 0 0 0 2px var(--diff-color), var(--shadow-md);
}

.wizard-diff-card.locked {
  opacity: 0.70;
  background-color: #fafaf9;
  border-style: dashed;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

.wizard-diff-card.locked:hover {
  border-color: #cbd5e1;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.diff-locked-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: rgba(244, 63, 94, 0.10);
  color: var(--danger);
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 800;
  border: 1px solid rgba(244, 63, 94, 0.20);
}

.diff-locked-tag svg {
  width: 11px;
  height: 11px;
}

.diff-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.diff-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.diff-indicator-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.diff-card-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  margin: 0;
  color: var(--text-primary);
}

.diff-selected-badge {
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  background-color: var(--brand-primary);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.diff-card-exp-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.diff-exp-box {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.diff-exp-gamble {
  flex-wrap: wrap;
  row-gap: 0;
}

.diff-exp-gamble .diff-card-exp {
  color: #b45309;
  font-size: 14px;
}

.diff-card-exp {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  color: var(--text-primary);
}

.diff-exp-unit {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
}

.diff-exp-boosted {
  color: #059669 !important;
}

.diff-bonus-tag {
  background-color: rgba(16, 185, 129, 0.12);
  color: #059669;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

.diff-card-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
  margin: 0 0 8px 0;
  flex: 1;
}

.wizard-reward-note {
  max-width: 720px;
  margin-top: -4px;
  line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Mode Details Preview Modal
   -------------------------------------------------------------------------- */
.mode-preview-modal {
  max-width: 460px;
  padding: 24px 20px;
}

.mode-preview-header {
  text-align: center;
  margin-bottom: 16px;
}

.mode-preview-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.3);
}

.mode-preview-icon svg {
  width: 26px;
  height: 26px;
}

.mode-preview-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  margin: 0 0 4px 0;
  color: var(--text-primary);
}

.mode-preview-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.mode-preview-features {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.mode-feature-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: left;
}

.mode-feature-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mode-feature-icon-wrap.icon-emerald { background: rgba(16, 185, 129, 0.12); color: #059669; }
.mode-feature-icon-wrap.icon-amber { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.mode-feature-icon-wrap.icon-pink { background: rgba(236, 72, 153, 0.12); color: #db2777; }
.mode-feature-icon-wrap.icon-purple { background: rgba(168, 85, 247, 0.12); color: #9333ea; }
.mode-feature-icon-wrap.icon-rose { background: rgba(244, 63, 94, 0.12); color: #e11d48; }
.mode-feature-icon-wrap.icon-blue { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.mode-feature-icon-wrap.icon-indigo { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }

.mode-feature-icon-wrap svg {
  width: 16px;
  height: 16px;
}

.mode-feature-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-feature-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-feature-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

.mode-preview-actions {
  display: flex;
  gap: 8px;
}

.btn-choose-mode {
  flex: 1;
}

.diff-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.diff-meta-time {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Gamble Config Card */
.gamble-setup-card {
  background: linear-gradient(180deg, #fffdf5 0%, #ffffff 100%);
  border-color: #fde68a;
  margin-bottom: 16px;
  padding: 14px;
}

.gamble-payout-box {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.08);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.gamble-payout-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: #b45309;
}

.gamble-no-funds-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background-color: rgba(244, 63, 94, 0.08);
  border: 1px dashed rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.no-funds-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background-color: rgba(244, 63, 94, 0.15);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.no-funds-badge svg {
  width: 18px;
  height: 18px;
}

.no-funds-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.no-funds-text strong {
  display: block;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 2px;
}

.no-funds-text p {
  margin: 0;
  line-height: 1.35;
  color: var(--text-muted);
}

.stake-presets-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stake-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background-color: var(--bg-surface);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.stake-chip:hover:not(:disabled) {
  border-color: var(--warning);
  color: var(--warning-text);
}

.stake-chip.active {
  background-color: var(--warning);
  border-color: var(--warning);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* Launch Button & Sticky Bottom Bar */
.wizard-sticky-bar {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.btn-launch-game {
  min-width: 300px;
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.35);
}

/* --------------------------------------------------------------------------
   Game Gameplay View & Ergonomics
   -------------------------------------------------------------------------- */
.game-page {
  max-width: 960px;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
  background: #ffffff;
  border-color: var(--border-color);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.hud-connection-status[hidden] {
  display: none !important;
}

.offline-hud-label-short {
  display: none;
}

.hud-timer-wrap .timer {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.timer.warn { color: var(--warning); }
.timer.critical { color: var(--danger); animation: timer-blink 1s ease infinite; }

@keyframes timer-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-mistakes {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.hud-hints {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.mistake-label { color: var(--text-muted); }
.hint-label { color: var(--text-muted); }
.mistake-count {
  font-family: var(--font-display);
  background-color: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-weight: 800;
}
.mistake-count.has-mistakes {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

.hint-count {
  font-family: var(--font-display);
  background-color: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-weight: 800;
}
.hint-count.has-hints {
  background-color: var(--brand-primary-subtle);
  color: var(--brand-primary);
}
.hint-count.zero-reward {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

.mistake-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--success);
}
.mistake-dot.used { background-color: var(--danger); }

/* Game Layout Grid */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 500px) 24px 280px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0;
  justify-content: center;
  align-items: start;
}

.game-snap-play {
  display: contents;
}

.game-snap-play .game-hud {
  grid-column: 1 / -1;
  grid-row: 1;
}

.game-snap-play .game-board-area {
  grid-column: 2;
  grid-row: 2;
}

.game-snap-info {
  grid-column: 4;
  grid-row: 2;
  min-width: 0;
}

.game-board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.board-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Sudoku Board Grid */
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  background-color: var(--bg-surface);
  border: 3px solid var(--cell-border-box);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  user-select: none;
  touch-action: manipulation;
}

.sudoku-board.board-complete {
  box-shadow: 0 0 0 4px var(--success), var(--shadow-xl);
}

.board-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: none;
  border-right: 1px solid var(--cell-border-color);
  border-bottom: 1px solid var(--cell-border-color);
  cursor: pointer;
  transition: background-color 0.1s ease;
  padding: 0;
  touch-action: manipulation;
}

.board-cell:nth-child(9n) { border-right: none; }
.board-cell:nth-child(n + 73) { border-bottom: none; }

.board-cell.border-right-thick { border-right: 2.5px solid var(--cell-border-box); }
.board-cell.border-bottom-thick { border-bottom: 2.5px solid var(--cell-border-box); }

.board-cell.box-alt { background-color: var(--cell-bg-alt); }

.board-cell .cell-value {
  font-family: var(--font-display);
  font-size: clamp(18px, 5.5vw, 29px);
  font-weight: 700;
  color: var(--cell-text-input);
  line-height: 1;
}

.board-cell.cell-given .cell-value {
  color: var(--cell-text-given);
  font-weight: 800;
}

.board-cell.cell-peer {
  background-color: var(--cell-bg-peer);
}

.board-cell.cell-same-digit {
  background-color: var(--cell-bg-same) !important;
}

.board-cell.cell-selected {
  background-color: var(--cell-bg-selected) !important;
  box-shadow: inset 0 0 0 2.5px var(--brand-primary);
  z-index: 2;
}

.board-cell.cell-conflict {
  background-color: var(--danger-subtle) !important;
}

.board-cell.cell-conflict .cell-value {
  color: var(--danger) !important;
}

/* Animations */
.board-cell.cell-pop {
  animation: cell-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cell-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.board-cell.cell-rejected {
  animation: cell-shake 0.3s ease;
  background-color: var(--danger-subtle) !important;
}

.board-cell.cell-pending {
  cursor: wait;
  opacity: 0.65;
}

@keyframes cell-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Note Grid */
.note-grid {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.note-grid span {
  font-family: var(--font-sans);
  font-size: clamp(7.5px, 2vw, 11px);
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.note-grid span.note-highlight {
  color: var(--brand-primary);
  font-weight: 800;
  background-color: var(--brand-primary-subtle);
  border-radius: 2px;
}

/* Numpad */
.numpad-section {
  width: 100%;
  max-width: 480px;
}

.numpad-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 7px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.numpad-heading strong {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.numpad-heading span {
  text-align: right;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  width: 100%;
  max-width: 480px;
}

.numpad-btn {
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
  box-shadow: var(--shadow-sm);
  min-height: 48px;
  touch-action: manipulation;
}

.numpad-btn:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.numpad-btn:active {
  transform: scale(0.94);
  background-color: var(--brand-primary-subtle);
}

.numpad-btn.numpad-done {
  opacity: 0.28;
  pointer-events: none;
  background-color: var(--bg-subtle);
}

.numpad-digit {
  font-size: 21px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--brand-primary);
  line-height: 1;
}

.numpad-remain {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Game Tools Row */
.game-tools-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.tool-btn {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.tool-btn:hover {
  background-color: var(--brand-primary-subtle);
  border-color: var(--border-strong);
  color: var(--brand-primary);
}

.tool-btn:active {
  transform: scale(0.97);
}

.tool-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tool-btn.active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.35);
}

.tool-btn-danger:hover {
  background-color: var(--danger-subtle);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--danger);
}

/* Sidebar */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-card {
  padding: 18px;
}

.side-card-header {
  margin-bottom: 10px;
}

.side-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-reward-value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  color: var(--brand-primary);
}

.side-reward-value.is-zero { color: var(--danger); }
.side-reward-kicker {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 2px;
}
.side-reward-status {
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  margin: 3px 0 10px;
}
.side-reward-breakdown {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 0 2px;
  border-top: 1px solid var(--border-color);
}
.side-reward-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
}
.side-reward-row span { color: var(--text-muted); }
.side-reward-row strong { color: var(--text-primary); white-space: nowrap; }
.side-reward-row.positive strong { color: var(--success-text); }
.side-reward-row.negative strong { color: var(--danger); }

.side-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.side-rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-rule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}

.rule-label { color: var(--text-muted); font-weight: 600; }
.rule-val {
  flex: 0 0 auto;
  color: var(--text-primary);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.kbd-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kbd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

kbd {
  font-family: var(--font-mono);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Modals & Dialogs
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(61, 38, 57, 0.45);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 30px 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: modal-scale-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-scale-up {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.modal-icon svg {
  width: 30px;
  height: 30px;
}

.modal-icon-success { background-color: var(--success-subtle); color: var(--success); }
.modal-icon-warning { background-color: var(--warning-subtle); color: var(--warning); }
.modal-icon-danger { background-color: var(--danger-subtle); color: var(--danger); }

.mistake-warning-overlay {
  background-color: rgba(91, 25, 54, 0.62);
}

.mistake-warning-dialog {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(244, 63, 94, 0.45);
  box-shadow: 0 22px 60px rgba(127, 29, 60, 0.38), 0 0 0 6px rgba(244, 63, 94, 0.10);
}

.mistake-warning-dialog::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, #f97316, #f43f5e, #be123c);
}

.mistake-warning-dialog .modal-icon-warning {
  background: linear-gradient(145deg, #fff7ed, #ffe4e6);
  border: 2px solid rgba(244, 63, 94, 0.30);
  color: var(--danger-text);
  box-shadow: 0 0 0 8px rgba(244, 63, 94, 0.08), 0 8px 20px rgba(244, 63, 94, 0.22);
  animation: mistake-warning-pulse 1.35s ease-in-out infinite;
}

@keyframes mistake-warning-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.mistake-warning-label {
  color: var(--danger-text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  margin-bottom: 5px;
}

.mistake-warning-dialog .modal-title {
  color: var(--danger-text);
}

.mistake-warning-dialog .modal-desc {
  color: var(--text-secondary);
  font-weight: 650;
  max-width: 350px;
  margin-left: auto;
  margin-right: auto;
}

.mistake-warning-note {
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  margin: -6px auto 0;
  max-width: 350px;
}

.mistake-warning-dialog .modal-actions {
  margin-top: 20px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.modal-actions .btn {
  flex: 1;
}

/* Result Modal Specifics */
.result-dialog {
  position: relative;
  max-width: 650px;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  padding: 34px 26px 24px;
}

.result-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.result-close-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }

.result-title {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.result-title.win { color: var(--brand-primary); }
.result-title.lose { color: var(--danger); }

.result-meta-tags {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.result-exp-block {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.result-exp-kicker {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 3px;
}

.result-exp-value {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  color: var(--brand-primary);
  line-height: 1.1;
}

.result-exp-value.negative { color: var(--danger); }
.result-exp-value.zero { color: var(--text-secondary); }

.result-exp-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
}

.result-levelup-banner {
  background: var(--brand-gradient-soft);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.result-duel-banner {
  border-radius: var(--radius-md);
  padding: 12px;
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.result-duel-banner.won {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.result-duel-banner.lost {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.result-sub-text {
  font-size: 12.5px;
  color: var(--text-muted);
}

.result-breakdown {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-align: left;
  background: var(--bg-surface);
}
.result-breakdown-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.result-breakdown-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
}
.result-breakdown-header span { color: var(--text-muted); font-size: 10.5px; }
.result-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.result-metric {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
  min-width: 0;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.result-metric-label { color: var(--text-muted); font-size: 11px; line-height: 1.25; }
.result-metric-value {
  color: var(--text-primary);
  font-size: 11.5px;
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}
.result-metric.positive .result-metric-value { color: var(--success-text); }
.result-metric.negative .result-metric-value { color: var(--danger-text); }
.result-metric.final,
.result-metric.zero { border: 1px solid var(--border-strong); background: var(--brand-gradient-soft); }
.result-metric.final .result-metric-value { color: var(--brand-primary); font-size: 13px; }
.result-metric.zero .result-metric-value { color: var(--text-secondary); }

.result-reason-block,
.result-lost-stake,
.result-achievement-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  margin: 0 0 14px;
  border-radius: var(--radius-md);
  text-align: left;
}
.result-reason-block {
  color: var(--danger-text);
  background: var(--danger-subtle);
  border: 1px solid rgba(244, 63, 94, 0.2);
}
.result-reason-block > .ic,
.result-lost-stake > .ic { flex: 0 0 auto; }
.result-reason-block strong { display: block; font-size: 12px; }
.result-reason-block p { margin: 2px 0 0; color: var(--text-secondary); font-size: 12px; }
.result-lost-stake {
  color: var(--danger-text);
  background: var(--danger-subtle);
  border: 1px solid rgba(244, 63, 94, 0.2);
  font-size: 12.5px;
  font-weight: 800;
}
.result-achievement-block {
  display: block;
  color: var(--text-primary);
  background: var(--brand-gradient-soft);
  border: 1px solid var(--border-strong);
}
.result-achievement-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--brand-primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}
.result-achievement-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(236, 72, 153, 0.14);
}
.result-achievement-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--brand-primary);
}
.result-achievement-item strong { font-size: 12.5px; }
.result-achievement-item p { margin: 2px 0 0; color: var(--text-muted); font-size: 11.5px; }
.result-achievement-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}
.result-achievement-link:hover { text-decoration: underline; }
.result-replay-note {
  margin: -8px 0 10px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.result-close-action {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.result-close-action:hover { color: var(--brand-primary); }

/* --------------------------------------------------------------------------
   Duels Arena View
   -------------------------------------------------------------------------- */
.duel-create-card {
  margin-bottom: 20px;
  z-index: 2;
}

.duel-form-grid {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}

.form-group.flex-2 { flex: 2; min-width: 200px; }
.form-group.align-end { align-self: flex-end; flex: 0 0 auto; }

.form-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  border: 1.5px solid var(--border-color);
  background-color: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14.5px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s ease;
}

.form-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-subtle);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ec4899' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Pastel select — avoids the browser-native blue/black popup. */
.styled-select {
  position: relative;
  width: 100%;
}

.styled-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.styled-select-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.styled-select-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.styled-select-trigger:focus-visible,
.styled-select.is-open .styled-select-trigger {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-subtle);
}

.styled-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.styled-select-chevron {
  flex: 0 0 auto;
  color: var(--brand-primary);
  font-size: 19px;
  font-weight: 700;
  line-height: 0.7;
  transform: translateY(-2px);
  transition: transform 0.15s ease;
}

.styled-select.is-open .styled-select-chevron {
  transform: rotate(180deg) translateY(2px);
}

.styled-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 10;
  display: none;
  max-height: min(320px, calc(100vh - 180px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
}

.styled-select.is-open .styled-select-menu {
  display: grid;
  gap: 2px;
}

.styled-select-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.styled-select-option:hover,
.styled-select-option.is-selected {
  background: var(--brand-primary-subtle);
  color: var(--text-primary);
}

.styled-select-option.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.styled-select-option-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
}

.styled-select-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.styled-select-option-meta,
.styled-select-option-disabled {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.styled-select-check {
  flex: 0 0 auto;
  color: var(--brand-primary);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
}

.styled-select-option.is-selected .styled-select-check {
  opacity: 1;
}

.rival-lookup-card {
  margin-bottom: 20px;
}

.rival-search-bar {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin-bottom: 16px;
}

.rival-vs-card {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.rival-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rival-player-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.rival-player-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.rival-score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.vs-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35);
}

.vs-score {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.vs-draws {
  font-size: 11px;
  color: var(--text-muted);
}

.duels-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duel-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.duel-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 180px;
}

.duel-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.duel-item-opponent {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-primary);
}

.duel-item-tags {
  display: flex;
  gap: 6px;
  align-items: center;
}

.duel-item-time {
  font-size: 11.5px;
  color: var(--text-muted);
}

.duel-item-actions {
  display: flex;
  gap: 8px;
}

/* Persistent duel invitation / acceptance notice */
.duel-inbox-root {
  position: fixed;
  top: max(82px, calc(env(safe-area-inset-top) + 68px));
  right: 18px;
  z-index: 250;
  width: min(92vw, 390px);
  pointer-events: none;
}

.duel-inbox-card {
  pointer-events: auto;
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-left: 4px solid var(--duel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: duel-notice-in 0.22s ease-out;
}

.duel-inbox-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--duel-subtle);
  color: var(--duel-text);
}

.duel-inbox-body { min-width: 0; flex: 1; }
.duel-inbox-title { font-weight: 800; color: var(--text-primary); }
.duel-inbox-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}
.duel-inbox-meta, .duel-inbox-description {
  color: var(--text-muted);
  font-size: 12px;
}
.duel-inbox-description { margin-top: 8px; }
.duel-inbox-actions { display: flex; gap: 8px; margin-top: 12px; }

@keyframes duel-notice-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Direct-challenge profile confirmation */
.duel-profile-modal { max-width: 520px; }
.duel-profile-modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--duel-subtle);
  color: var(--duel-text);
}
.duel-profile-summary { text-align: center; }
.duel-profile-level { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.duel-profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 20px;
}
.duel-profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-muted);
  text-align: center;
  font-size: 11px;
}
.duel-profile-stat svg { color: var(--duel); }
.duel-profile-stat strong { color: var(--text-primary); font-size: 16px; }

/* Synchronized ready lobby */
.duel-lobby-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.duel-lobby-card {
  max-width: 860px;
  margin: 0 auto;
  padding: 26px;
}
.duel-lobby-topline { display: flex; gap: 8px; align-items: center; }
.duel-ready-players {
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  align-items: center;
  gap: 18px;
  margin: 32px 0 24px;
}
.duel-ready-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
}
.duel-ready-player.is-me .duel-ready-name { color: var(--brand-primary); }
.duel-ready-name { font-size: 16px; }
.duel-ready-stats { color: var(--text-muted); font-size: 12px; }
.duel-player-status { font-size: 12px; font-weight: 800; }
.duel-player-status.ready { color: var(--success-text); }
.duel-player-status.waiting { color: var(--warning-text); }
.duel-ready-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.duel-ready-count {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--duel-subtle);
  color: var(--duel-text);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
}
.duel-ready-count.complete { background: var(--success-subtle); color: var(--success-text); }
.duel-ready-label { color: var(--text-muted); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.duel-ready-line { width: 70px; border-top: 2px dashed var(--border-strong); margin-top: 3px; }
.duel-hidden-board-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px dashed rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-md);
  background: var(--duel-subtle);
  color: var(--duel-text);
}
.duel-hidden-board-notice > svg { flex: 0 0 auto; }
.duel-hidden-board-notice strong { color: var(--text-primary); }
.duel-hidden-board-notice p { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }
.duel-deadline-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--warning-text);
  font-size: 12px;
  font-weight: 700;
}
.duel-lobby-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.ready-waiting-badge { padding: 10px 14px; }
.duel-starting-card, .duel-lobby-error {
  max-width: 560px;
  margin: 50px auto;
  padding: 38px 24px;
  text-align: center;
}
.duel-starting-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--duel-subtle);
  color: var(--duel);
}
.duel-starting-card .text-muted, .duel-lobby-error .text-muted { margin-bottom: 20px; }

/* --------------------------------------------------------------------------
   Leaderboard View
   -------------------------------------------------------------------------- */
.tab-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background-color: var(--bg-surface);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.tab-btn.active {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.35);
}

.tab-icon {
  width: 15px;
  height: 15px;
}

.metric-header-short {
  display: none;
}

.metric-value-short {
  display: none;
}

/* Unified Ranked Table */
.leaderboard-table-card {
  padding: 0;
  overflow: hidden;
}

.data-table-ranked {
  width: 100%;
  table-layout: fixed;
}

.data-table-ranked th {
  background-color: var(--bg-subtle);
  padding: 12px 14px;
}

.data-table-ranked td {
  padding: 12px 14px;
}

.data-table-ranked .th-rank,
.data-table-ranked .td-rank {
  width: 52px;
  text-align: center;
  padding: 12px 4px 12px 12px;
}

.data-table-ranked .th-player,
.data-table-ranked .td-player {
  padding: 12px 8px;
  min-width: 0;
}

.data-table-ranked .th-level,
.data-table-ranked .td-level {
  width: 80px;
  text-align: center;
  padding: 12px 6px;
}

.data-table-ranked .th-metric,
.data-table-ranked .td-metric-cell {
  width: 110px;
  text-align: right;
  padding: 12px 10px;
}

.data-table-ranked .th-wins,
.data-table-ranked .td-wins {
  width: 90px;
  text-align: right;
  padding: 12px 14px 12px 6px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12.5px;
  line-height: 1;
}

.rank-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.rank-crown svg {
  display: block;
  width: 100%;
  height: 100%;
}

.rank-badge-gold {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  border: 1.5px solid #f59e0b;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.rank-badge-silver {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  color: #6b21a8;
  border: 1.5px solid #a855f7;
  box-shadow: 0 2px 6px rgba(168, 85, 247, 0.18);
}

.rank-badge-bronze {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  color: #c2410c;
  border: 1.5px solid #fb923c;
  box-shadow: 0 2px 6px rgba(251, 146, 60, 0.18);
}

.rank-badge-normal {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.tr-top-1 td {
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.25) 0%, transparent 60%);
}

.tr-top-2 td {
  background: linear-gradient(90deg, rgba(245, 243, 255, 0.25) 0%, transparent 60%);
}

.tr-top-3 td {
  background: linear-gradient(90deg, rgba(255, 247, 237, 0.25) 0%, transparent 60%);
}

.tr-placeholder td {
  background-color: rgba(255, 255, 255, 0.5);
  border-bottom: 1px dashed var(--border-color);
}

.avatar-placeholder {
  background-color: #fff0f6;
  color: var(--brand-primary);
  border: 1.5px dashed #f472b6;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-placeholder svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.placeholder-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
}

.placeholder-sub {
  font-size: 11px;
  color: var(--brand-primary);
  font-weight: 600;
}

.td-player-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.td-me-badge {
  margin-left: 8px;
  display: inline-flex;
}

.td-metric-cell {
  font-size: 14px;
  color: var(--brand-primary);
}

/* Table Component */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

.data-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: var(--bg-surface-hover);
}

.data-table tr.tr-me td {
  background-color: var(--brand-primary-subtle);
}

.th-rank, .td-rank { width: 56px; }
.td-player { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--text-primary); }
.leaderboard-player-link { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; margin: -6px -4px; padding: 6px 4px; border-radius: 10px; color: var(--text-primary); transition: background .15s ease, color .15s ease; }
.leaderboard-player-link:hover { background: var(--brand-primary-subtle); color: var(--brand-primary-hover); }
.leaderboard-player-link:focus-visible { background: var(--brand-primary-subtle); }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-display); }
.font-bold { font-weight: 800; }
.text-muted { color: var(--text-muted); }
.opacity-60 { opacity: 0.65; }
.italic { font-style: italic; }
.font-normal { font-weight: 500; }
.text-xs { font-size: 11.5px; }

/* --------------------------------------------------------------------------
   Profile View
   -------------------------------------------------------------------------- */
.profile-header-card {
  margin-bottom: 20px;
}

.profile-header-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.profile-info {
  flex: 1;
  min-width: 260px;
}

.profile-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.profile-username {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Public player profile -------------------------------------------------- */
.public-profile-page { max-width: 1180px; }
.public-profile-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.public-profile-page-header .page-title { display: flex; align-items: center; gap: 8px; }
.public-profile-back-link { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 8px; color: var(--brand-primary); font-size: 11px; font-weight: 800; }
.public-profile-back-link:hover { color: var(--brand-primary-hover); text-decoration: underline; }
.public-profile-back-link .ic svg { width: 15px; height: 15px; }
.public-profile-badge { white-space: nowrap; }
.public-profile-header-card { background: linear-gradient(135deg, #fff, #fff8fb 72%, #f7f2ff); }
.public-profile-header-card .profile-header-inner { align-items: center; }
.public-profile-header-actions { display: flex; flex: 0 0 auto; margin-left: auto; }
.public-profile-header-actions .btn { white-space: nowrap; }
.public-profile-chips { margin-top: 10px; }
.public-profile-stats-card { margin-top: 20px; }
.public-profile-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.public-profile-detail-grid > .card { min-width: 0; margin-top: 0; }
.public-profile-detail-card .card-header,
.public-profile-recent-card .card-header { align-items: flex-start; }
.public-profile-recent-card { margin-top: 20px; }
.public-profile-history-row { min-width: 0; }
.public-profile-showcase-empty { min-height: 82px; }
.public-profile-error { max-width: 560px; margin: 48px auto; padding: 38px 24px; text-align: center; }
.public-profile-error .empty-icon { margin: 0 auto 14px; }
.public-profile-error h1 { margin-bottom: 8px; font-family: var(--font-display); font-size: 23px; }
.public-profile-error p { max-width: 420px; margin: 0 auto; line-height: 1.55; }
.public-profile-error-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 22px; }

/* Mastery Grid */
.mastery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.mastery-item-card {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mastery-content {
  flex: 1;
  min-width: 0;
}

.mastery-top-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
  margin-bottom: 8px;
}

.mastery-top-line > .badge-diff {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.mastery-top-line > .mastery-counts,
.mastery-top-line > .mastery-lock-badge {
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
}

.mastery-top-line > .badge-warning {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  justify-self: end;
}

.mastery-lock-badge {
  white-space: nowrap;
}

.mastery-counts {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.mastery-bar-wrap {
  height: 6px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.mastery-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
}

/* Mode Stats Grid */
.mode-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.mode-stat-card {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mode-stat-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-stat-icon {
  color: var(--brand-primary);
  display: inline-flex;
}

.mode-stat-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text-primary);
}

.mode-stat-value {
  font-size: 21px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.mode-stat-unit {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.mode-stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Account Management Card */
.account-card {
  margin-top: 20px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.account-info-text {
  flex: 1;
  min-width: 240px;
}

.btn-logout-action {
  color: var(--danger-text);
  border-color: var(--border-color);
  background-color: var(--bg-surface);
}

.btn-logout-action:hover {
  background-color: var(--danger-subtle) !important;
  border-color: rgba(244, 63, 94, 0.4) !important;
  color: var(--danger) !important;
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Auth Split Layout
   -------------------------------------------------------------------------- */
.auth-split-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}

.auth-brand-side {
  background: linear-gradient(145deg, #ec4899 0%, #db2777 45%, #a855f7 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(32px, 6vw, 84px);
  position: relative;
  overflow: hidden;
}

.auth-mini-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2.5px;
  width: min(240px, 50%);
  aspect-ratio: 1;
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md);
  padding: 6px;
  backdrop-filter: blur(4px);
}

.auth-mini-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11.5px;
  color: #ffffff;
}

.auth-mini-cell.alt { background: rgba(255, 255, 255, 0.12); }
.auth-mini-cell.filled { background: #ffffff; color: var(--brand-primary); }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-petal {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 6px;
  background: #ffffff;
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-6deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-headline {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 12px;
}

.brand-lead {
  font-size: 14.5px;
  opacity: 0.9;
  line-height: 1.5;
  margin-bottom: 24px;
  max-width: 440px;
}

.brand-feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0.96;
}

.feature-icon {
  color: #fed7aa;
}

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background-color: var(--bg-page);
}

.auth-form-card {
  width: 100%;
  max-width: 390px;
  padding: 28px;
}

.auth-tab-switch {
  display: flex;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-sub-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  line-height: 1.4;
}

.form-error-alert {
  background-color: var(--danger-subtle);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--danger-text);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Toasts & Notifications
   -------------------------------------------------------------------------- */
#toasts {
  position: fixed;
  top: max(74px, calc(env(safe-area-inset-top) + 60px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 400px);
}

.toast {
  background-color: var(--text-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-full);
  padding: 9px 20px;
  box-shadow: var(--shadow-xl);
  animation: toast-in 0.25s ease, toast-out 0.25s ease 2.7s forwards;
  max-width: 100%;
  text-align: center;
}

.toast.error { background-color: var(--danger); }
.toast.success { background-color: var(--success); }

@media (max-width: 640px) {
  .duel-inbox-root {
    top: max(72px, calc(env(safe-area-inset-top) + 58px));
    right: 10px;
    width: calc(100vw - 20px);
  }

  .duel-profile-stats { grid-template-columns: 1fr; }
  .duel-ready-players { grid-template-columns: 1fr; gap: 14px; margin-top: 22px; }
  .duel-ready-center { order: 3; }
  .duel-ready-line { display: none; }
  .duel-lobby-card { padding: 18px 14px; }
  .duel-lobby-header { align-items: stretch; flex-direction: column; }
  .duel-lobby-header .btn { align-self: flex-start; }
  .duel-lobby-actions { flex-direction: column; }
  .duel-lobby-actions .btn, .duel-lobby-actions .badge { width: 100%; justify-content: center; }
}

@keyframes toast-in {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateY(-10px); opacity: 0; }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* --------------------------------------------------------------------------
   Empty State & Loading
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.empty-text {
  font-size: 13.5px;
  font-weight: 700;
}

.loading-block {
  text-align: center;
  padding: 44px 16px;
  color: var(--text-muted);
}

.loading-block p {
  font-size: 13.5px;
  font-weight: 700;
  margin-top: 12px;
  font-family: var(--font-display);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  padding: 24px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--brand-primary);
}

.footer-tagline {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.footer-links {
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--brand-primary);
}

/* ==========================================================================
   Comprehensive Mobile & Tablet Responsive Media Queries (Refined Scale)
   ========================================================================== */

/* Tablets & Mobile Navigation Switch (<= 960px) */
@media (max-width: 960px) {
  html, body {
    font-size: 13.5px;
  }

  /* Navigation switch: hide top nav links, activate mobile bottom bar */
  .main-nav {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: block !important;
    padding: 3px 6px calc(4px + env(safe-area-inset-bottom)) 6px;
  }

  .bottom-nav-item {
    flex: 1 1 0;
    padding: 3px 6px;
    font-size: 10px;
    min-width: 0;
    gap: 1px;
    overflow: hidden;
    white-space: nowrap;
  }

  .bottom-nav-inner {
    min-width: 0;
  }

  .bottom-nav-icon {
    width: 19px;
    height: 19px;
  }

  .bottom-nav-icon svg {
    width: 17px;
    height: 17px;
  }

  .site-header {
    height: 52px;
  }

  .header-inner {
    height: 52px;
    padding: 0 14px;
    justify-content: space-between;
  }

  .site-logo {
    font-size: 16.5px;
    gap: 7px;
  }

  .logo-petal {
    width: 28px;
    height: 28px;
  }

  .logo-petal svg {
    width: 15px;
    height: 15px;
  }

  .user-pill-name {
    display: none;
  }

  .user-pill {
    padding: 2px 7px 2px 3px;
    gap: 5px;
    margin-left: auto;
  }

  .avatar-xs {
    width: 22px;
    height: 22px;
    font-size: 10.5px;
  }

  .badge-level-pill {
    font-size: 10px;
    padding: 1px 6px;
  }

  /* Adjust page padding for fixed bottom bar */
  .container {
    padding: 0 14px;
  }

  .page {
    padding-top: 14px;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .game-page {
    padding-top: 10px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 14px 13px;
    border-radius: var(--radius-md);
  }

  .card + .card {
    margin-top: 14px;
  }

  .card-header {
    margin-bottom: 12px;
  }

  .card-title {
    font-size: 15px;
  }

  .page-header {
    margin-bottom: 16px;
  }

  .page-title {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .page-desc {
    font-size: 12.5px;
  }

  /* Layout grid stacking */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .dash-col-main, .dash-col-side {
    gap: 14px;
  }

  .auth-split-layout {
    grid-template-columns: 1fr;
  }

  .auth-brand-side {
    display: none;
  }

  /* Hero Card */
  .hero-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 14px;
    text-align: center;
    gap: 14px;
    margin-bottom: 14px;
  }

  .hero-profile {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    min-width: unset;
  }

  .hero-greeting {
    font-size: 11px;
  }

  .hero-username {
    font-size: 21px;
    margin: 1px 0 6px;
  }

  .hero-chips {
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
  }

  .hero-actions {
    width: 100%;
    gap: 8px;
  }

  .hero-actions .btn {
    flex: 1;
    padding: 9px 14px;
    font-size: 13px;
  }

  .ring-wrap.level-ring-wrap {
    width: 80px !important;
    height: 80px !important;
  }

  .level-ring-wrap .ring-svg {
    width: 80px;
    height: 80px;
  }

  .level-ring-wrap .ring-value {
    font-size: 24px;
  }

  .level-ring-wrap .ring-caption {
    font-size: 8px;
  }

  /* Metrics in 2 columns with delicate sizing */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .metric-card {
    padding: 10px 9px;
    gap: 4px;
    border-radius: var(--radius-sm);
  }

  .metric-icon {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-xs);
  }

  .metric-icon svg {
    width: 14px;
    height: 14px;
  }

  .metric-value {
    font-size: 17px;
  }

  .metric-label {
    font-size: 11px;
  }

  .metric-sub {
    font-size: 10px;
    margin-top: -2px;
  }

  /* Heatmap */
  .heatmap {
    grid-template-rows: repeat(7, 10px);
    grid-auto-columns: 10px;
    gap: 2.5px;
  }

  .hm-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
  }

  .hm-legend {
    margin-top: 8px;
    gap: 3px;
  }

  .hm-legend-label {
    font-size: 9.5px;
  }

  /* Play Wizard on Mobile — Premium 2-column Grid System (Modes & Difficulties) */
  .play-wizard-page {
    padding-top: 6px !important;
    padding-bottom: calc(95px + env(safe-area-inset-bottom)) !important;
  }

  .wizard-step-tag {
    font-size: 9.5px;
    padding: 2px 7px;
    margin-bottom: 2px;
  }

  .page-header.text-center-mobile {
    margin-bottom: 8px;
  }

  .page-header.text-center-mobile .page-title {
    font-size: 16px;
    margin: 2px 0;
  }

  .page-header.text-center-mobile .page-desc {
    display: none;
  }

  .wizard-nav-bar {
    margin-bottom: 6px;
  }

  .btn-back-step {
    font-size: 11.5px;
    padding: 4px 8px;
  }

  .wizard-current-mode-pill {
    padding: 2px 8px;
    font-size: 11px;
  }

  /* Step 1: Mode Cards in a 2-column Grid on Mobile */
  .wizard-mode-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, auto) !important;
    gap: 8px !important;
  }

  .wizard-mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 10px 11px !important;
    min-height: 96px !important;
    gap: 4px !important;
    border-radius: var(--radius-md) !important;
    min-width: 0 !important;
  }

  .wizard-mode-icon-slot {
    width: 28px !important;
    height: 28px !important;
    border-radius: var(--radius-sm) !important;
  }

  .wizard-mode-icon-slot svg {
    width: 15px !important;
    height: 15px !important;
  }

  .wizard-mode-body {
    width: 100% !important;
    min-width: 0 !important;
  }

  .wizard-mode-top {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
    margin-bottom: 2px !important;
  }

  .wizard-mode-title {
    font-size: 13.5px !important;
    font-weight: 800 !important;
  }

  .wizard-mode-badges .badge {
    font-size: 9.5px !important;
    padding: 1px 4px !important;
  }

  .wizard-mode-desc {
    font-size: 10.5px !important;
    line-height: 1.25 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  .wizard-mode-arrow {
    display: none !important;
  }

  /* Step 2: 8 Difficulty Cards in 2x4 Grid on Mobile */
  .wizard-diff-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(4, auto) !important;
    gap: 8px !important;
  }

  .wizard-diff-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 10px 12px !important;
    border-radius: var(--radius-md) !important;
    min-height: 96px !important;
    min-width: 0 !important;
  }

  .diff-card-top {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 2px !important;
    gap: 4px !important;
  }

  .diff-title-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
  }

  .diff-indicator-dot {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
  }

  .diff-card-name {
    font-size: 14px !important;
    font-weight: 800 !important;
  }

  .diff-selected-badge {
    width: 16px !important;
    height: 16px !important;
    font-size: 10px !important;
  }

  .diff-card-exp-row {
    margin: 3px 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .diff-exp-box {
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 3px !important;
  }

  .diff-card-exp {
    font-size: 18px !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
  }

  .diff-exp-unit {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: var(--text-muted) !important;
  }

  .diff-bonus-tag {
    font-size: 9px !important;
    padding: 1px 4px !important;
  }

  .diff-locked-tag {
    font-size: 10px !important;
    padding: 2px 6px !important;
    font-weight: 800 !important;
  }

  .diff-card-desc {
    display: none !important;
  }

  .diff-card-meta {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    font-size: 10.5px !important;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    margin-top: 2px !important;
  }

  .diff-meta-time {
    font-weight: 700 !important;
    color: var(--text-secondary) !important;
  }

  .wizard-sticky-bar {
    position: fixed;
    bottom: calc(48px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    z-index: 55;
    padding: 6px 14px;
    background: rgba(255, 245, 248, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(252, 231, 243, 0.95);
    box-shadow: 0 -4px 16px rgba(219, 39, 119, 0.08);
  }

  .wizard-sticky-inner {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
  }

  .btn-launch-game {
    width: 100%;
    min-width: unset;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 800;
    border-radius: var(--radius-full);
  }

  /* Game Board and HUD — Board remains large & prominent */
  .game-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100svh;
    min-height: 0;
    flex: 0 0 100svh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-snap-type: y proximity;
    scrollbar-width: none;
    padding-top: 10px;
    padding-bottom: 0;
  }

  .game-page::-webkit-scrollbar {
    display: none;
  }

  .game-layout {
    display: contents;
  }

  .game-snap-play,
  .game-snap-info {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .game-snap-play {
    display: flex;
    flex-direction: column;
    height: calc(100svh - 10px);
    min-height: calc(100svh - 10px);
    overflow: hidden;
  }

  .game-snap-info {
    display: block;
    min-height: calc(100svh - 10px);
    padding-top: 10px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .game-snap-play .game-hud,
  .game-snap-play .game-board-area,
  .game-snap-info .game-sidebar {
    grid-column: auto;
    grid-row: auto;
  }

  .game-layout {
    width: 100%;
  }

  .game-board-area,
  .board-container,
  .game-sidebar {
    width: 100%;
    min-width: 0;
  }

  .game-hud {
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
    margin-bottom: 10px;
    gap: 6px;
    border-radius: var(--radius-sm);
  }

  .game-page {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .hud-left,
  .hud-center,
  .hud-right {
    min-width: 0;
  }

  .hud-timer-wrap .timer {
    font-size: 20px;
  }

  .mistake-label {
    font-size: 11.5px;
  }

  .mistake-count {
    font-size: 11px;
    padding: 1px 5px;
  }

  .hint-label {
    font-size: 11.5px;
  }

  .hint-count {
    font-size: 11px;
    padding: 1px 5px;
  }

  .sudoku-board {
    width: 100%;
    max-width: 480px;
    flex-shrink: 1;
    border-width: 2.5px;
    border-radius: var(--radius-md);
  }

  .board-cell .cell-value {
    font-size: clamp(20px, 6vw, 28px);
  }

  .note-grid span {
    font-size: clamp(7.5px, 2.1vw, 11px);
  }

  .numpad-grid {
    width: 100%;
    max-width: 480px;
    gap: 4px;
  }

  .numpad-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
  }

  .numpad-heading span {
    text-align: left;
  }

  .numpad-btn {
    min-height: 48px;
    padding: 6px 0;
    border-radius: var(--radius-xs);
  }

  .numpad-digit {
    font-size: 20px;
  }

  .numpad-remain {
    font-size: 9px;
    margin-top: 1px;
  }

  .game-tools-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    max-width: 480px;
    gap: 6px;
  }

  .tool-btn {
    min-width: 0;
    padding: 9px 6px;
    font-size: 12.5px;
    min-height: 42px;
    border-radius: var(--radius-sm);
  }

  .game-sidebar {
    flex-direction: column;
    gap: 12px;
  }

  .game-sidebar .side-card {
    flex: 0 1 auto;
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .side-rule-row {
    align-items: flex-start;
  }

  .side-rule-row .rule-label,
  .side-rule-row .rule-val {
    min-width: 0;
  }

  .side-rule-row .rule-val {
    flex: 1 1 auto;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .side-card-title {
    font-size: 12px;
  }

  .side-reward-value {
    font-size: 15px;
  }

  .kbd-shortcuts-card {
    display: none;
  }

  /* Leaderboard */
  .leaderboard-table-card {
    overflow: hidden !important;
  }

  .table-responsive {
    overflow-x: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    width: 100% !important;
  }

  .table-responsive::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .tab-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    margin-bottom: 12px;
    gap: 5px;
    scrollbar-width: none;
  }

  .tab-group::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 11.5px;
  }

  .badge-nowrap {
    white-space: nowrap !important;
  }

  .data-table-ranked {
    width: 100% !important;
    table-layout: fixed !important;
  }

  .data-table-ranked th, .data-table-ranked td {
    padding: 9px 4px !important;
    font-size: 11.5px;
  }

  .data-table-ranked .th-rank, 
  .data-table-ranked .td-rank {
    width: 36px !important;
    padding-left: 6px !important;
    padding-right: 2px !important;
    text-align: center !important;
  }

  .rank-badge {
    width: 26px !important;
    height: 26px !important;
    font-size: 11px !important;
    border-radius: 6px !important;
  }

  .rank-crown {
    width: 15px !important;
    height: 15px !important;
  }

  .data-table-ranked .th-player, 
  .data-table-ranked .td-player {
    width: auto !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
    min-width: 0 !important;
  }

  .avatar-sm {
    width: 26px !important;
    height: 26px !important;
    font-size: 11px !important;
    flex-shrink: 0 !important;
  }

  .td-player {
    gap: 6px !important;
  }

  .td-player-info {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .td-username {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
  }

  .placeholder-title {
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  .placeholder-sub {
    font-size: 10px !important;
  }

  .data-table-ranked .th-level, 
  .data-table-ranked .td-level {
    width: 58px !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
    text-align: center !important;
  }

  .td-level {
    white-space: nowrap !important;
  }

  .td-level .badge {
    white-space: nowrap !important;
    font-size: 10px !important;
    padding: 2px 5px !important;
  }

  .td-me-badge {
    margin-left: 3px;
    padding: 1px 4px;
    font-size: 9px;
  }

  .data-table-ranked .th-metric, 
  .data-table-ranked .td-metric-cell {
    width: 74px !important;
    padding-left: 2px !important;
    padding-right: 8px !important;
    text-align: right !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
  }

  .data-table-ranked .th-metric {
    white-space: normal !important;
    line-height: 1.1 !important;
    overflow-wrap: anywhere;
  }

  .th-wins, .td-wins {
    display: none !important;
  }

  /* Duels */
  .duel-form-grid {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .duel-form-grid .form-group {
    min-width: 100%;
  }

  .duel-form-grid .btn {
    width: 100%;
    padding: 9px;
  }

  .form-input {
    padding: 8px 10px;
    font-size: 13px;
  }

  .rival-search-bar {
    flex-direction: column;
    gap: 8px;
  }

  .rival-search-bar .btn {
    width: 100%;
  }

  .rival-vs-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 10px;
  }

  .vs-badge {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .vs-score {
    font-size: 17px;
  }

  .duel-item-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .duel-item-opponent {
    font-size: 13px;
  }

  .duel-item-actions {
    width: 100%;
    gap: 6px;
  }

  .duel-item-actions .btn {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Profile */
  .profile-header-inner {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .profile-username {
    font-size: 20px;
  }

  .profile-user-row {
    justify-content: center;
    gap: 6px;
  }

  .mastery-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mastery-item-card {
    padding: 10px 8px;
    gap: 8px;
  }

  .mastery-counts {
    font-size: 10.5px;
  }

  .mode-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .mode-stat-card {
    padding: 9px 8px;
    gap: 2px;
  }

  .mode-stat-name {
    font-size: 12px;
  }

  .mode-stat-value {
    font-size: 16px;
  }

  .mode-stat-unit {
    font-size: 10.5px;
  }

  .mode-stat-sub {
    font-size: 10px;
  }

  .history-row {
    padding: 7px 0;
    gap: 8px;
  }

  .history-status {
    width: 24px;
    height: 24px;
  }

  .history-meta {
    font-size: 10.5px;
  }

  .history-exp {
    font-size: 11.5px;
  }

  .account-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .btn-logout-action {
    width: 100%;
    padding: 8px;
    font-size: 12.5px;
  }

  /* Modals */
  .modal-dialog {
    padding: 20px 14px;
    max-width: calc(100vw - 28px);
    border-radius: var(--radius-lg);
  }

  .result-dialog {
    padding: 28px 12px 18px;
  }

  .result-breakdown {
    padding: 11px;
  }

  .result-breakdown-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .result-metrics-grid {
    grid-template-columns: 1fr;
  }

  .modal-icon {
    width: 46px;
    height: 46px;
    margin-bottom: 10px;
  }

  .modal-icon svg {
    width: 22px;
    height: 22px;
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-desc {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .modal-actions {
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
  }

  .modal-actions .btn {
    width: 100%;
    padding: 9px;
  }

  .result-exp-value {
    font-size: 28px;
  }

  /* Footer on mobile */
  .site-footer {
    padding: 12px 0 calc(62px + env(safe-area-inset-bottom)) 0;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 4px;
  }

  .footer-logo {
    font-size: 13.5px;
  }

  .footer-tagline {
    font-size: 11px;
  }

  .footer-links {
    display: none !important;
  }
}

/* Small Smart Phones (<= 400px) */
@media (max-width: 400px) {
  .game-hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    row-gap: 4px;
  }

  .game-hud .hud-left {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
    gap: 4px;
  }

  .game-hud .hud-center {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .game-hud .hud-right {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-end;
    gap: 5px;
  }

  .game-hud .hud-left .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
  }

  .game-hud .hud-left .badge {
    gap: 3px;
    padding: 2px 6px;
    font-size: 10px;
  }

  .game-hud .offline-hud-label-long {
    display: none;
  }

  .game-hud .offline-hud-label-short {
    display: inline;
  }

  .game-hud .hud-left .badge-icon {
    width: 11px;
    height: 11px;
  }

  .game-hud .hud-left .diff-dot {
    width: 6px;
    height: 6px;
  }

  .game-hud .hud-timer-wrap .timer {
    font-size: 18px;
  }

  .game-hud .hud-right .mistake-label,
  .game-hud .hud-right .hint-label {
    font-size: 10px;
  }

  .game-hud .hud-right .mistake-count,
  .game-hud .hud-right .hint-count {
    font-size: 10px;
    padding: 1px 4px;
  }

  .difficulty-selector-grid {
    grid-template-columns: 1fr;
  }

  .mode-stats-grid {
    grid-template-columns: 1fr;
  }

  .hero-username {
    font-size: 19px;
  }

  .sudoku-board {
    width: 100%;
    max-width: 480px;
    flex-shrink: 1;
  }

  .board-cell .cell-value {
    font-size: clamp(18px, 5.8vw, 24px);
  }

  .numpad-grid {
    width: 100%;
    max-width: 100%;
    gap: 3px;
  }

  .game-tools-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .numpad-btn {
    min-height: 44px;
  }

  .numpad-digit {
    font-size: 18px;
  }

  .numpad-remain {
    font-size: 8.5px;
  }
}

/* Keep the complete play screen usable on short phone viewports. */
@media (max-width: 960px) and (max-height: 700px) {
  .game-snap-play .game-board-area {
    gap: 8px;
  }

  .game-snap-play .sudoku-board {
    width: min(100%, calc(100svh - 332px));
  }

  .game-snap-play .numpad-heading {
    margin-bottom: 4px;
    font-size: 9px;
  }

  .game-snap-play .numpad-heading strong {
    font-size: 9.5px;
  }

  .game-snap-play .numpad-btn {
    min-height: 40px;
    padding: 4px 0;
  }

  .game-snap-play .numpad-digit {
    font-size: 16px;
  }

  .game-snap-play .numpad-remain {
    font-size: 8px;
  }

  .game-snap-play .game-tools-row {
    gap: 4px;
  }

  .game-snap-play .tool-btn {
    min-height: 38px;
    padding: 6px 4px;
    gap: 4px;
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  .game-hud .badge-offline {
    width: 28px;
    padding-left: 6px;
    padding-right: 6px;
    justify-content: center;
    font-size: 0;
  }

  .game-hud .badge-offline .badge-icon {
    flex: 0 0 11px;
  }

  .game-hud .offline-hud-label-short {
    display: none;
  }

  .game-hud .hud-center {
    justify-content: flex-start;
    overflow: hidden;
  }

  .game-hud .hud-timer-wrap,
  .game-hud .hud-timer-wrap .timer {
    min-width: 0;
  }
}

/* ==========================================================================
   Pusheen Ambient Wallpaper Background Layer
   ========================================================================== */
.pusheen-bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  overflow: hidden;
  contain: layout paint;
  opacity: 0.20;
}

.pusheen-bg-layer.pusheen-bg-mounted {
  background-image:
    url("/img/pusheen/pusheen-bg.png"),
    radial-gradient(circle at 50% 0%, rgba(244, 114, 182, 0.08), transparent 58%);
  /* Keep each 1280x720 composition at 16:9; repeat the tile instead of
     stretching it across portrait viewports. */
  background-repeat: repeat, no-repeat;
  background-position: 0 0, center;
  background-size: min(100%, calc(100vh * 16 / 9)) auto, cover;
}

.pusheen-bg-layer.is-suspended {
  visibility: hidden;
}

@media (max-width: 1200px) {
  .pusheen-bg-layer {
    opacity: 0.17;
  }
}

@media (max-width: 960px) {
  body {
    background-attachment: scroll;
  }

  .pusheen-bg-layer.pusheen-bg-mounted {
    background-image:
      url("/img/pusheen/pusheen-bg-mobile.png"),
      radial-gradient(circle at 50% 0%, rgba(244, 114, 182, 0.08), transparent 58%);
  }

  .pusheen-bg-layer {
    opacity: 0.16;
  }
}
/* ==========================================================================
   Ambient Decorative Backdrop Art (Marin Characters in corner)
   ========================================================================== */
#app {
  position: relative;
  z-index: 1;
}

.ambient-backdrop {
  position: fixed;
  pointer-events: none;
  user-select: none;
  z-index: 2;
  transition: opacity 0.4s ease, transform 0.4s ease;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.ambient-art-img {
  display: block;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 14px 32px rgba(236, 72, 153, 0.16));
  animation: ambientFloat 7s ease-in-out infinite;
  transform-origin: bottom right;
}

/* Home view: Marin Peace anchored to the exact bottom-right corner */
.ambient-home {
  bottom: -6px;
  right: -2px;
  width: clamp(170px, 14vw, 230px);
  opacity: 0.90;
}

/* Play Wizard view: Marin Celebrate anchored to bottom right (full head, unclipped) */
.ambient-play {
  bottom: -6px;
  right: -2px;
  width: clamp(200px, 16vw, 260px);
  opacity: 0.92;
}

@keyframes ambientFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  50% {
    transform: translateY(3px) rotate(-1.5deg) scale(1.015);
  }
}

@media (max-width: 1200px) {
  .ambient-home {
    width: 150px;
    opacity: 0.55;
  }
  .ambient-play {
    width: 170px;
    opacity: 0.55;
  }
}

@media (max-width: 960px) {
  .ambient-backdrop {
    display: none !important;
  }
}

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

/* --------------------------------------------------------------------------
   Inbox, messaging and privacy settings
   -------------------------------------------------------------------------- */
.inbox-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.inbox-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.inbox-page-header .page-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.inbox-page-header .page-title .ic svg {
  width: 23px;
  height: 23px;
  color: var(--brand-primary);
}

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr);
  gap: 20px;
  align-items: start;
}

.inbox-notifications-card,
.inbox-messages-card {
  min-width: 0;
}

.inbox-notifications-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inbox-notification {
  display: flex;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.inbox-notification.is-unread {
  border-color: rgba(236, 72, 153, 0.32);
  background: linear-gradient(90deg, rgba(253, 242, 248, 0.92), var(--bg-surface));
}

.inbox-notification-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--brand-primary);
}

.inbox-notification-icon svg { width: 18px; height: 18px; }
.inbox-type-duel_invite,
.inbox-type-duel_accepted { color: var(--duel-text); background: var(--duel-subtle); }
.inbox-type-message,
.inbox-type-message_request,
.inbox-type-message_request_accepted { color: var(--brand-primary); background: var(--brand-primary-subtle); }
.inbox-type-unlock { color: var(--success); background: var(--success-subtle); }

.inbox-notification-body { min-width: 0; flex: 1; }
.inbox-notification-top { display: flex; justify-content: space-between; gap: 10px; }
.inbox-notification-type,
.inbox-notification-date { color: var(--text-muted); font-size: 11px; }
.inbox-notification-type { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.inbox-notification-title { margin: 4px 0 2px; font-size: 14px; color: var(--text-primary); }
.inbox-notification-text { margin: 0; color: var(--text-secondary); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-notification-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 10px; }
.inbox-request-preview { color: var(--text-muted); font-size: 12px; flex: 1 1 100%; }

.inbox-new-message {
  display: grid;
  gap: 8px;
  padding: 13px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.inbox-new-message-title,
.inbox-subtitle { color: var(--text-primary); font-size: 13px; font-weight: 800; }
.inbox-subtitle { margin: 16px 0 8px; }
.inbox-new-message .form-input,
.inbox-chat-input { font-size: 13px; }

.inbox-request-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-request-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.inbox-request-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.inbox-request-info strong { font-size: 13px; }
.inbox-request-info span { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-request-actions { display: flex; gap: 5px; }

.inbox-threads-list { display: flex; flex-direction: column; gap: 5px; }
.inbox-thread-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  color: inherit;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
}
.inbox-thread-row:hover,
.inbox-thread-row.active { border-color: var(--border-color); background: var(--bg-subtle); }
.inbox-thread-main { min-width: 0; flex: 1; }
.inbox-thread-name { color: var(--text-primary); font-size: 13px; font-weight: 800; }
.inbox-thread-preview { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-thread-unread { min-width: 19px; height: 19px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--brand-primary); color: #fff; font-size: 10px; font-weight: 800; }

.inbox-thread-empty {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}
.inbox-thread-empty svg { width: 32px; height: 32px; color: var(--brand-primary); }
.inbox-thread-panel { margin-top: 16px; border-top: 1px solid var(--border-color); padding-top: 14px; }
.inbox-thread-header { display: flex; align-items: center; gap: 9px; padding-bottom: 10px; }
.inbox-chat-messages { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 2px; }
.inbox-chat-message { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 82%; }
.inbox-chat-message.mine { align-self: flex-end; align-items: flex-end; }
.inbox-chat-bubble { padding: 8px 11px; border-radius: 14px 14px 14px 4px; background: var(--bg-subtle); color: var(--text-primary); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-chat-message.mine .inbox-chat-bubble { border-radius: 14px 14px 4px 14px; background: var(--brand-primary-subtle); color: var(--brand-primary); }
.inbox-chat-message time { color: var(--text-muted); font-size: 10px; }
.inbox-chat-compose { display: flex; align-items: flex-end; gap: 7px; margin-top: 9px; }
.inbox-chat-compose .inbox-chat-input { flex: 1; resize: vertical; }

.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 13px; }
.settings-field { display: flex; flex-direction: column; gap: 5px; }
.settings-help { color: var(--text-muted); font-size: 11px; line-height: 1.35; }
.settings-toggle { display: flex; align-items: flex-start; gap: 9px; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); cursor: pointer; }
.settings-toggle input { margin-top: 3px; accent-color: var(--brand-primary); }
.settings-toggle span { display: flex; flex-direction: column; gap: 3px; }
.settings-toggle small { color: var(--text-muted); font-size: 11px; line-height: 1.3; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 15px; }

@media (max-width: 960px) {
  .inbox-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .inbox-page-header { align-items: flex-start; flex-direction: column; }
  .inbox-page-header > .btn { width: 100%; }
  .inbox-notification-top { flex-direction: column; gap: 2px; }
  .inbox-request-row { align-items: flex-start; flex-wrap: wrap; }
  .inbox-request-info { flex-basis: calc(100% - 50px); }
  .inbox-request-actions { width: 100%; justify-content: flex-end; }
  .settings-grid { grid-template-columns: 1fr; }

  .inbox-chat-compose {
    flex-direction: column;
    align-items: stretch;
  }

  .inbox-chat-compose .inbox-chat-input,
  .inbox-chat-compose .btn {
    width: 100%;
    min-width: 0;
  }

  .inbox-chat-compose .btn {
    justify-content: center;
  }
}

/* Daily challenge ------------------------------------------------------- */
.daily-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  overflow: hidden;
  border-color: rgba(244, 114, 182, .38);
  background: linear-gradient(120deg, rgba(253, 242, 248, .98), rgba(255, 255, 255, .98) 58%, rgba(254, 249, 195, .72));
}
.daily-card::after {
  content: '';
  position: absolute;
  width: 150px;
  height: 150px;
  right: -55px;
  top: -70px;
  border-radius: 50%;
  background: rgba(244, 114, 182, .1);
}
.daily-card-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--brand-600, #db2777);
  background: rgba(244, 114, 182, .15);
}
.daily-card-icon svg { width: 30px; height: 30px; }
.daily-card-kicker { color: #be185d; font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.daily-card-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 3px 0 7px; }
.daily-card-title-row h2 { margin: 0; font-size: 1.35rem; }
.daily-card-content p { margin: 0; color: var(--text-muted, #64748b); }
.daily-card-result { color: var(--text, #334155) !important; font-weight: 700; }
.daily-card-reset { margin-top: 8px; color: #9d174d; font-size: .78rem; font-weight: 600; }
.daily-card-action { position: relative; z-index: 1; }

/* Achievements ---------------------------------------------------------- */
.achievements-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.achievement-tile { display: flex; gap: 12px; min-height: 128px; padding: 15px; border: 1px solid var(--border, #e2e8f0); border-radius: 16px; background: rgba(255,255,255,.72); }
.achievement-tile.locked { filter: grayscale(.85); opacity: .62; }
.achievement-tile.unlocked { border-color: rgba(244, 114, 182, .35); box-shadow: 0 7px 22px rgba(219, 39, 119, .07); }
.achievement-icon { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #be185d; background: #fce7f3; }
.achievement-content { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.achievement-content p { margin: 0; color: var(--text-muted, #64748b); font-size: .78rem; line-height: 1.4; }
.achievement-content small { margin-top: auto; color: #94a3b8; font-size: .68rem; }
.achievement-category { color: #db2777; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.achievements-page { max-width: 1180px; }
.achievements-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.achievements-page-header .page-title { display: flex; align-items: center; gap: 8px; }
.achievements-overview-card { background: linear-gradient(135deg, #fff, #fff8fb); }
.achievements-overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.achievement-stat { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 13px 15px; border: 1px solid rgba(244, 114, 182, .2); border-radius: 14px; background: rgba(255, 255, 255, .8); }
.achievement-stat-icon { grid-row: span 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: #be185d; background: #fce7f3; }
.achievement-stat strong { color: var(--text-primary); font-family: var(--font-display); font-size: 21px; line-height: 1.1; }
.achievement-stat span { color: var(--text-muted); font-size: 11px; font-weight: 700; }
.achievements-showcase-note { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; color: #9d174d; background: rgba(252, 231, 243, .62); font-size: 12px; font-weight: 700; }
.achievements-showcase-note > .ic { width: 16px; height: 16px; flex: 0 0 auto; }
.achievements-showcase-note .card-link { margin-left: auto; font-size: 12px; }
.achievements-showcase-note.is-locked { color: var(--text-muted); background: var(--bg-subtle); }
.achievements-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: -2px 0 18px; }
.achievements-filter-bar .tab-btn { padding: 7px 12px; font-size: 12px; }
.achievement-filter-count { opacity: .72; font-size: 10px; }
.achievement-card-topline { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 15px; }
.achievement-showcase-tag { display: inline-flex; align-items: center; gap: 3px; color: #b45309; font-size: 9px; font-weight: 800; white-space: nowrap; }
.achievement-showcase-tag .ic { width: 11px; height: 11px; }
.achievements-library-tile { min-height: 142px; }

/* Profile achievement showcase ------------------------------------------ */
.showcase-header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.showcase-header-actions .btn { white-space: nowrap; }
.showcase-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.showcase-item { min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 13px; border: 1px solid rgba(244, 114, 182, .28); border-radius: 15px; background: linear-gradient(145deg, #fff, #fff8fb); }
.showcase-item-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #be185d; background: #fce7f3; }
.showcase-item-icon svg { width: 19px; height: 19px; }
.showcase-item-content { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.showcase-item-content strong { overflow: hidden; color: var(--text-primary); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.showcase-item-content p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--text-muted); font-size: 10.5px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.showcase-locked, .showcase-empty { display: flex; align-items: center; gap: 13px; padding: 17px; border: 1px dashed var(--border-color); border-radius: 15px; color: var(--text-muted); background: var(--bg-subtle); }
.showcase-lock-icon, .showcase-empty-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; color: var(--brand-primary); background: var(--brand-primary-subtle); }
.showcase-locked strong, .showcase-empty strong { color: var(--text-primary); font-size: 13px; }
.showcase-locked p, .showcase-empty p { margin: 3px 0 9px; color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }

/* Public showcase in player preview ------------------------------------- */
.public-showcase { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-color); }
.public-showcase-title { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; color: var(--brand-primary); font-size: 12px; font-weight: 800; }
.public-showcase-title .ic { width: 14px; height: 14px; }
.public-showcase-list { display: flex; gap: 6px; flex-wrap: wrap; }
.public-showcase-item { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 8px; border: 1px solid rgba(244, 114, 182, .25); border-radius: 999px; color: #9d174d; background: #fff7fb; font-size: 10.5px; font-weight: 700; }
.public-showcase-item .ic { width: 13px; height: 13px; flex: 0 0 auto; }

/* Blocking -------------------------------------------------------------- */
.blocked-users-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border, #e2e8f0); }
.blocked-users-section h4 { margin: 0 0 10px; }
.blocked-users-list { display: grid; gap: 8px; }
.blocked-user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 12px; background: #f8fafc; }
.inbox-chat-blocked { margin-top: 12px; padding: 12px; border-radius: 12px; color: #9f1239; background: #fff1f2; font-size: .82rem; }
.inbox-thread-header > .btn, .inbox-thread-header > .badge { margin-left: auto; }

/* Developer panel ------------------------------------------------------- */
.developer-page { display: grid; gap: 20px; }
.developer-section { margin: 0; }
.developer-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.developer-form-grid input[hidden] { display: none; }
.developer-form-grid textarea { grid-column: 1 / -1; }
.developer-preview { margin-top: 16px; padding: 18px; min-height: 110px; border: 1px solid rgba(244, 114, 182, .3); border-radius: 15px; background: #fffafb; }
.developer-preview.empty { display: grid; place-items: center; color: #94a3b8; border-style: dashed; }
.developer-preview h3 { margin: 8px 0 5px; }
.developer-preview p { margin: 0 0 10px; white-space: pre-wrap; }
.developer-analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.developer-table-block { min-width: 0; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }
.developer-table-block-wide { width: 100%; }
.developer-subtitle { margin: 0 0 10px; font-size: 15px; color: var(--text-primary); }
.developer-compact-table { font-size: 13px; }
.developer-compact-table th, .developer-compact-table td { padding: 10px 12px; }
.developer-account-toolbar { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.developer-account-search { flex: 1 1 auto; min-width: 180px; }
.developer-account-list { min-width: 0; }
.developer-users-table { min-width: 680px; }
.developer-account-detail { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.developer-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.developer-detail-header h3 { margin-bottom: 3px; }
.developer-detail-metrics { margin-bottom: 14px; }
.developer-account-settings { margin: 0 0 18px; padding: 10px 12px; border-radius: 10px; color: var(--text-muted); background: var(--bg-subtle); font-size: 13px; }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger-text); }
.daily-weights-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.developer-future { border-style: dashed; }

@media (max-width: 980px) {
  .achievements-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .developer-analytics-grid { grid-template-columns: 1fr; }
  .daily-weights-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .daily-card { grid-template-columns: auto 1fr; margin-bottom: 14px; }
  .daily-card-action { grid-column: 1 / -1; }
  .daily-card-action .btn { width: 100%; justify-content: center; }
  .achievements-grid, .developer-form-grid, .daily-weights-grid { grid-template-columns: 1fr; }
  .developer-form-grid textarea { grid-column: auto; }
  .developer-account-toolbar { flex-wrap: wrap; }
  .developer-account-search { flex-basis: 100%; }
  .developer-account-toolbar .btn { flex: 1; justify-content: center; }
}

/* Header utility buttons ------------------------------------------------ */
.header-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-muted);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: .15s ease;
}
.header-icon-btn:hover,
.header-icon-btn.active { color: var(--brand-primary); border-color: var(--brand-primary); background: var(--brand-primary-subtle); }
.header-icon-btn .ic { display: grid; place-items: center; }
.header-icon-btn .ic svg { width: 18px; height: 18px; }
.header-icon-btn .inbox-unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 10px;
  color: #fff;
  background: var(--brand-primary);
  font-size: 9px;
  font-weight: 800;
}
.header-icon-btn .inbox-unread-badge[hidden] { display: none; }

/* Dedicated player chats ----------------------------------------------- */
.messages-page { max-width: 1440px; min-width: 0; }
.messages-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.messages-page-header .page-title { display: flex; align-items: center; gap: 8px; }
.messages-shell {
  min-width: 0;
  min-height: calc(100vh - 225px);
  height: min(780px, calc(100vh - 170px));
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-md);
}
.messages-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background: linear-gradient(180deg, #fffafd, #fff 32%);
}
.messages-search-wrap { position: relative; padding: 18px 16px 14px; border-bottom: 1px solid var(--border-color); }
.messages-search-wrap > .ic { position: absolute; left: 28px; top: 30px; color: var(--text-muted); pointer-events: none; }
.messages-search-wrap > .ic svg { width: 17px; height: 17px; }
.messages-search-input { height: 44px; padding-left: 39px; border-radius: 14px; background: #fff; }
.messages-sidebar-content,
.messages-search-results { flex: 1; min-height: 0; overflow-y: auto; padding: 13px 10px 18px; }
.messages-sidebar-section + .messages-sidebar-section { margin-top: 18px; }
.messages-sidebar-section h2,
.messages-search-caption { margin: 0 8px 8px; color: var(--text-muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.messages-person-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: .15s ease;
}
.messages-person-row:hover { background: var(--bg-subtle); }
.messages-person-row.active { border-color: rgba(244, 114, 182, .28); background: var(--brand-primary-subtle); }
.messages-person-row > .avatar { width: 40px; height: 40px; flex: 0 0 40px; }
.messages-person-row > .ic { margin-left: auto; color: #cbd5e1; }
.messages-person-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 2px; }
.messages-person-copy strong { color: var(--text-primary); font-size: 13px; }
.messages-person-copy small { overflow: hidden; color: var(--text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.messages-unread { min-width: 21px; height: 21px; display: grid; place-items: center; padding: 0 5px; border-radius: 11px; color: #fff; background: var(--brand-primary); font-size: 10px; font-weight: 800; }
.messages-request-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-primary-subtle); }
.messages-list-empty { margin: 20px 12px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.messages-conversation { min-width: 0; min-height: 0; background: linear-gradient(155deg, rgba(255,255,255,.98), rgba(255,247,250,.75)); }
.messages-conversation-inner { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.messages-conversation-header { min-height: 76px; display: flex; align-items: center; gap: 13px; padding: 14px 22px; border-bottom: 1px solid var(--border-color); background: rgba(255,255,255,.84); }
.messages-back-btn { display: none; }
.messages-conversation-identity { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 13px; padding: 4px 8px 4px 4px; margin: -4px 0 -4px -4px; border-radius: 15px; transition: background .15s ease, color .15s ease; }
.messages-conversation-identity:hover,
.messages-conversation-identity:focus-visible { background: var(--brand-primary-subtle); }
.messages-conversation-header .avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.messages-conversation-person { min-width: 0; }
.messages-conversation-person h2 { overflow: hidden; margin: 0; color: var(--text-primary); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.messages-conversation-person span { display: block; overflow: hidden; color: var(--text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.messages-profile-hint { transition: color .15s ease; }
.messages-conversation-identity:hover .messages-profile-hint,
.messages-conversation-identity:focus-visible .messages-profile-hint { color: var(--brand-primary); }
.messages-profile-chevron { flex: 0 0 auto; color: var(--text-faint); transition: color .15s ease, transform .15s ease; }
.messages-profile-chevron svg { width: 15px; height: 15px; }
.messages-conversation-identity:hover .messages-profile-chevron,
.messages-conversation-identity:focus-visible .messages-profile-chevron { color: var(--brand-primary); transform: translateX(2px); }
.messages-conversation-actions { min-width: 0; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.messages-block-btn { margin-left: 0; }
.messages-history { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; padding: 28px clamp(22px, 4vw, 64px); scroll-behavior: smooth; }
.messages-history-empty,
.messages-empty-conversation { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--text-muted); text-align: center; }
.messages-history-empty .ic { color: #f9a8d4; }
.messages-history-empty p { margin-top: 9px; font-size: 12px; }
.messages-empty-conversation { padding: 40px; }
.messages-empty-conversation h2 { margin: 14px 0 6px; color: var(--text-primary); }
.messages-empty-conversation p { max-width: 390px; line-height: 1.6; }
.messages-empty-icon { width: 70px; height: 70px; display: grid; place-items: center; border-radius: 24px; color: var(--brand-primary); background: var(--brand-primary-subtle); }
.messages-empty-icon svg { width: 34px; height: 34px; }
.messages-bubble-row { max-width: min(72%, 650px); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.messages-bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.messages-bubble { padding: 11px 15px; border-radius: 18px 18px 18px 5px; color: var(--text-primary); background: #f1f5f9; font-size: 14px; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.messages-bubble-row.mine .messages-bubble { border-radius: 18px 18px 5px 18px; color: #9d174d; background: #fce7f3; }
.messages-bubble-row time { color: #94a3b8; font-size: 9px; }
.messages-compose { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 16px 22px 26px; border-top: 1px solid var(--border-color); background: rgba(255,255,255,.9); }
.messages-compose-input { min-height: 60px; max-height: 150px; resize: vertical; border-radius: 16px; padding: 12px 15px; font-size: 14px; }
.messages-send-btn { min-width: 112px; align-self: stretch; justify-content: center; border-radius: 16px; }
.messages-send-label { display: inline; }
.messages-compose small { grid-column: 1 / -1; margin-left: 4px; color: var(--text-muted); font-size: 9px; }
.messages-status-bar,
.messages-request-actions-large { min-height: 92px; display: flex; align-items: center; gap: 13px; padding: 18px 24px; border-top: 1px solid rgba(251, 113, 133, .2); color: #9f1239; background: #fff1f2; }
.messages-status-bar > .ic { flex: 0 0 auto; }
.messages-status-bar p { flex: 1; margin: 0; font-size: 13px; font-weight: 650; line-height: 1.5; }
.messages-request-actions-large { justify-content: space-between; color: var(--text-primary); background: #fffbeb; border-color: #fde68a; }
.messages-request-actions-large strong { display: block; }
.messages-request-actions-large p { margin: 3px 0 0; color: var(--text-muted); font-size: 12px; }
.messages-request-actions-large > div:last-child { display: flex; gap: 8px; }

/* Settings page --------------------------------------------------------- */
.settings-page { max-width: 1050px; }
.settings-main-card + .settings-main-card { margin-top: 18px; }
.settings-panel-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; }
.settings-showcase-card .card-header { align-items: flex-start; }
.settings-showcase-picker { display: flex; flex-direction: column; gap: 14px; }
.settings-showcase-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.settings-showcase-intro strong { color: var(--text-primary); font-size: 13px; }
.settings-showcase-intro p { margin: 3px 0 0; color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }
.showcase-selection-count { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: #9d174d; background: var(--brand-primary-subtle); font-size: 10px; font-weight: 800; white-space: nowrap; }
.settings-showcase-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.settings-showcase-option { min-width: 0; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 8px; padding: 11px; border: 1px solid var(--border-color); border-radius: 13px; cursor: pointer; background: #fff; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.settings-showcase-option:hover { border-color: rgba(244, 114, 182, .5); background: #fffafd; }
.settings-showcase-option.is-selected { border-color: rgba(244, 114, 182, .58); background: #fff7fb; box-shadow: 0 4px 12px rgba(219, 39, 119, .07); }
.settings-showcase-option.is-disabled { cursor: not-allowed; opacity: .58; }
.settings-showcase-option > input { margin-top: 3px; accent-color: var(--brand-primary); }
.settings-showcase-option-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #be185d; background: #fce7f3; }
.settings-showcase-option-icon svg { width: 15px; height: 15px; }
.settings-showcase-option-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.settings-showcase-option-copy strong { overflow: hidden; color: var(--text-primary); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.settings-showcase-option-copy small { display: -webkit-box; overflow: hidden; color: var(--text-muted); font-size: 10px; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.settings-showcase-locked { display: flex; align-items: center; gap: 12px; padding: 15px; border: 1px dashed var(--border-color); border-radius: 15px; background: var(--bg-subtle); }
.settings-showcase-lock-icon { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; color: var(--text-muted); background: #e2e8f0; }
.settings-showcase-locked strong { color: var(--text-primary); font-size: 13px; }
.settings-showcase-locked p { margin: 3px 0 0; color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }
.settings-showcase-empty { min-height: 80px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1px dashed var(--border-color); border-radius: 14px; color: var(--text-muted); font-size: 11.5px; text-align: center; }
.settings-showcase-empty p { margin: 0; }
.settings-toggle-card { min-height: 112px; padding: 16px; border: 1px solid var(--border-color); border-radius: 16px; background: #fff; }
.settings-privacy-field { min-height: 112px; justify-content: center; padding: 16px; border-radius: 16px; background: var(--bg-subtle); }
.settings-blocked-list { display: grid; gap: 9px; }
.settings-blocked-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: 15px; background: #fff; }
.settings-blocked-user { display: flex; align-items: center; gap: 12px; }
.settings-blocked-user > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.settings-blocked-user small { color: var(--text-muted); font-size: 10px; }
.settings-empty-blocked { min-height: 140px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--text-muted); border: 1px dashed var(--border-color); border-radius: 16px; text-align: center; }
.settings-empty-blocked p { margin: 0; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Inbox notification drawer -------------------------------------------- */
body.inbox-open { overflow: hidden; }
.inbox-overlay[hidden] { display: none; }
.inbox-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; justify-content: flex-end; }
.inbox-overlay-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(44, 20, 33, .28); backdrop-filter: blur(2px); cursor: default; animation: inboxFade .18s ease-out; }
.inbox-drawer { position: relative; width: clamp(350px, 25vw, 470px); height: 100%; display: flex; flex-direction: column; overflow: hidden; background: #fffafd; box-shadow: -18px 0 60px rgba(80, 24, 52, .18); animation: inboxSlide .22s ease-out; }
.inbox-drawer-loading,
.inbox-drawer-error,
.inbox-drawer-empty { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 30px; color: var(--text-muted); text-align: center; }
.inbox-drawer-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--border-color); background: rgba(255,255,255,.92); }
.inbox-drawer-header h2 { margin: 1px 0 0; color: var(--text-primary); font-size: 24px; }
.inbox-drawer-kicker { color: var(--brand-primary); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.inbox-drawer-toolbar { min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 18px; border-bottom: 1px solid var(--border-color); color: var(--text-muted); font-size: 11px; }
.inbox-drawer-list { flex: 1; overflow-y: auto; padding: 12px; }
.inbox-drawer-item { display: flex; gap: 11px; padding: 13px 10px; border: 1px solid transparent; border-bottom-color: var(--border-color); border-radius: 14px; }
.inbox-drawer-item.unread { border-color: rgba(244, 114, 182, .22); background: rgba(253, 242, 248, .86); }
.inbox-drawer-item + .inbox-drawer-item { margin-top: 7px; }
.inbox-drawer-item-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 12px; color: var(--brand-primary); background: var(--brand-primary-subtle); }
.inbox-drawer-item-icon svg { width: 17px; height: 17px; }
.inbox-drawer-item-icon.type-duel_invite { color: var(--duel-text); background: var(--duel-subtle); }
.inbox-drawer-item-icon.type-achievement { color: #b45309; background: #fef3c7; }
.inbox-drawer-item-copy { min-width: 0; flex: 1; }
.inbox-drawer-item-meta { display: flex; justify-content: space-between; gap: 9px; color: var(--text-muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.inbox-drawer-item-copy h3 { margin: 4px 0 3px; color: var(--text-primary); font-size: 13px; }
.inbox-drawer-item-copy p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-drawer-item-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@keyframes inboxFade { from { opacity: 0; } }
@keyframes inboxSlide { from { transform: translateX(100%); } }

@media (max-width: 960px) {
  .header-icon-btn { width: 34px; height: 34px; }
  .messages-page { padding-left: 12px; padding-right: 12px; }
  .messages-shell { grid-template-columns: 285px minmax(0, 1fr); height: calc(100vh - 170px); }
  .settings-panel-grid { grid-template-columns: 1fr; }

  /* Keep every mobile route inside the layout viewport. Grid/flex children
     otherwise use their min-content width and can make the page pan sideways. */
  #app,
  .container,
  .page,
  .messages-page,
  .settings-page {
    min-width: 0;
    max-width: 100%;
  }

  .messages-page,
  .settings-page {
    overflow-x: clip;
  }

  .settings-panel-grid > *,
  .settings-field,
  .settings-toggle,
  .settings-showcase-locked > div:last-child,
  .settings-blocked-user,
  .settings-blocked-user > div:last-child {
    min-width: 0;
  }

  .settings-showcase-locked strong,
  .settings-showcase-locked p,
  .settings-blocked-user strong {
    overflow-wrap: anywhere;
  }

  /* Keep mobile browsers from zooming the page when a form control gets
     focus. Checkboxes/radios are excluded because they never trigger this. */
  input:not([type='checkbox']):not([type='radio']),
  select,
  textarea,
  .styled-select-trigger,
  .messages-search-input,
  .messages-compose-input,
  .inbox-new-message .form-input,
  .inbox-chat-input {
    font-size: 16px;
  }
}

@media (max-width: 700px) {
  .messages-page-header { align-items: flex-start; flex-direction: column; gap: 12px; }
  .messages-page-header > .btn { align-self: stretch; justify-content: center; }

  /* The directory is the first mobile screen. The conversation is a
     separate full-screen state, never a second panel below the directory. */
  .messages-page:not(.messages-page-chat-open) .messages-shell {
    height: auto;
    min-height: 0;
    display: block;
    overflow: visible;
    border-radius: 18px;
  }

  .messages-page:not(.messages-page-chat-open) .messages-sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 0;
  }

  .messages-page:not(.messages-page-chat-open) .messages-sidebar-content,
  .messages-page:not(.messages-page-chat-open) .messages-search-results {
    overflow: visible;
  }

  .messages-page:not(.messages-page-chat-open) .messages-conversation {
    display: none;
  }

  /* A selected user becomes the only visible surface on mobile. Using a
     dynamic viewport unit keeps the composer above the on-screen keyboard. */
  body.messages-chat-open {
    overflow: hidden;
    background: #fffafd;
  }

  body.messages-chat-open .site-header,
  body.messages-chat-open .mobile-bottom-nav,
  body.messages-chat-open .site-footer,
  body.messages-chat-open #pusheen-bg {
    display: none !important;
  }

  .messages-page.messages-page-chat-open {
    position: fixed;
    z-index: 80;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #fffafd;
  }

  .messages-page.messages-page-chat-open .messages-page-header,
  .messages-page.messages-page-chat-open .messages-sidebar {
    display: none;
  }

  .messages-page.messages-page-chat-open .messages-shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .messages-page.messages-page-chat-open .messages-conversation,
  .messages-page.messages-page-chat-open .messages-conversation-inner {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .messages-page.messages-page-chat-open .messages-conversation-header {
    min-height: calc(66px + env(safe-area-inset-top));
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: rgba(255, 255, 255, .96);
  }

  .messages-page.messages-page-chat-open .messages-back-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
  }

  .messages-page.messages-page-chat-open .messages-back-btn:hover,
  .messages-page.messages-page-chat-open .messages-back-btn:focus-visible {
    color: var(--brand-primary);
    background: var(--brand-primary-subtle);
  }

  .messages-page.messages-page-chat-open .messages-back-btn svg {
    width: 21px;
    height: 21px;
  }

  .messages-page.messages-page-chat-open .messages-conversation-identity {
    gap: 10px;
  }

  .messages-page.messages-page-chat-open .messages-conversation-header .avatar-lg {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  .messages-page.messages-page-chat-open .messages-conversation-person h2 {
    max-width: min(46vw, 220px);
    font-size: 14px;
  }

  .messages-page.messages-page-chat-open .messages-conversation-person span {
    font-size: 10px;
  }

  .messages-page.messages-page-chat-open .messages-conversation-actions {
    gap: 3px;
  }

  .messages-page.messages-page-chat-open .messages-block-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
  }

  .messages-page.messages-page-chat-open .messages-block-label,
  .messages-page.messages-page-chat-open .messages-send-label {
    display: none;
  }

  .messages-page.messages-page-chat-open .messages-history {
    min-height: 0;
    padding: 20px 14px;
  }

  .messages-page.messages-page-chat-open .messages-bubble-row {
    max-width: 86%;
  }

  .messages-page.messages-page-chat-open .messages-bubble {
    padding: 10px 13px;
    font-size: 13px;
  }

  .messages-page.messages-page-chat-open .messages-compose {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }

  .messages-page.messages-page-chat-open .messages-compose-input {
    min-height: 46px;
    max-height: 120px;
    resize: none;
    padding: 11px 13px;
    border-radius: 23px;
  }

  .messages-page.messages-page-chat-open .messages-send-btn {
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 50%;
  }

  .messages-page.messages-page-chat-open .messages-compose small {
    margin-left: 3px;
    font-size: 9px;
  }

  .messages-page.messages-page-chat-open .messages-status-bar,
  .messages-page.messages-page-chat-open .messages-request-actions-large {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .messages-page.messages-page-chat-open .messages-request-actions-large {
    align-items: stretch;
    flex-direction: column;
  }

  .messages-page.messages-page-chat-open .messages-request-actions-large > div:last-child {
    justify-content: flex-end;
  }
  .inbox-drawer { width: min(100%, 430px); }
}

@media (max-width: 440px) {
  .site-logo .logo-text { display: none; }
  .header-user-area { gap: 5px; }
  .user-pill .badge-level-pill { display: none; }
  .messages-conversation-header { padding: 12px; }
  .messages-block-btn { padding-left: 8px; padding-right: 8px; font-size: 0; gap: 0; }
  .messages-block-btn .ic { margin: 0; }
  .inbox-drawer { width: 100%; }
}

@media (max-width: 980px) {
  .showcase-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-showcase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .achievements-page-header { align-items: stretch; flex-direction: column; }
  .achievements-page-header > .btn { width: 100%; justify-content: center; }
  .achievements-overview-grid { grid-template-columns: 1fr; }
  .showcase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .showcase-header-actions { align-items: flex-start; flex-direction: column; gap: 5px; }
  .showcase-header-actions .btn { padding: 4px 8px; }
  .settings-showcase-grid { grid-template-columns: 1fr; }
  .settings-showcase-intro { align-items: flex-start; flex-direction: column; }
  .settings-showcase-locked, .showcase-locked, .showcase-empty { align-items: flex-start; }
}

@media (max-width: 700px) {
  .public-profile-page-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .public-profile-badge { align-self: flex-start; }
  .public-profile-header-card .profile-header-inner { align-items: stretch; }
  .public-profile-header-actions { width: 100%; margin-left: 0; }
  .public-profile-header-actions .btn { width: 100%; justify-content: center; }
  .public-profile-detail-grid { grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
  .public-profile-stats-card,
  .public-profile-recent-card { margin-top: 14px; }
}

/* Ranking gets a compact, touch-friendly layout on narrow screens. Keep all
   sort options visible so the player never has to hunt through a clipped row. */
@media (max-width: 640px) {
  .leaderboard-page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .leaderboard-page .page-header {
    margin-bottom: 12px;
  }

  .leaderboard-page .tab-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    padding-bottom: 0;
    margin-bottom: 14px;
  }

  .leaderboard-page .tab-btn {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    justify-content: center;
    gap: 4px;
    padding: 7px 6px;
    font-size: 11.5px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .leaderboard-page .tab-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
  }

  .leaderboard-page .leaderboard-table-card {
    padding: 7px 6px 6px;
    border-radius: 18px;
  }

  .leaderboard-page .data-table-ranked th,
  .leaderboard-page .data-table-ranked td {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  .leaderboard-page .data-table-ranked .metric-header-full {
    display: none;
  }

  .leaderboard-page .data-table-ranked .metric-header-short {
    display: inline;
  }

  .leaderboard-page .data-table-ranked .metric-value-full {
    display: none;
  }

  .leaderboard-page .data-table-ranked .metric-value-short {
    display: inline;
  }

  .leaderboard-page .data-table-ranked .th-metric {
    white-space: nowrap !important;
    overflow-wrap: normal;
  }
}

@media (max-width: 340px) {
  .leaderboard-page .tab-btn {
    padding-left: 4px;
    padding-right: 4px;
    font-size: 11px;
  }

  .leaderboard-page .data-table-ranked .th-rank,
  .leaderboard-page .data-table-ranked .td-rank {
    width: 34px !important;
  }

  .leaderboard-page .data-table-ranked .th-level,
  .leaderboard-page .data-table-ranked .td-level {
    width: 56px !important;
  }

  .leaderboard-page .data-table-ranked .th-metric,
  .leaderboard-page .data-table-ranked .td-metric-cell {
    width: 70px !important;
    padding-right: 6px !important;
  }
}

/* Keep gameplay and ranking usable at the actual mobile viewport, including
   the space occupied by the global header. */
@media (max-width: 960px) {
  .mobile-bottom-nav.mobile-nav-hidden {
    display: none !important;
  }

  .game-page {
    height: calc(100svh - 52px);
    flex-basis: calc(100svh - 52px);
  }

  .game-snap-play {
    height: calc(100% + 10px);
    min-height: calc(100% + 10px);
  }

  .game-snap-info {
    min-height: calc(100% + 10px);
  }

  .leaderboard-page {
    min-width: 0;
    overflow-x: clip;
  }

  .leaderboard-page .tab-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    padding-bottom: 0;
  }

  .leaderboard-page .tab-btn {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    justify-content: center;
    gap: 5px;
    padding: 7px 8px;
    font-size: 12px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .leaderboard-page .leaderboard-table-card {
    padding: 10px 8px 8px;
    border-radius: 18px;
  }

  .leaderboard-page .data-table-ranked {
    display: block;
    border-collapse: separate;
    border-spacing: 0;
  }

  .leaderboard-page .data-table-ranked thead,
  .leaderboard-page .data-table-ranked tbody {
    display: block;
    width: 100%;
  }

  .leaderboard-page .data-table-ranked thead {
    margin-bottom: 7px;
    border-radius: 12px;
    overflow: hidden;
  }

  .leaderboard-page .data-table-ranked thead tr,
  .leaderboard-page .data-table-ranked tbody tr {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 58px 74px;
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }

  .leaderboard-page .data-table-ranked tbody {
    display: grid;
    gap: 6px;
  }

  .leaderboard-page .data-table-ranked tbody tr {
    min-height: 46px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-surface);
  }

  .leaderboard-page .data-table-ranked th,
  .leaderboard-page .data-table-ranked td {
    display: flex;
    align-items: center;
    min-width: 0;
    width: auto !important;
    padding: 8px 4px !important;
  }

  .leaderboard-page .data-table-ranked th {
    min-height: 40px;
    font-size: 11px;
  }

  .leaderboard-page .data-table-ranked .th-rank,
  .leaderboard-page .data-table-ranked .td-rank {
    justify-content: center;
    text-align: center !important;
  }

  .leaderboard-page .data-table-ranked .th-player {
    justify-content: flex-start;
  }

  .leaderboard-page .data-table-ranked .td-player {
    justify-content: flex-start;
    gap: 7px !important;
  }

  .leaderboard-page .data-table-ranked .th-level,
  .leaderboard-page .data-table-ranked .td-level {
    justify-content: center;
    text-align: center !important;
  }

  .leaderboard-page .data-table-ranked .th-metric,
  .leaderboard-page .data-table-ranked .td-metric-cell {
    justify-content: flex-end;
    text-align: right !important;
  }

  .leaderboard-page .data-table-ranked tbody td {
    border-bottom: 0 !important;
  }

  .leaderboard-page .data-table-ranked .metric-header-full,
  .leaderboard-page .data-table-ranked .metric-value-full {
    display: none;
  }

  .leaderboard-page .data-table-ranked .metric-header-short,
  .leaderboard-page .data-table-ranked .metric-value-short {
    display: inline;
  }
}

@media (max-width: 340px) {
  .leaderboard-page .data-table-ranked thead tr,
  .leaderboard-page .data-table-ranked tbody tr {
    grid-template-columns: 34px minmax(0, 1fr) 56px 70px;
  }
}

@media (max-width: 480px) {
  .game-snap-play .game-tools-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .game-snap-play .tool-btn {
    min-height: 38px;
  }
}

/* --------------------------------------------------------------------------
   Offline entry points and local-game metadata
   -------------------------------------------------------------------------- */
.badge-offline {
  color: #17634d;
  background: #dff8ec;
  border-color: #b7ebd4;
}

.connectivity-status {
  white-space: nowrap;
}

.connectivity-online {
  color: #17634d;
  background: #ecfbf4;
  border-color: #c9efdc;
}

.connectivity-offline {
  color: #8a4b18;
  background: #fff1dc;
  border-color: #f5d39e;
}

.offline-startup-warning {
  max-width: 520px;
}

.offline-startup-warning .modal-desc + .modal-desc {
  margin-top: -8px;
}

.offline-site-header .main-nav {
  justify-content: center;
}

.offline-header-status {
  min-width: max-content;
}

.offline-page-header {
  align-items: center;
}

.offline-trust-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #17634d;
  background: #ecfbf4;
  border: 1px solid #c9efdc;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}

.offline-trust-label svg,
.offline-header-status svg,
.offline-side-label svg {
  width: 14px;
  height: 14px;
}

.offline-home-content {
  display: grid;
  gap: 22px;
}

/* The web build can be reached through a stale/direct offline link even when
   the local pack is disabled. Keep that fallback self-contained and centered. */
.offline-unavailable-page {
  min-height: calc(100dvh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.offline-unavailable-page .offline-page-header {
  display: none;
}

.offline-unavailable-page .offline-home-content {
  width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  gap: 0;
}

.offline-active-card,
.offline-start-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-color: #c9efdc;
}

.offline-card-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #17634d;
  background: #ecfbf4;
  border-radius: 15px;
}

.offline-card-icon svg {
  width: 24px;
  height: 24px;
}

.offline-card-copy .card-kicker,
.offline-card-copy .card-title {
  display: block;
}

.offline-card-copy .card-title {
  margin: 3px 0 8px;
}

.offline-session-meta,
.offline-history-item-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.offline-card-copy p {
  margin: 8px 0 0;
}

.offline-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.offline-unavailable-card {
  width: min(620px, 100%);
  max-width: 620px;
  margin: 0 auto;
  padding: 32px;
  text-align: center;
}

.offline-unavailable-card .offline-card-icon {
  margin: 0 auto 16px;
}

.offline-unavailable-card .card-title {
  margin: 0 0 8px;
}

.offline-unavailable-card p {
  margin: 0 auto 20px;
  max-width: 500px;
}

.offline-history-wrap {
  min-width: 0;
}

.offline-history-card {
  overflow: hidden;
}

.offline-history-list {
  display: grid;
}

.offline-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-top: 1px solid var(--border-subtle);
}

.offline-history-item-meta {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 11px;
}

.offline-history-item-side {
  display: grid;
  justify-items: end;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.offline-sync-state {
  color: #17634d;
  font-weight: 700;
}

.offline-history-loading,
.offline-history-error {
  padding: 28px 18px;
  text-align: center;
}

.offline-picker-section {
  margin-top: 24px;
}

.offline-picker-heading {
  margin: 0 0 12px;
  font-size: 15px;
}

.offline-mode-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.offline-mode-card,
.offline-diff-card {
  width: 100%;
  border: 1px solid var(--border-color);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.offline-mode-card {
  display: flex;
  align-items: center;
}

.offline-mode-card .wizard-mode-body {
  min-width: 0;
}

.offline-mode-rule {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 11px;
}

.offline-diff-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.offline-diff-card {
  min-height: 116px;
}

.offline-diff-card .diff-card-desc {
  margin-bottom: 0;
}

.offline-rules-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
  padding: 16px 18px;
  color: var(--text-secondary);
}

.offline-rules-note > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--brand-primary);
}

.offline-rules-note strong {
  color: var(--text-primary);
  font-size: 13px;
}

.offline-rules-note p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.offline-launch-bar {
  display: flex;
  justify-content: center;
  padding: 24px 0 10px;
}

.offline-game-sidebar .offline-side-card {
  border-color: #c9efdc;
}

.offline-side-label {
  color: #17634d;
  font-size: 13px;
  font-weight: 800;
}

.offline-side-sync {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 11px;
}

.offline-result-no-exp .result-exp-value {
  font-size: 20px;
}

.offline-result-dialog .result-breakdown {
  margin-top: 4px;
}

@media (max-width: 760px) {
  .offline-active-card,
  .offline-start-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .offline-card-actions,
  .offline-start-card > .btn {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .offline-diff-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .offline-history-item {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .offline-site-header .main-nav {
    display: none;
  }

  .offline-header-status .badge {
    font-size: 10px;
  }

  .offline-mode-grid {
    grid-template-columns: 1fr;
  }

  .offline-history-item {
    display: grid;
    gap: 8px;
  }

  .offline-history-item-side {
    justify-items: start;
  }
}

.update-notice-host:empty {
  display: none;
}

.update-notice {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 14px;
  padding: 14px 18px;
}

.update-notice-copy {
  display: grid;
  gap: 3px;
}

.update-notice-copy span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .update-notice {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ========================================================================
   KILLER SUDOKU / Chimera V2
   ======================================================================== */
.killer-page {
  --killer-ink: #4a2451;
  --killer-pink: #ec4899;
  --killer-lilac: #8b5cf6;
  --killer-soft: #fff2fb;
}

.badge-diff.diff-killer { color: #7e3f9b; }
.badge-mode.mode-chimera_v2 { color: #7e3f9b; }

.killer-state-layout {
  display: grid;
  gap: 20px;
  max-width: 1080px;
  margin: 0 auto;
}

.killer-state-card,
.killer-rules-card,
.killer-home-offer-card {
  overflow: hidden;
  position: relative;
}

.killer-state-card::before,
.killer-home-offer-card::before,
.killer-offer-dialog::before {
  background: var(--brand-gradient-soft);
  border-radius: 50%;
  content: '';
  height: 280px;
  opacity: .62;
  pointer-events: none;
  position: absolute;
  right: -100px;
  top: -150px;
  width: 280px;
}

.killer-card-eyebrow {
  color: var(--killer-pink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  position: relative;
  text-transform: uppercase;
}

.killer-card-heading {
  align-items: center;
  display: flex;
  gap: 18px;
  position: relative;
}

.killer-card-heading h1,
.killer-state-card h1 {
  color: var(--killer-ink);
  font-family: 'Quicksand', sans-serif;
  font-size: clamp(25px, 4vw, 39px);
  margin: 5px 0 0;
}

.killer-card-subtitle {
  color: var(--text-muted);
  margin: 5px 0 0;
}

.killer-mark,
.killer-home-offer-mark {
  align-items: center;
  background: linear-gradient(145deg, #f9a8d4, #a78bfa);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(180, 96, 184, .24);
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 32px;
  height: 72px;
  justify-content: center;
  width: 72px;
}

.killer-lead {
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 24px 0 0;
  max-width: 720px;
  position: relative;
}

.killer-state-facts {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0;
  position: relative;
}

.killer-fact {
  background: var(--killer-soft);
  border: 1px solid #f7d8ef;
  border-radius: 14px;
  display: grid;
  gap: 2px;
  padding: 12px;
}

.killer-fact-icon { color: var(--killer-pink); font-size: 18px; }
.killer-fact-label { color: var(--text-muted); font-size: 11px; }
.killer-fact strong { color: var(--killer-ink); font-size: 13px; }

.killer-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
}

.killer-rules-card { padding-bottom: 24px; }
.killer-rules-intro { color: var(--text-secondary); line-height: 1.55; }
.killer-symbol-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0 18px; }
.killer-symbol-chip {
  align-items: center;
  background: var(--killer-soft);
  border: 1px solid #f2d5ed;
  border-radius: 10px;
  color: var(--killer-ink);
  display: inline-flex;
  font-size: 20px;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.killer-clue-list,
.killer-live-clue-list {
  color: var(--text-secondary);
  display: grid;
  gap: 9px;
  line-height: 1.45;
  margin: 0;
  padding-left: 22px;
}

.killer-home-offer-card {
  align-items: center;
  background: linear-gradient(120deg, #fff, #fff5fc);
  display: grid;
  gap: 16px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin-bottom: 20px;
  padding: 20px 22px;
}

.killer-home-offer-mark { border-radius: 16px; font-size: 24px; height: 54px; width: 54px; }
.killer-home-offer-copy { position: relative; }
.killer-home-offer-copy h2 { color: var(--killer-ink); font-family: 'Quicksand', sans-serif; margin: 3px 0; }
.killer-home-offer-copy p { color: var(--text-muted); font-size: 13px; margin: 0; }

.killer-offer-dialog,
.killer-decline-dialog { max-width: 500px; overflow: hidden; position: relative; }
.killer-offer-dialog > *, .killer-decline-dialog > * { position: relative; }
.modal-icon-killer {
  background: linear-gradient(145deg, #f9a8d4, #a78bfa);
  color: #fff;
  font-size: 30px;
}
.killer-modal-orbit { color: #c084fc; font-size: 14px; letter-spacing: .5em; margin-bottom: 4px; }
.killer-offer-title { color: var(--killer-ink); font-family: 'Quicksand', sans-serif; font-size: 34px; letter-spacing: .04em; }
.killer-offer-warning { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; color: #9a3412; font-size: 12px; line-height: 1.45; margin: 15px 0; padding: 11px 13px; }
.killer-offer-actions { justify-content: flex-end; }
.btn-killer { background: linear-gradient(135deg, #c084fc, #ec4899); border-color: transparent; color: #fff; }
.btn-killer:hover { background: linear-gradient(135deg, #a855f7, #db2777); color: #fff; }

.killer-game-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(290px, 390px); }
.killer-game-main, .killer-game-aside { min-width: 0; }
.killer-hud { align-items: center; display: flex; justify-content: space-between; margin-bottom: 14px; padding: 10px 14px; }
.killer-hud .hud-left, .killer-hud .hud-right { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.killer-hud .hud-center { flex: 0 0 auto; }
.killer-online-badge { color: var(--success-text); }
.killer-online-badge::first-letter { color: var(--success); }
.killer-board-card { padding: clamp(14px, 3vw, 26px); }
.killer-board-heading { align-items: flex-start; display: flex; justify-content: space-between; margin-bottom: 18px; }
.killer-board-heading h1 { color: var(--killer-ink); font-family: 'Quicksand', sans-serif; font-size: clamp(20px, 3vw, 28px); margin: 3px 0 0; }
.killer-save-status { color: var(--text-muted); font-size: 11px; margin: 5px 0 0 12px; text-align: right; white-space: nowrap; }
.killer-save-status.is-saved { color: var(--success-text); }
.killer-save-status.is-warning { color: var(--danger-text); }
.killer-board-help { color: var(--text-muted); font-size: 12px; line-height: 1.5; margin: 16px 0 0; text-align: center; }

.killer-board {
  aspect-ratio: 1;
  border: 2px solid #c9a4c9;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  margin: 0 auto;
  max-width: 620px;
  overflow: hidden;
}
.killer-cell {
  align-items: center;
  background: #fff;
  border: 0;
  border-bottom: 1px solid #f2ddeb;
  border-right: 1px solid #f2ddeb;
  color: var(--killer-ink);
  cursor: pointer;
  display: flex;
  font-family: 'Quicksand', sans-serif;
  font-size: clamp(18px, 4vw, 32px);
  font-weight: 700;
  justify-content: center;
  min-width: 0;
  padding: 0;
  transition: background .15s ease, color .15s ease;
}
.killer-cell:nth-child(3n) { border-right: 2px solid #d8b8d5; }
.killer-cell:nth-child(9n) { border-right: 0; }
.killer-cell:nth-child(n+19):nth-child(-n+27),
.killer-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid #d8b8d5; }
.killer-cell:nth-child(n+73) { border-bottom: 0; }
.killer-cell.is-given { background: #fff3fb; color: #8c4d88; cursor: default; }
.killer-cell.is-empty { color: #d8b8d5; }
.killer-cell:not(:disabled):hover, .killer-cell.is-selected { background: #fce7f3; }
.killer-cell.is-selected { box-shadow: inset 0 0 0 2px var(--killer-pink); }

.killer-palette-card { margin-top: 14px; padding: 16px; }
.killer-symbol-palette { display: grid; gap: 8px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.killer-palette-btn { align-items: center; background: var(--killer-soft); border: 1px solid #f2d5ed; border-radius: 11px; color: var(--killer-ink); cursor: pointer; display: flex; flex-direction: column; gap: 1px; justify-content: center; min-height: 58px; padding: 5px; }
.killer-palette-btn:hover { background: #fce7f3; border-color: #f9a8d4; }
.killer-palette-glyph { font-size: 22px; line-height: 1; }
.killer-palette-name { color: var(--text-muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.killer-palette-erase { background: #fff; color: var(--danger-text); }

.killer-game-aside { display: grid; align-content: start; gap: 14px; }
.killer-mapping-card, .killer-clues-card { padding: 16px; }
.killer-mapping-list { display: grid; gap: 9px; }
.killer-mapping-row { align-items: center; display: grid; gap: 5px; grid-template-columns: 28px 16px minmax(0, 1fr); }
.killer-mapping-symbol { color: var(--killer-ink); font-size: 23px; text-align: center; }
.killer-mapping-arrow { color: var(--text-faint); font-size: 12px; text-align: center; }
.killer-digit-options { display: grid; gap: 3px; grid-template-columns: repeat(10, minmax(20px, 1fr)); }
.killer-digit-btn, .killer-digit-clear { background: #fff; border: 1px solid #efddea; border-radius: 6px; color: var(--text-secondary); cursor: pointer; font-size: 11px; min-height: 25px; padding: 0; }
.killer-digit-btn:hover, .killer-digit-btn.is-selected { background: #fce7f3; border-color: var(--killer-pink); color: var(--killer-ink); font-weight: 800; }
.killer-digit-clear { color: var(--danger-text); }
.killer-digit-clear:not(.is-visible) { opacity: .45; }
.killer-live-clues-card { min-height: 100px; }
.killer-live-clue-list { list-style: none; padding-left: 0; }
.killer-live-clue { align-items: flex-start; display: flex; gap: 7px; }
.killer-clue-status { background: #f7eff7; border-radius: 50%; color: var(--text-faint); flex: 0 0 auto; font-size: 11px; height: 18px; line-height: 18px; text-align: center; width: 18px; }
.killer-live-clue.is-valid .killer-clue-status { background: var(--success-subtle); color: var(--success-text); }
.killer-live-clue.is-invalid .killer-clue-status { background: var(--danger-subtle); color: var(--danger-text); }
.killer-clues-hint, .killer-clues-success, .killer-clues-error { font-size: 11px; line-height: 1.45; margin: 13px 0 0; }
.killer-clues-hint { color: var(--text-muted); }
.killer-clues-success { color: var(--success-text); }
.killer-clues-error { color: var(--danger-text); }
.killer-terminal-summary { border-top: 1px solid var(--border-subtle); margin-top: 22px; padding-top: 22px; text-align: center; }
.killer-terminal-icon { align-items: center; border-radius: 50%; display: inline-flex; font-size: 28px; height: 58px; justify-content: center; width: 58px; }
.killer-terminal-icon.is-success { background: var(--success-subtle); color: var(--success-text); }
.killer-terminal-icon.is-failed { background: var(--danger-subtle); color: var(--danger-text); }
.killer-terminal-summary h2 { color: var(--killer-ink); font-family: 'Quicksand', sans-serif; margin: 12px 0 4px; }
.killer-terminal-summary p { margin: 0 auto; max-width: 480px; }
.killer-terminal-metrics { display: flex; gap: 22px; justify-content: center; margin-top: 17px; }
.killer-terminal-metrics span { color: var(--text-muted); font-size: 11px; }
.killer-terminal-metrics strong { color: var(--killer-ink); font-size: 13px; margin-left: 5px; }

@media (max-width: 900px) {
  .killer-game-layout { grid-template-columns: 1fr; }
  .killer-game-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .killer-state-facts { grid-template-columns: 1fr; }
  .killer-card-heading { align-items: flex-start; }
  .killer-card-heading h1 { font-size: 27px; }
  .killer-home-offer-card { align-items: flex-start; grid-template-columns: auto minmax(0, 1fr); }
  .killer-home-offer-card .btn { grid-column: 1 / -1; justify-self: start; }
  .killer-game-aside { grid-template-columns: 1fr; }
  .killer-hud { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .killer-hud .hud-center { order: 3; width: 100%; }
  .killer-hud .hud-center .timer { justify-content: center; }
  .killer-save-status { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: normal; }
}
