/**
 * PoGO Pal - Styles
 * Design System v4 - "Pokédex Companion" Light Theme
 */

/* ============================================
   DESIGN SYSTEM TOKENS
   ============================================ */
:root {
  /* Debug version for cache verification */
  --css-build: "v3.3.9";

  /* Background Hierarchy (light to dark for depth) */
  --bg-page: #F5F0E6;
  --bg-surface: #EDE8DC;
  --bg-surface-alt: #E5DFD0;
  --bg-inset: #DDD7C7;

  /* Legacy aliases (for compatibility during migration) */
  --bg-primary: var(--bg-page);
  --bg-secondary: var(--bg-surface);
  --bg-card: var(--bg-surface);

  /* Brand Colors */
  --color-primary: #DC0A2D;
  --color-primary-hover: #B8082A;
  --color-primary-active: #9A0623;
  --color-secondary: #3B7A8C;
  --color-secondary-hover: #2D5F6D;
  --color-secondary-active: #1F444E;

  /* Legacy alias */
  --accent: var(--color-primary);

  /* Text Colors */
  --text-primary: #2D3436;
  --text-secondary: #2D3436;
  --text-muted: #8B9396;
  --text-inverse: #FFFFFF;

  /* Border Colors */
  --border-default: #C4BBA8;
  --border-strong: #9A9282;
  --border-subtle: #D9D2C2;
  --border-color: var(--border-default);

  /* State Colors */
  --color-success: #4CAF50;
  --color-warning: #FF9800;
  --color-error: #F44336;
  --color-info: #2196F3;

  /* Shadows */
  --shadow-inset: inset 2px 2px 4px rgba(0,0,0,0.1);
  --shadow-panel: inset 1px 1px 0 rgba(255,255,255,0.5), 2px 2px 0 rgba(0,0,0,0.15);

  /* Pixel Bevel Tokens - Tactile Button System */
  --btn-bg: #E8E0D0;
  --btn-bg-hover: #F0EAE0;
  --btn-bg-active: #E0D8C8;
  --btn-border: #9A9282;
  --btn-hi: #F8F4EC;
  --btn-lo: #7A7262;
  --btn-hi-active: #6A6252;
  --btn-lo-active: #D0C8B8;
  --btn-shadow: 0 2px 0 #7A7262;
  --btn-inset: inset 1px 1px 0 #7A7262, inset -1px -1px 0 #F8F4EC;

  /* Tab Hover */
  --tab-hover-bg: rgba(0, 0, 0, 0.08);

  /* Typography */
  --font-display: "Press Start 2P", monospace;
  --font-body: "VT323", monospace;
  --font-pixel: "Press Start 2P", monospace;

  /* Font Sizes - Display */
  --text-display-lg: 16px;
  --text-display-md: 12px;
  --text-display-sm: 10px;
  --text-display-xs: 8px;

  /* Font Sizes - Type Pills */
  --text-pill: 16px;
  --text-pill-compact: 14px;

  /* Font Sizes - Body */
  --text-body-lg: 24px;
  --text-body-md: 20px;
  --text-body-sm: 18px;
  --text-body-xs: 16px;

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

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s ease;

  /* Layout constants */
  --appbar-h: 52px;
  --appbar-real-h: var(--appbar-h);
  --modebar-h: 44px;
  --modebar-real-h: 44px;
  --utilbar-h: 44px;
  --utilbar-real-h: var(--utilbar-h);
  --typebar-h: 48px;
  --collectionbar-h: 60px;
  --collectionbar-real-h: var(--collectionbar-h);
  --filterzone-real-h: 0px;
  --sticky-offset: 0px;
  --table-sticky-top: 0px;
  --sticky-stack-h: 0px;

  /* Type colors (Pokemon GO palette) */
  --t-normal: #A8A878;
  --t-fire: #F08030;
  --t-water: #6890F0;
  --t-electric: #F8D030;
  --t-grass: #78C850;
  --t-ice: #98D8D8;
  --t-fighting: #C03028;
  --t-poison: #A040A0;
  --t-ground: #E0C068;
  --t-flying: #A890F0;
  --t-psychic: #F85888;
  --t-bug: #A8B820;
  --t-rock: #B8A038;
  --t-ghost: #705898;
  --t-dragon: #7038F8;
  --t-dark: #705848;
  --t-steel: #B8B8D0;
  --t-fairy: #EE99AC;
}

/* ============================================
   DARK THEME
   ============================================ */
html[data-theme="dark"] {
  /* Background Hierarchy (dark to light for depth) */
  --bg-page: #1a1a2e;
  --bg-surface: #25253a;
  --bg-surface-alt: #2d2d45;
  --bg-inset: #16162a;

  /* Legacy aliases */
  --bg-primary: var(--bg-page);
  --bg-secondary: var(--bg-surface);
  --bg-card: var(--bg-surface);

  /* Text Colors */
  --text-primary: #e8e8ec;
  --text-secondary: #a8a8b8;
  --text-muted: #6a6a7a;
  --text-inverse: #1a1a2e;

  /* Border Colors */
  --border-default: #404058;
  --border-strong: #5a5a70;
  --border-subtle: #303045;
  --border-color: var(--border-default);

  /* Brand Colors (slightly muted for dark mode) */
  --color-primary: #e53e5a;
  --color-primary-hover: #f04e6a;
  --color-primary-active: #c0303f;
  --color-secondary: #4a9aac;
  --color-secondary-hover: #5aafbf;
  --color-secondary-active: #3a8090;

  /* Shadows */
  --shadow-inset: inset 2px 2px 4px rgba(0,0,0,0.3);
  --shadow-panel: inset 1px 1px 0 rgba(255,255,255,0.1), 2px 2px 0 rgba(0,0,0,0.3);

  /* Pixel Bevel Tokens - Dark Mode */
  --btn-bg: #35354a;
  --btn-bg-hover: #42425a;
  --btn-bg-active: #28283a;
  --btn-border: #505068;
  --btn-hi: #4a4a65;
  --btn-lo: #1a1a2a;
  --btn-hi-active: #151525;
  --btn-lo-active: #5a5a75;
  --btn-shadow: 0 2px 0 #1a1a2a;
  --btn-inset: inset 1px 1px 0 #1a1a2a, inset -1px -1px 0 #4a4a65;

  /* Tab Hover */
  --tab-hover-bg: rgba(255, 255, 255, 0.1);
}

/* Appbar dark mode overrides */
html[data-theme="dark"] .appbar {
  background-color: #25253a;
  border-top-color: #404058;
  border-bottom-color: #404058;
}

html[data-theme="dark"] .app-footer {
  border-bottom-color: #404058;
}

/* Scanline overlay - reduce opacity in dark mode */
html[data-theme="dark"] body::before {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.01) 2px,
    rgba(255,255,255,0.01) 4px
  );
}

/* Theme icon visibility */
.theme-icon { display: none; }
html:not([data-theme]) .theme-icon--system,
html[data-theme="system"] .theme-icon--system { display: block; }
html[data-theme="light"] .theme-icon--light { display: block; }
html[data-theme="dark"] .theme-icon--dark { display: block; }

/* System preference detection (when data-theme="system") */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    /* Background Hierarchy */
    --bg-page: #1a1a2e;
    --bg-surface: #25253a;
    --bg-surface-alt: #2d2d45;
    --bg-inset: #16162a;

    /* Legacy aliases */
    --bg-primary: var(--bg-page);
    --bg-secondary: var(--bg-surface);
    --bg-card: var(--bg-surface);

    /* Text Colors */
    --text-primary: #e8e8ec;
    --text-secondary: #a8a8b8;
    --text-muted: #6a6a7a;
    --text-inverse: #1a1a2e;

    /* Border Colors */
    --border-default: #404058;
    --border-strong: #5a5a70;
    --border-subtle: #303045;
    --border-color: var(--border-default);

    /* Brand Colors */
    --color-primary: #e53e5a;
    --color-primary-hover: #f04e6a;
    --color-primary-active: #c0303f;
    --color-secondary: #4a9aac;
    --color-secondary-hover: #5aafbf;
    --color-secondary-active: #3a8090;

    /* Shadows */
    --shadow-inset: inset 2px 2px 4px rgba(0,0,0,0.3);
    --shadow-panel: inset 1px 1px 0 rgba(255,255,255,0.1), 2px 2px 0 rgba(0,0,0,0.3);

    /* Pixel Bevel Tokens - Dark Mode */
    --btn-bg: #35354a;
    --btn-bg-hover: #42425a;
    --btn-bg-active: #28283a;
    --btn-border: #505068;
    --btn-hi: #4a4a65;
    --btn-lo: #1a1a2a;
    --btn-hi-active: #151525;
    --btn-lo-active: #5a5a75;
    --btn-shadow: 0 2px 0 #1a1a2a;
    --btn-inset: inset 1px 1px 0 #1a1a2a, inset -1px -1px 0 #4a4a65;

    /* Tab Hover */
    --tab-hover-bg: rgba(255, 255, 255, 0.1);
  }

  html[data-theme="system"] .appbar {
    background-color: #25253a;
    border-top-color: #404058;
    border-bottom-color: #404058;
  }

  html[data-theme="system"] .app-footer {
    border-bottom-color: #404058;
  }

  html[data-theme="system"] body::before {
    background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.01) 2px,
      rgba(255,255,255,0.01) 4px
    );
  }
}

/* Dark mode tactile elements now handled by --btn-* tokens in html[data-theme="dark"] */

/* System preference dark: Override tokens when OS is in dark mode */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    /* Background Hierarchy */
    --bg-page: #1a1a2e;
    --bg-surface: #25253a;
    --bg-surface-alt: #2d2d45;
    --bg-inset: #16162a;
    --bg-primary: var(--bg-page);
    --bg-secondary: var(--bg-surface);
    --bg-card: var(--bg-surface);

    /* Text Colors */
    --text-primary: #e8e8ec;
    --text-secondary: #a8a8b8;
    --text-muted: #6a6a7a;
    --text-inverse: #1a1a2e;

    /* Border Colors */
    --border-default: #404058;
    --border-strong: #5a5a70;
    --border-subtle: #303045;
    --border-color: var(--border-default);

    /* Brand Colors */
    --color-primary: #e53e5a;
    --color-primary-hover: #f04e6a;
    --color-primary-active: #c0303f;
    --color-secondary: #4a9aac;
    --color-secondary-hover: #5aafbf;
    --color-secondary-active: #3a8090;

    /* Shadows */
    --shadow-inset: inset 2px 2px 4px rgba(0,0,0,0.3);
    --shadow-panel: inset 1px 1px 0 rgba(255,255,255,0.1), 2px 2px 0 rgba(0,0,0,0.3);

    /* Pixel Bevel Tokens */
    --btn-bg: #35354a;
    --btn-bg-hover: #42425a;
    --btn-bg-active: #28283a;
    --btn-border: #505068;
    --btn-hi: #4a4a65;
    --btn-lo: #1a1a2a;
    --btn-hi-active: #151525;
    --btn-lo-active: #5a5a75;
    --btn-shadow: 0 2px 0 #1a1a2a;
    --btn-inset: inset 1px 1px 0 #1a1a2a, inset -1px -1px 0 #4a4a65;

    /* Tab Hover */
    --tab-hover-bg: rgba(255, 255, 255, 0.1);
  }

  html[data-theme="system"] .appbar {
    background-color: #25253a;
    border-top-color: #404058;
    border-bottom-color: #404058;
  }

  html[data-theme="system"] .app-footer {
    border-bottom-color: #404058;
  }

  html[data-theme="system"] body::before {
    background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.01) 2px,
      rgba(255,255,255,0.01) 4px
    );
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md);
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100%;
  line-height: 1.5;
  overflow: hidden;
}

/* Subtle scanline overlay for device feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.015) 2px,
    rgba(0,0,0,0.015) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

button { font-family: inherit; }

/* ============================================
   LAYOUT
   ============================================ */
.app {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* App bar - static flex item at top */
.appbar {
  flex: 0 0 auto;
  z-index: 9999;
  min-height: var(--appbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  padding-top: env(safe-area-inset-top, 0);
  background-color: #EDE8DC;
  border-top: 2px solid #5a544e;
  border-bottom: 2px solid #5a544e;
}

.appbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.appbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54vw;
}

/* ============================================
   COMPONENTS
   ============================================ */
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--btn-bg-hover);
    box-shadow: 0 3px 0 var(--btn-lo);
    transform: translateY(-1px);
  }
}

.icon-btn:active {
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
  transform: translateY(1px);
}

.icon-btn:active .icon {
  transform: translateY(1px);
}

.close-x {
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1;
}


.skin-mark {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.6px;
  opacity: 0.95;
  user-select: none;
}

/* Hidden file input */
.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   GBA/DS SKIN - Design System v4 Light Theme
   ============================================ */
html[data-skin="gba-ds"] {
  /* Typography aliases for legacy compatibility */
  --font-ui: var(--font-display);
  --font-size-label: var(--text-display-xs);
  --letter-spacing-label: 0.5px;
}

/* Title uses display font */
html[data-skin="gba-ds"] .title {
  font-family: var(--font-display);
  font-size: var(--text-display-md);
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-primary);
}

/* Version tag - small semantic version */
.version-tag {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--text-primary);
  position: relative;
  top: -2px;
}

/* Labels use display font */
html[data-skin="gba-ds"] .collection-note,
html[data-skin="gba-ds"] .sheet-title,
html[data-skin="gba-ds"] .panel-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Skin mark styling */
html[data-skin="gba-ds"] .skin-mark {
  font-family: var(--font-display);
}

/* ============================================
   APP WINDOW (Browser-style container)
   ============================================ */
.app-window {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.window-tabs {
  display: flex;
  background: var(--bg-inset);
  border-bottom: 2px solid var(--border-default);
  padding: 0;
}

/* Secondary tabs - nested level, connects to panel below */
.window-tabs-secondary {
  background: var(--bg-surface-alt);
  border: 2px solid var(--border-strong);
  border-bottom: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.window-tabs-secondary .window-tab {
  font-size: var(--text-display-xs);
  padding: var(--space-sm) var(--space-md);
}

.window-tabs-secondary .window-tab:first-child {
  border-top-left-radius: 8px;
  border-right: 2px solid var(--border-default);
}

.window-tabs-secondary .window-tab:last-child {
  border-top-right-radius: 8px;
}

.window-tabs-secondary .window-tab {
  border-bottom: 2px solid var(--border-default);
}

.window-tabs-secondary .window-tab.is-active {
  background: var(--bg-surface);
  border-bottom: 2px solid var(--bg-surface);
}

/* Sub-view container */
.vs-sub-view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.vs-sub-view[hidden] {
  display: none !important;
}

/* Coming soon placeholder content */
.coming-soon-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  gap: var(--space-md);
}

.window-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.window-tab:hover {
  background: var(--tab-hover-bg);
}

.window-tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-bottom: 2px solid var(--bg-surface);
  margin-bottom: -2px;
}

.window-content {
  position: relative;
  z-index: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 12px var(--space-md) 12px;
  overflow: hidden;
}

/* ============================================
   MODE BAR (Legacy - kept for reference)
   ============================================ */
.modebar {
  position: sticky;
  top: var(--appbar-real-h);
  z-index: 190;
  height: var(--modebar-h);
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  gap: var(--space-md);
  background: var(--bg-page);
}

.modebar-inner {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--bg-inset);
  box-shadow: var(--shadow-inset);
}

.mode-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  line-height: 1;
  height: 28px;
  padding: 0 var(--space-md);
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

.mode-tab:hover:not(.is-active) {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.mode-tab.is-active {
  background: var(--color-primary);
  color: var(--text-inverse);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.2), 1px 1px 0 rgba(0,0,0,0.2);
}

/* ============================================
   UTILITY ROW
   ============================================ */
.utility-row {
  position: sticky;
  top: calc(var(--appbar-real-h) + var(--modebar-real-h));
  z-index: 195;
  height: var(--utilbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  gap: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.utility-left { display: flex; align-items: center; gap: var(--space-md); }
.utility-right { display: flex; align-items: center; gap: var(--space-md); }

.util-btn {
  appearance: none;
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  height: 32px;
  padding: 0 var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  transition: all var(--transition-fast);
}

.util-btn:hover {
  background: var(--bg-surface-alt);
}

.util-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.util-icon .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.util-label {
  font-weight: inherit;
  letter-spacing: 0.5px;
}

/* Help button - now uses standard icon-btn styling */
/* .gbp-q class kept for backwards compatibility but no longer changes appearance */

/* ============================================
   COLLECTION BAR & FILTER ZONE
   ============================================ */
.collectionbar {
  min-height: var(--collectionbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-md);
  border-bottom: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
}

.collection-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.collection-stat {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: nowrap;
}

.collection-stat strong {
  color: var(--color-primary);
}

.collection-note {
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.filterzone {
  border-bottom: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
}

/* Active filters strip */
.active-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
}

.active-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.types-open-btn {
  touch-action: manipulation;
  z-index: 2;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  height: 32px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.types-open-btn:hover {
  background: var(--bg-surface-alt);
}

.types-open-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.types-open-icon {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  background: var(--color-primary);
  border: 1px solid var(--color-primary-hover);
  color: var(--text-inverse);
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}

.active-icons {
  z-index: 1;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  overflow: visible;
  padding: 2px 0;
}

.active-all {
  color: var(--text-secondary);
  font-size: 0.92rem;
  white-space: nowrap;
}

.icon-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.2);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.2);
  flex: 0 0 auto;
}

.icon-chip.is-selected {
  box-shadow: 0 0 0 2px var(--bg-page), 0 0 0 4px var(--text-primary);
}

.icon-chip svg {
  width: 16px;
  height: 16px;
  fill: var(--text-inverse);
  opacity: 0.95;
}

.icon-chip-btn {
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-chip-btn:hover {
  background: var(--bg-surface-alt);
}

.icon-chip-btn:active { transform: translateY(1px); }

.clear-btn {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  align-self: flex-start;
  -webkit-tap-highlight-color: transparent;
}

/* Only apply hover on devices with hover capability (not touch) */
@media (hover: hover) {
  .clear-btn:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
  }
}

/* Active (pressed) state - works on all devices */
.clear-btn:active {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

/* ============================================
   BOTTOM SHEET
   ============================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-bottom: none;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  max-height: 78vh;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.sheet-actions {
  display: inline-flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Sheet button - pixel bevel style */
.sheet-btn {
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  cursor: pointer;
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.sheet-btn:hover {
  background: var(--btn-bg-hover);
  box-shadow: 0 3px 0 var(--btn-lo);
  transform: translateY(-1px);
}

.sheet-btn:active {
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
  transform: translateY(1px);
}

.sheet-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

.sheet-btn.ghost:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.sheet-body {
  padding: var(--space-md);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
}

@media (min-width: 520px) {
  .type-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Universal type pill - used everywhere for type indicators */
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-pill);
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.type-pill .icon-chip {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.type-pill .type-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Smaller font for longer type names to prevent truncation */
.type-pill[data-type="Electric"] .type-name,
.type-pill[data-type="Fighting"] .type-name,
.type-pill[data-type="Psychic"] .type-name {
  font-size: var(--text-pill-compact);
}

/* Interactive pill states (buttons) */
button.type-pill {
  cursor: pointer;
  text-align: left;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) {
  button.type-pill:hover {
    background: var(--btn-bg-hover);
    box-shadow: 0 3px 0 var(--btn-lo);
    transform: translateY(-1px);
  }
}

button.type-pill:focus {
  outline: none;
}

button.type-pill:active:not(.is-selected) {
  background: var(--btn-bg-active);
  transform: translateY(1px);
}

.type-pill.is-selected {
  /* Pressed/inset effect - inverted bevel, sunk in */
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
  transform: translateY(1px);
}

/* Block-level pill variant - stretches to fill container */
.type-pill--block {
  width: 100%;
  justify-content: center;
}


.sheet-hint {
  margin-top: var(--space-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.showing-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin: var(--space-sm) 0 var(--space-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 18px;
}

.showing-row strong {
  color: var(--text-primary);
}

.hint {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
  margin: 0 0 var(--space-md);
}

/* ============================================
   PANELS
   ============================================ */
.panel {
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.panel-header {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
}

.panel-header .sub {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-family: var(--font-body);
  font-size: 20px;
}

th, td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

th {
  position: sticky;
  top: var(--table-sticky-top);
  z-index: 20;
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border-strong);
}

td {
  color: var(--text-primary);
}

tr:hover td {
  background: var(--bg-surface-alt);
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  background: var(--bg-inset);
}

th.sortable:active { transform: translateY(1px); }

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.sort-ind {
  font-size: 10px;
  color: var(--color-primary);
}

.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================================
   ERROR MODAL (reusable app-wide)
   ============================================ */
.error-modal .modal-card {
  border: 2px solid var(--color-error);
  background: #fff5f5;
}

.error-modal .modal-header {
  border-bottom-color: var(--color-error);
}

.error-modal .error-title {
  color: var(--color-error);
}

.error-modal .error-meta {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
}

.error-modal code {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-error);
  background: rgba(220, 10, 45, 0.1);
  padding: 1px 4px;
  border-radius: 2px;
}

/* Init error fallback */
.init-error {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.init-error[hidden] {
  display: none;
}

/* ============================================
   INFO DRAWER
   ============================================ */
body.no-scroll { overflow: hidden; }

/* Empty state scroll prevention disabled - was causing layout issues */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
}

.drawer-backdrop[hidden] {
  display: none !important;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(380px, 92vw);
  background: var(--bg-surface);
  /* Match app-window frame: same border weight and color */
  border-left: 2px solid #5a544e;
  box-shadow: -8px 0 24px rgba(0,0,0,0.18);
  transform: translateX(104%);
  transition: transform 180ms ease;
  padding-top: env(safe-area-inset-top, 0);
  z-index: 10001;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  position: sticky;
  top: 0;
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
}

/* Close button - pixel bevel style */
.drawer-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.drawer-close-btn:hover {
  background: var(--btn-bg-hover);
}

.drawer-close-btn:active {
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
  transform: translateY(1px);
}

.drawer-content {
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* Intro gloss - add subtle divider after */
.drawer-content > .gloss:first-child {
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-sm);
}

/* Accordion sections - pixel bevel style */
.drawer-content details {
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  border-radius: var(--radius-sm);
  margin: var(--space-sm) 0;
  overflow: hidden;
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

/* Expanded state - pressed/inset look */
.drawer-content details[open] {
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
}

.drawer-content summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

.drawer-content summary::-webkit-details-marker { display: none; }

/* +/- indicator styled as mini tactile element */
.drawer-content summary::after {
  content: '+';
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: normal;
  color: var(--text-primary);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
}

.drawer-content details[open] summary::after {
  content: '−';
  background: var(--bg-inset);
}

.drawer-content .gloss {
  margin-top: 0;
  padding: 0 var(--space-md) var(--space-md) var(--space-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  line-height: 1.35;
  font-size: 18px;
}

/* When details is open, add top padding to gloss */
.drawer-content details[open] .gloss {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-subtle);
}

.drawer-content code {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg-surface-alt);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Upload drawer panel */
.upload-panel {
  background: var(--bg-inset);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-top: var(--space-md);
}

.upload-panel-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 18px;
}

.upload-label {
  color: var(--text-secondary);
}

.upload-value {
  color: var(--text-primary);
  font-weight: bold;
}

.upload-coming-soon {
  margin-top: var(--space-xs);
  color: var(--text-muted);
  font-size: 16px;
  font-style: italic;
}

.upload-action {
  margin-top: var(--space-lg);
  display: flex;
  justify-content: center;
}

/* Upload CTA button - pixel bevel style */
.upload-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
  cursor: pointer;
  /* Pixel Bevel - flat bg with crisp edge highlights */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  border-radius: var(--radius-sm);
  box-shadow: var(--btn-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.upload-action-btn .icon {
  width: 18px;
  height: 18px;
}

.upload-action-btn:hover {
  background: var(--btn-bg-hover);
}

.upload-action-btn:active {
  background: var(--btn-bg-active);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
  transform: translateY(1px);
}

.upload-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-sm);
  color: var(--color-success);
  font-family: var(--font-body);
  font-size: 18px;
}

.upload-status[hidden] {
  display: none;
}

.upload-status-icon {
  font-size: 16px;
}

.grade-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xs) var(--space-sm);
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  font-size: 16px;
}

.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface-alt);
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--text-primary);
  min-width: 32px;
}

/* ============================================
   DEBUG PANEL
   ============================================ */
.debug-details {
  margin: var(--space-sm) var(--space-md) 0 var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-default);
  background: var(--bg-inset);
  overflow: hidden;
}

.debug-details > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--text-primary);
}

.debug-details > summary::-webkit-details-marker { display: none; }
.debug-details > summary .mono { color: var(--text-muted); font-size: 16px; }

.debug-body {
  padding: var(--space-sm) var(--space-md) var(--space-md) var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.debug-block + .debug-block { margin-top: var(--space-sm); }
.debug-label { font-family: var(--font-display); font-size: 8px; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-xs); }
.debug-chipwrap { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

.debug-chip {
  font-family: var(--font-body);
  font-size: 16px;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debug-mapping, .debug-sample {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

/* ============================================
   VS MODE
   ============================================ */

/* View containers - flex for full height */
#viewVersus {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vs-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vs-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  overflow: hidden;
}

/* Scrollable body region - always scrollable */
.vs-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Remove top padding and disable scroll when recommendations are visible (grid collapsed) */
.vs-panel-body.recs-visible {
  padding-top: 0;
  overflow: hidden;
}

/* Type grid section - hidden when collapsed */
.type-grid-section[hidden] {
  display: none;
}

.vs-panel-header {
  background: var(--bg-surface-alt);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-default);
}

.vs-panel-header .panel-subtitle {
  text-align: left;
}

.panel-section-header {
  background: var(--bg-surface-alt);
  margin: 0 calc(-1 * var(--space-md)) calc(-1 * var(--space-sm));
  padding: var(--space-sm) var(--space-md);
  border-top: 2px solid var(--border-default);
  border-bottom: 2px solid var(--border-default);
  text-align: center;
}

/* Tappable section header - clickable to collapse/expand */
.tappable-header {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, box-shadow 0.1s ease;
}

.tappable-header:hover {
  background: var(--bg-inset);
}

/* Pressed/expanded state - inset effect like selected type pills */
.collapsible-section:not(.collapsed) .tappable-header {
  background: var(--bg-inset);
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.15), inset 1px 1px 2px rgba(0,0,0,0.1);
}

/* Top arrows between opponent header and recommendations */
.vs-top-arrows {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  padding: 6px var(--space-md);
}

.vs-top-arrows[hidden] {
  display: none;
}

.vs-top-arrow-col {
  display: flex;
  justify-content: center;
  align-items: center;
}

.vs-top-arrow-col svg {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
  opacity: 0.95;
}

/* Collapsible sections - reusable pattern */
.collapsible-section {
  /* Container for header + content */
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.collapsible-header .panel-subtitle {
  flex: 1;
}

.collapsible-toggle {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.collapsible-toggle:hover {
  background: var(--bg-surface-alt);
}

.collapsible-toggle:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.collapsible-content {
  /* Content area - visible by default */
}

.collapsible-section.collapsed .collapsible-content {
  display: none;
}

.collapsible-placeholder {
  display: none;
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-muted);
  padding: var(--space-xs) 0;
  text-align: center;
  line-height: 1;
}

.collapsible-section.collapsed .collapsible-placeholder {
  display: block;
}

/* Show placeholder in coming soon sections */
.coming-soon-placeholder .collapsible-placeholder {
  display: block;
}

/* ============================================
   CAROUSEL - VS Tab Results Carousel
   ============================================ */

/* Carousel container - extends beyond parent padding */
#vsRecommendations {
  overflow: hidden;
  position: relative;
  margin: 0 calc(-1 * var(--space-md));
  width: calc(100% + 2 * var(--space-md));
}

/* Carousel track - holds all slides */
.carousel-track {
  display: flex;
  transition: transform 0.3s ease-out;
  will-change: transform;
  touch-action: pan-y;
}

/* Individual slides */
.carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
}

/* Carousel header - contains arrows and title */
.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-alt);
  padding: 6px 2px !important;
  min-height: 40px;
  border-bottom: 2px solid var(--border-default);
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Subsequent headers within same slide get top border */
.carousel-content + .carousel-header {
  border-top: 2px solid var(--border-default);
}

.carousel-header .panel-subtitle {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Carousel arrows */
.carousel-arrow {
  appearance: none;
  border: none;
  background: transparent;
  padding: var(--space-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

.carousel-arrow svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.carousel-arrow:hover {
  color: var(--text-primary);
}

.carousel-arrow:active {
  transform: scale(0.9);
}

/* Placeholder for missing arrow (first/last slide) */
.carousel-arrow-placeholder {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}

/* Carousel content */
.carousel-content {
  flex: 1;
  padding: 16px var(--space-sm);
  touch-action: pan-y;
}

/* Wider column gaps in carousel content */
.carousel-content .picks-list {
  gap: var(--space-md);
}

.carousel-content .type-columns {
  gap: var(--space-md);
}

/* Your Pokemon slide - add top padding to align with other slides that have arrow headers */
#vsYourPokeSection .carousel-content {
  padding-top: calc(18px + var(--space-xs));
}

/* Dot indicators */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding: 0 0 var(--space-md) 0;
}

.carousel-dot {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
}

.carousel-dot:hover {
  border-color: var(--border-strong);
}

.carousel-dot.is-active {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
}

/* ============================================
   STICKY HEADER - Direct child of scroll container
   ============================================ */

/* Sticky header - outside vs-panel for proper sticky behavior */
.vs-sticky-header {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-strong);
  border-bottom: 2px solid var(--border-default);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  margin-bottom: -2px;
  /* SOLID OPAQUE BACKGROUND - direct on element */
  background: #E5DFD0;
}

/* Mask layer: extra insurance for Safari paint */
.vs-sticky-mask {
  position: absolute;
  inset: -2px; /* Extend beyond padding to cover border area */
  background: #E5DFD0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
}

/* Ensure hidden attribute overrides display:flex */
.vs-sticky-header[hidden] {
  display: none !important;
}

.vs-sticky-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vs-sticky-header-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  height: 34px;
}

/* Sticky header pills - same sizing as opponent-header pills */
.vs-sticky-header-pills .type-pill {
  padding: 6px 10px;
  justify-content: center;
}

.vs-sticky-header-pills .type-pill .icon-chip {
  width: 16px;
  height: 16px;
}

/* When sticky header is shown, hide the top border-radius of vs-panel */
.vs-sticky-header:not([hidden]) + .vs-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ============================================
   OPPONENT HEADER - Fixed at top of vs-panel
   ============================================ */

/* Opponent header - pixel bevel style, always visible, never scrolls */
.opponent-header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 28px var(--space-sm);
  cursor: pointer;
  border-bottom: 2px solid var(--border-default);
  background: var(--bg-surface);
}

/* Top row: title + toggle button */
.opponent-header-top {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pills row - always visible (line 2 of header) */
.opponent-header-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  height: 34px;
}


/* Header pills - slightly larger padding, inherit base font-size */
.opponent-header-pills .type-pill {
  padding: 6px 10px;
  justify-content: center;
}

.opponent-header-pills .type-pill .icon-chip {
  width: 16px;
  height: 16px;
}

/* Instructions row inside collapsible content */
.opponent-instructions {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.vs-panel-title {
  font-family: var(--font-display);
  font-size: var(--text-display-sm);
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.panel-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
}

.info-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  flex-shrink: 0;
  margin-left: var(--space-xs);
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 8px;
  cursor: pointer;
  vertical-align: middle;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.info-icon-btn:hover {
  background: var(--color-secondary);
  color: var(--text-inverse);
  border-color: var(--color-secondary);
}

/* Modal styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: 101;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-default);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.modal-close-btn {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-md);
}

.modal-body .t {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.modal-body .t + .t {
  margin-top: var(--space-sm);
}

.vs-block {
  margin-top: var(--space-md);
}

.vs-block-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.vs-k {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Reusable action row for button groups - asymmetric spacing keeps buttons connected to content above */
.action-row {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}


.vs-hero {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
}

.picks-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

/* When picks-list uses column layout, type-columns grid takes precedence */
.picks-list.type-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vs-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
}

.vs-empty[hidden],
.vs-pick-prompt[hidden] {
  display: none;
}

.vs-empty-upload {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Arrow icon in empty state buttons */
.arrow-icon {
  font-size: 14px;
  line-height: 1;
}

.helper-text {
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.brief-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.brief-container[hidden] {
  display: none;
}

.brief-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.brief-label {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.brief-label strong {
  color: var(--text-primary);
}

.brief-v {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

/* Double flash error animation for validation */
.flash-error {
  animation: flash-error-2x 0.8s ease;
}

@keyframes flash-error-2x {
  0%, 100% { color: inherit; }
  12.5%, 37.5% { color: var(--color-error); }
  25%, 50% { color: inherit; }
  62.5%, 87.5% { color: var(--color-error); }
  75% { color: inherit; }
}

/* Flash error for type pills - subtle background pulse */
.type-pill.flash-error {
  animation: flash-pill-bg 0.6s ease;
}

@keyframes flash-pill-bg {
  0%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.5; }
  50% { opacity: 1; }
}

.battle-tiprow {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  position: relative;
}

.battle-tiprow .tip-label {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-muted);
}

.battle-tiprow .tip-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.battle-tiprow .tip-btn:hover {
  background: var(--color-secondary);
  color: var(--text-inverse);
  border-color: var(--color-secondary);
}

.battle-tooltip {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: var(--space-xs);
  width: min(320px, calc(100vw - 56px));
  border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  padding: var(--space-md);
  color: var(--text-primary);
  z-index: 10;
}

.battle-tooltip .t {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.battle-tooltip .t + .t { margin-top: var(--space-sm); }

/* ============================================
   FLIP CARD - Press to reveal interaction
   ============================================ */

/* Flip card wrapper - square cards */
.flip-card {
  cursor: pointer;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

/* Focus styles - no visible outline */
.flip-card:focus {
  outline: none;
}

/* Pressed state - lighter inset effect */
.flip-card.is-pressed {
  background: var(--bg-surface-alt);
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.08), inset 1px 1px 1px rgba(0,0,0,0.05);
  transform: translateY(1px);
}

/* Inner container */
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Both card faces - shared styles */
.flip-card-face {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-xs);
  overflow: hidden;
  height: 100%;
}

/* Front face - shown by default, content vertically centered (bumped up slightly) */
.flip-card-front {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 20px; /* bump content up */
}

/* Back face - hidden by default, content centered */
.flip-card-back {
  display: none;
  align-items: center;
  text-align: center;
  justify-content: center;
}

/* Pressed state: show back, hide front */
.flip-card.is-pressed .flip-card-front {
  display: none;
}

.flip-card.is-pressed .flip-card-back {
  display: flex;
}

/* ============================================
   FRONT FACE LAYOUT
   ============================================ */

/* CP positioned top-right absolutely */
.poke-cp {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1;
}

/* Center group: name + type pills centered as a unit */
.poke-center-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Line 2: Name (centered) */
.poke-name-line {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
  line-height: 1.1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poke-name-line.long-name {
  font-size: 13px;
}

.poke-name-line.very-long-name {
  font-size: 11px;
}

/* Line 3: Type pills (centered) */
.poke-type-line {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

/* Legacy: Type icon + Name header (keeping for compatibility) */
.poke-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.poke-header .icon-chip {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Pokemon name (legacy) */
.poke-name {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poke-name.long-name {
  font-size: 13px;
}

.poke-name.very-long-name {
  font-size: 11px;
}

/* Matchup icons row - positioned at bottom */
.poke-matchup-icons {
  position: absolute;
  bottom: var(--space-xs);
  left: var(--space-xs);
  right: var(--space-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.matchup-icons-strong,
.matchup-icons-weak {
  display: flex;
  align-items: center;
  gap: 2px;
}

.matchup-icons-strong {
  color: var(--success, #2a7);
}

.matchup-icons-weak {
  color: var(--danger, #c55);
}

.matchup-caret {
  font-size: 10px;
  margin-right: 2px;
}

.matchup-dash {
  font-size: 11px;
  opacity: 0.6;
}

/* Mini icon chips for matchup row */
.icon-chip-mini {
  width: 14px;
  height: 14px;
}

/* ============================================
   BACK FACE LAYOUT
   ============================================ */

/* Back header: Type icons + Name */
.poke-header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-bottom: 4px;
}

.poke-header-back .icon-chip {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Matchup detail sections - labels positioned absolutely */
.matchup-detail {
  width: 100%;
  text-align: center;
}

.matchup-detail.strong-section {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  right: var(--space-xs);
  height: 45%;
}

.matchup-detail.weak-section {
  position: absolute;
  bottom: var(--space-xs);
  left: var(--space-xs);
  right: var(--space-xs);
  height: 45%;
}

.matchup-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: bold;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.matchup-label.strong {
  color: var(--success, #2a7);
}

.matchup-label.weak {
  color: var(--danger, #c55);
}

/* Mini type pills container - no wrap, fit on one line */
.matchup-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  justify-content: center;
}

/* Mini type pills (icon + label) */
.type-pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-alt, #E5DFD0);
  font-family: var(--font-body);
  font-size: 9px;
  line-height: 1;
}

.type-pill-mini .icon-chip,
.type-pill-mini .icon-chip-mini {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.type-pill-mini-label {
  color: var(--text-primary);
}

/* Overflow indicator (+N) */
.matchup-overflow {
  font-size: 9px;
  color: var(--text-secondary);
  padding: 1px 3px;
}

/* Empty matchup placeholder */
.matchup-none {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Back face placeholder when no opponent types */
.flip-back-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px;
  white-space: pre-line;
}

/* ============================================
   COLUMN LAYOUT - Type-grouped Pokemon cards
   ============================================ */

/* Uses same 3-column grid as picks-list */
.type-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-xs);
}

.type-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.type-column-header {
  padding: var(--space-sm) 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.type-column-icon {
  width: 16px;
  height: 16px;
}

/* Hide column headers (type icons) for combined slide */
.carousel-slide--no-icons .type-column-header {
  display: none;
}

.type-column-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
  align-items: center;
}

.type-column-pills {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  touch-action: pan-y;
  margin-top: var(--space-xs);
}

.type-column-pills .type-pill {
  width: 100%;
  justify-content: center;
  touch-action: pan-y;
  /* Flat/informational - not clickable */
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-top-color: var(--border-default);
  border-left-color: var(--border-default);
  border-right-color: var(--border-default);
  border-bottom-color: var(--border-default);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.06);
  cursor: default;
}

.type-column-pills .type-pill:hover {
  /* No hover effect - not interactive */
  background: var(--bg-surface);
  transform: none;
}

/* Type icons row - horizontal layout for compact display */
.type-column-icons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  justify-content: center;
  align-items: center;
  touch-action: pan-y;
}

.type-result-icon {
  width: 22px;
  height: 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Unpressed: raised look */
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 0 var(--btn-lo);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.type-result-icon:active,
.type-result-icon.is-popup-active {
  /* Pressed: sunk in */
  transform: translateY(2px);
  box-shadow: none;
}

.type-icon-none {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================
   SIMPLE CARD - Accessible Pokemon card
   ============================================ */

.simple-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  width: 100%;
  box-sizing: border-box;
  /* Unpressed: raised 3D look like grid buttons */
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  border-top-color: var(--btn-hi);
  border-left-color: var(--btn-hi);
  border-right-color: var(--btn-lo);
  border-bottom-color: var(--btn-lo);
  box-shadow: var(--btn-shadow);
  touch-action: pan-y;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.simple-card:active,
.simple-card.is-popup-active {
  /* Pressed: sunk in */
  background: var(--btn-bg-active);
  transform: translateY(1px);
  border-top-color: var(--btn-hi-active);
  border-left-color: var(--btn-hi-active);
  border-right-color: var(--btn-lo-active);
  border-bottom-color: var(--btn-lo-active);
  box-shadow: var(--btn-inset);
}

.simple-card-name {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: normal;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pokemon info popup - appears on tap */
.poke-popup {
  position: fixed;
  z-index: 1000;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-width: 374px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.poke-popup.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.poke-popup-text {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--text-primary);
  line-height: 1.6;
}

.poke-popup-text .icon-chip {
  width: 22px;
  height: 22px;
  display: inline-block;
  vertical-align: middle;
  margin: 0 3px;
}

/* Tappable icons in popup - unpressed look by default */
.poke-popup-text .icon-chip.is-tappable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Unpressed: raised look */
  box-shadow: 0 2px 0 var(--btn-lo);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

/* Pressed only while held - returns to unpressed on release */
.poke-popup-text .icon-chip.is-tappable:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Mini type label popup - appears on hold */
.type-label-popup {
  position: fixed;
  z-index: 1001;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.type-label-popup.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.type-label-popup-text {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Placeholder card for empty results */
.simple-card--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}

.simple-card-placeholder-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
  white-space: pre-line;
}

/* ============================================
   LEGACY STYLES (for backwards compatibility)
   ============================================ */

/* Legacy .poke-card class - keep for any old references */
.poke-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
  text-align: center;
  overflow: hidden;
  min-height: 100px;
}

/* Legacy matchup row */
.poke-matchups {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  margin-top: auto;
  padding-top: 4px;
}

.matchup-strong {
  color: var(--success, #2a7);
}

.matchup-weak {
  color: var(--danger, #c55);
}

/* Legacy .poke-meta */
.poke-meta {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary);
}

.poke-types {
  display: flex;
  justify-content: center;
  gap: 4px;
}

/* Type icons in flip card faces */
.flip-card-face .type-pill {
  padding: 0;
  gap: 0;
  border: none;
  background: transparent;
}

.flip-card-face .type-pill .type-name {
  display: none;
}

.flip-card-face .type-pill .icon-chip {
  width: 20px;
  height: 20px;
}

/* ============================================
   BUDGET COUNTER CARDS
   ============================================ */
.poke-moveset {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
}

.poke-badges {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* Badge color variants (extends .grade-pill) */
.badge-common { background: #4a7; color: white; }
.badge-uncommon { background: #58c; color: white; }
.badge-rare { background: #c84; color: white; }
.badge-legendary { background: #a5c; color: white; }
.badge-low { background: #6a6; color: white; }
.badge-medium { background: #ca6; color: #333; }
.badge-high { background: #c66; color: white; }

/* ============================================
   UTILITIES
   ============================================ */
#viewVersus,
#viewCollection,
#viewTrade { display: contents; }

#viewVersus[hidden],
#viewCollection[hidden],
#viewTrade[hidden] { display: none !important; }

.icon {
  width: 18px;
  height: 18px;
  opacity: 0.95;
  /* Icons handle their own fill/stroke via currentColor */
}

/* ============================================
   MOBILE TWEAKS
   ============================================ */
@media (max-width: 480px) {
  :root {
    --appbar-h: 50px;
    --typebar-h: 46px;
  }
  .title { max-width: 52vw; }
  th, td { padding: 9px 10px; font-size: 0.9rem; }
  .main {
    padding: 0;
  }
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
  text-align: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  background: var(--bg-surface);
  border-bottom: 2px solid #5a544e;
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: underline;
}

.app-footer a:hover {
  color: var(--text-primary);
}

/* VS Recommendations hidden state */
#vsRecommendations[hidden] {
  display: none;
}

/* ============================================
   VIEWPORT FIT - In-app browser scaling
   ============================================ */
#appScaleWrapper {
  height: 100%;
  display: flex;
  justify-content: center;
}

.app {
  --app-scale: 1;
}
