
    /* ============================================================================
       CSS VARIABLES - Wordle-Inspired Minimal Design System
       ============================================================================ */
    
    /* Light Theme (Default) */
    :root[data-theme="light"],
    :root:not([data-theme]) {
      /* Backgrounds */
      --bg-primary: #ffffff;
      --bg-secondary: #f7f7f7;
      --bg-elevated: #ffffff;
      --bg-hover: #f0f0f0;
      
      /* Borders */
      --border-default: #d3d6da;
      --border-hover: #878a8c;
      --border-selected: #6aaa64;
      --border-error: #e63946;
      
      /* Text */
      --text-primary: #1a1a1a;
      --text-secondary: #787c7e;
      --text-muted: #b0b0b0;
      --text-on-accent: #ffffff;
      
      /* Accents */
      --accent-success: #6aaa64;
      --accent-success-hover: #5a9a54;
      --accent-warning: #c9b458;
      --accent-error: #e63946;
      --accent-info: #4a90e2;
      
      /* Grid Tile States */
      --tile-bg-default: #ffffff;
      --tile-bg-selected: rgba(106, 170, 100, 0.2);
      --tile-bg-success: #6aaa64;
      --tile-bg-error: rgba(230, 57, 70, 0.1);
      
      /* Legacy compatibility */
      --success: #6aaa64;
      --error: #e63946;
      --warning: #c9b458;
    }

    /* Dark Theme - Improved Contrast */
    :root[data-theme="dark"] {
      /* Backgrounds - Dark mode palette */
      --bg-primary: #0d1117;
      --bg-secondary: #111827;
      --bg-elevated: #161b22;
      --bg-hover: #1f2937;
      
      /* Borders */
      --border-default: #1f2937;
      --border-hover: #2d3748;
      --border-selected: #5b8def;
      --border-error: #f87171;
      
      /* Text */
      --text-primary: #e5e7eb;
      --text-secondary: #c7cdd8;
      --text-muted: #8b93a7;
      --text-on-accent: #ffffff;
      
      /* Accents */
      --accent-success: #34d399;
      --accent-success-hover: #059669;
      --accent-warning: #fbbf24;
      --accent-error: #f87171;
      --accent-info: #38bdf8;
      
      /* Grid Tile States */
      --tile-bg-default: #161b22;
      --tile-bg-selected: rgba(91, 141, 239, 0.25);
      --tile-bg-success: #34d399;
      --tile-bg-error: rgba(248, 113, 113, 0.22);
      
      /* Legacy compatibility */
      --success: #34d399;
      --error: #f87171;
      --warning: #fbbf24;
    }

    /* Typography Scale */
    :root {
      --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      --font-xs: 0.75rem;
      --font-sm: 0.875rem;
      --font-base: 1rem;
      --font-lg: 1.25rem;
      --font-xl: 1.5rem;
      --font-2xl: 2rem;
      --font-3xl: 2.5rem;
      --font-display: 3rem;
      
      --font-normal: 400;
      --font-medium: 500;
      --font-semibold: 600;
      --font-bold: 700;
      
      --leading-tight: 1.25;
      --leading-normal: 1.5;
      --leading-relaxed: 1.75;
    }

    /* Spacing Scale (8px base) */
    :root {
      --space-1: 0.25rem;
      --space-2: 0.5rem;
      --space-3: 0.75rem;
      --space-4: 1rem;
      --space-5: 1.5rem;
      --space-6: 2rem;
      --space-8: 3rem;
      --space-10: 4rem;
      --space-12: 6rem;
    }

    /* Border Radius */
    :root {
      --radius-sm: 4px;
      --radius-md: 8px;
      --radius-lg: 12px;
      --radius-xl: 16px;
      --radius-full: 9999px;
    }

    /* Shadows (Subtle, Wordle-style) */
    :root {
      --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
      --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.08);
      --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.1);
      --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.12);
      --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
      --shadow-tile: 0 2px 4px rgba(0, 0, 0, 0.1);
      --shadow-tile-selected: 0 4px 8px rgba(106, 170, 100, 0.3);
    }

    /* Transitions */
    :root {
      --transition-fast: 150ms ease-out;
      --transition-normal: 200ms ease-out;
      --transition-slow: 300ms ease-out;
      --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
      
      /* Legacy compatibility */
      --transition-fast: 0.15s;
      --transition-normal: 0.2s;
      --transition-slow: 0.3s;
    }

    /* Grid Dimensions */
    :root {
      --grid-tile-size-4: 62px;
      --grid-tile-size-5: 50px;
      --grid-gap: 6px;
      --grid-font-size: 32px;
      --grid-tile-size-4-mobile: 70px;
      --grid-tile-size-5-mobile: 56px;
      --grid-font-size-mobile: 28px;
    }

    /* Font Size Multiplier (for accessibility) */
    :root {
      --font-size-multiplier: 1;
    }

    /* Font Size Options */
    body.font-size-small {
      --font-size-multiplier: 0.85;
    }

    body.font-size-large {
      --font-size-multiplier: 1.15;
    }

    body.font-size-xlarge {
      --font-size-multiplier: 1.3;
    }

    body {
      font-size: calc(14px * var(--font-size-multiplier));
    }

    /* Screen Reader Only */
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border-width: 0;
    }

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

    /* ============================================================================
       RESET & BASE STYLES
       ============================================================================ */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: var(--font-family);
      background: var(--bg-primary);
      color: var(--text-primary);
      font-size: var(--font-base);
      line-height: var(--leading-normal);
      min-height: 100vh;
      overflow-x: hidden;
      transition: background-color 200ms ease, color 200ms ease;
      /* Safe area insets for notched devices */
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
    }

    #app {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* ============================================================================
       HEADER - Minimal Wordle-style
       ============================================================================ */
    .header {
      background: var(--bg-primary);
      border-bottom: 1px solid var(--border-default);
      padding: var(--space-4) var(--space-5);
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: relative;
      transition: background-color 200ms ease, border-color 200ms ease;
    }

    .header-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--space-2);
    }

    .title {
      font-size: var(--font-3xl);
      font-weight: var(--font-bold);
      color: var(--text-primary);
      letter-spacing: -0.02em;
      margin: 0;
    }

    .dict-badge {
      display: inline-block;
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-full);
      padding: var(--space-1) var(--space-3);
      font-size: var(--font-xs);
      color: var(--text-secondary);
      font-weight: var(--font-medium);
    }

    .header-actions {
      display: flex;
      gap: var(--space-2);
      align-items: center;
    }

    .btn-icon {
      background: transparent;
      border: none;
      padding: var(--space-2);
      cursor: pointer;
      font-size: var(--font-xl);
      color: var(--text-secondary);
      border-radius: var(--radius-md);
      transition: background-color var(--transition-fast), color var(--transition-fast);
      min-width: 44px;
      min-height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

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

    .btn-icon:focus {
      outline: 2px solid var(--accent-info);
      outline-offset: 2px;
    }

    /* ============================================================================
       MAIN LAYOUT - Centered Wordle-style
       ============================================================================ */
    .main-container {
      display: flex;
      flex: 1;
      gap: var(--space-8);
      padding: var(--space-6) var(--space-4);
      max-width: 1200px;
      margin: 0 auto;
      width: 100%;
      align-items: flex-start;
    }

    /* Mobile: Single column */
    @media (max-width: 767px) {
      .main-container {
        flex-direction: column;
        padding: var(--space-4) var(--space-3);
        gap: var(--space-5);
        align-items: stretch;
      }
    }

    /* ============================================================================
       GRID PANEL - Wordle-style Centered Layout
       ============================================================================ */
    .grid-panel {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--space-4);
      max-width: 600px;
      margin: 0 auto;
    }

    /* Mode Selection - At top of grid panel */
    .mode-selection {
      width: 100%;
      display: flex;
      justify-content: center;
      margin-bottom: var(--space-2);
    }

    .mode-toggles {
      display: flex;
      gap: var(--space-2);
    }

    /* Submit Button Container - Directly under grid */
    .submit-button-container {
      width: 100%;
      display: flex;
      justify-content: center;
      margin-top: var(--space-2);
      margin-bottom: var(--space-3);
    }

    .btn-submit {
      min-width: 200px;
      font-size: var(--font-xl);
      padding: var(--space-4) var(--space-8);
      font-weight: var(--font-bold);
    }

    @media (max-width: 767px) {
      .btn-submit {
        min-width: 180px;
        font-size: var(--font-lg);
        padding: var(--space-3) var(--space-6);
      }
    }
    
    .grid-panel .action-buttons {
      margin-top: var(--space-2);
      gap: var(--space-2);
    }
    
    .grid-panel .btn {
      padding: var(--space-3) var(--space-5);
      font-size: var(--font-base);
      min-width: 100px;
    }

    .grid-container {
      display: grid;
      gap: var(--grid-gap);
      padding: var(--space-4);
      background: transparent;
      border-radius: 0;
      box-shadow: none;
    }

    .grid-container.grid-4 {
      grid-template-columns: repeat(4, 1fr);
    }

    .grid-container.grid-5 {
      grid-template-columns: repeat(5, 1fr);
    }

    .grid-tile {
      width: var(--grid-tile-size-4);
      height: var(--grid-tile-size-4);
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--tile-bg-default);
      border: 2px solid var(--border-default);
      border-radius: var(--radius-md);
      font-size: var(--grid-font-size);
      font-weight: var(--font-bold);
      color: var(--text-primary);
      cursor: pointer;
      transition: all var(--transition-fast);
      user-select: none;
      touch-action: manipulation;
      position: relative;
    }

    .grid-container.grid-5 .grid-tile {
      width: var(--grid-tile-size-5);
      height: var(--grid-tile-size-5);
    }

    @media (max-width: 767px) {
      .grid-tile {
        width: var(--grid-tile-size-4-mobile);
        height: var(--grid-tile-size-4-mobile);
        font-size: var(--grid-font-size-mobile);
      }
      
      .grid-container.grid-5 .grid-tile {
        width: var(--grid-tile-size-5-mobile);
        height: var(--grid-tile-size-5-mobile);
      }
    }

    .grid-tile:hover:not(.disabled) {
      border-color: var(--border-hover);
      transform: scale(1.05);
    }

    @media (hover: none) {
      .grid-tile:hover:not(.disabled) {
        transform: scale(1);
      }
    }

    .grid-tile.selected {
      background: var(--tile-bg-selected);
      border-color: var(--border-selected);
      box-shadow: var(--shadow-tile-selected);
      transform: scale(1.05);
    }

    .grid-tile.drag-path {
      border-color: var(--accent-info);
      background: rgba(74, 144, 226, 0.1);
    }

    .grid-tile.drag-path.selected {
      border-color: var(--border-selected);
      background: var(--tile-bg-selected);
    }

    .grid-tile.disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .grid-container.paused .grid-tile {
      opacity: 0.5;
      cursor: not-allowed;
      pointer-events: none;
    }

    .grid-container.paused .grid-tile.selected {
      opacity: 0.3;
    }

    /* Word submission success state */
    .grid-tile.submitted {
      background: var(--tile-bg-success);
      border-color: var(--accent-success);
      color: var(--text-on-accent);
      animation: tileSuccess var(--transition-bounce);
    }

    @keyframes tileSuccess {
      0% { transform: scale(1); }
      50% { transform: scale(1.1); }
      100% { transform: scale(1); }
    }

    /* Word submission error state */
    .grid-container.word-error .grid-tile.selected {
      background: var(--tile-bg-error);
      border-color: var(--border-error);
      animation: tileError 0.5s ease;
    }

    @keyframes tileError {
      0%, 100% { transform: translateX(0); }
      10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
      20%, 40%, 60%, 80% { transform: translateX(4px); }
    }

    /* Word Length Color Indicators - Subtle variations */
    .grid-container.word-length-4 .grid-tile.selected {
      background: var(--tile-bg-selected);
    }

    .grid-container.word-length-5 .grid-tile.selected {
      background: var(--tile-bg-selected);
    }

    .grid-container.word-length-6 .grid-tile.selected {
      background: var(--tile-bg-selected);
    }

    .grid-container.word-length-7 .grid-tile.selected {
      background: var(--tile-bg-selected);
    }

    .grid-container.word-length-8plus .grid-tile.selected {
      background: var(--tile-bg-selected);
    }

    /* Keyboard input feedback */
    .grid-tile.keyboard-highlight {
      animation: keyboardSelect 0.3s ease-out;
    }

    @keyframes keyboardSelect {
      0% {
        transform: scale(1);
      }
      50% {
        transform: scale(1.1);
        box-shadow: var(--shadow-tile-selected);
      }
      100% {
        transform: scale(1);
      }
    }

    @media (prefers-reduced-motion: reduce) {
      .grid-tile.keyboard-highlight {
        animation: none;
      }
    }

    .grid-placeholder {
      padding: 2rem;
      text-align: center;
      color: var(--text-secondary);
      font-size: 1.1rem;
      grid-column: 1 / -1;
    }

    .grid-container.word-submitted {
      animation: flashSuccess 0.3s ease;
    }

    @keyframes flashSuccess {
      0%, 100% { 
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
      }
      50% { 
        box-shadow: 0 4px 30px rgba(16, 185, 129, 0.8);
      }
    }

    .stat-value.score-increase {
      animation: scorePop 0.6s ease;
      will-change: transform;
    }

    @keyframes scorePop {
      0%, 100% { 
        transform: scale(1);
      }
      50% { 
        transform: scale(1.3);
        color: var(--success);
      }
    }
    
    /* Performance optimizations */
    .grid-container.word-submitted {
      will-change: box-shadow;
    }
    
    .achievement-notification {
      will-change: transform, opacity;
    }

    .current-word-display {
      text-align: center;
      min-height: 60px;
    }

    .cur-word-text {
      font-size: var(--font-2xl);
      font-weight: var(--font-bold);
      color: var(--text-primary);
      letter-spacing: 0.1em;
      min-height: 2.5rem;
    }

    .potential-score {
      font-size: var(--font-base);
      color: var(--text-secondary);
      margin-top: var(--space-2);
    }

    .score-breakdown {
      font-size: var(--font-xs);
      color: var(--text-secondary);
      margin-top: var(--space-2);
      padding: var(--space-2);
      background: var(--bg-elevated);
      border-radius: var(--radius-sm);
      border-left: 2px solid var(--accent-success);
      display: none;
    }

    .score-breakdown.visible {
      display: block;
    }

    .score-breakdown-line {
      display: flex;
      justify-content: space-between;
      margin: var(--space-1) 0;
    }

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

    .score-breakdown-value {
      color: var(--accent-success);
      font-weight: var(--font-semibold);
    }

    .score-breakdown-total {
      margin-top: var(--space-2);
      padding-top: var(--space-2);
      border-top: 1px solid var(--border-default);
      font-weight: var(--font-bold);
    }

    /* ============================================================================
       STATS PANEL
       ============================================================================ */
    .stats-panel {
      flex: 0 0 300px;
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
    }

    @media (max-width: 767px) {
      .stats-panel {
        flex: 1;
      }
    }

    /* Combo Timer Visual Indicator */
    .combo-item {
      position: relative;
    }

    .combo-wrapper {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 60px;
      height: 60px;
    }

    .combo-timer-ring {
      position: absolute;
      width: 60px;
      height: 60px;
      transform: rotate(-90deg);
      transition: opacity var(--transition-normal);
    }

    .combo-timer-ring.hidden {
      opacity: 0;
      pointer-events: none;
    }

    .combo-timer-bg {
      fill: none;
      stroke: var(--border-default);
      stroke-width: 4;
    }

    .combo-timer-progress {
      fill: none;
      stroke: var(--accent-success);
      stroke-width: 4;
      stroke-linecap: round;
      stroke-dasharray: 163.36; /* 2 * π * 26 */
      stroke-dashoffset: 163.36;
      transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
    }

    /* Color transitions based on time remaining */
    .combo-timer-progress.warning {
      stroke: var(--warning);
    }

    .combo-timer-progress.danger {
      stroke: var(--error);
    }

    .combo-value {
      position: relative;
      z-index: 1;
    }

    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
      .combo-timer-progress {
        transition: none;
      }
    }

    .stats-section {
      background: var(--bg-elevated);
      padding: var(--space-5);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border-default);
      box-shadow: var(--shadow-card);
    }

    .stat-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: var(--space-3) 0;
      border-bottom: 1px solid var(--border-default);
    }

    .stat-item.streak-active {
      background: rgba(106, 170, 100, 0.1);
      border-left: 3px solid var(--accent-success);
      padding-left: var(--space-2);
    }

    .stat-item.streak-active .stat-value {
      color: var(--accent-success);
      font-weight: var(--font-bold);
    }

    .stat-item:last-child {
      border-bottom: none;
    }

    .stat-label {
      color: var(--text-secondary);
      font-size: 14px;
    }

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

    /* Milestone Badges */
    .milestone-badges {
      display: flex;
      gap: 0.5rem;
      justify-content: center;
      padding: 0.5rem;
      margin-top: 0.5rem;
    }

    .milestone-badge {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      border: 2px solid var(--text-secondary);
      background: var(--bg-primary);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      transition: all var(--transition-normal);
      opacity: 0.4;
    }

    .milestone-badge.unlocked {
      border-color: var(--accent-success);
      background: var(--tile-bg-selected);
      opacity: 1;
      box-shadow: var(--shadow-tile-selected);
    }

    .milestone-badge.just-unlocked {
      animation: milestoneUnlock 0.6s ease-out;
    }

    @keyframes milestoneUnlock {
      0% {
        transform: scale(1);
      }
      50% {
        transform: scale(1.3);
      }
      100% {
        transform: scale(1);
      }
    }

    .milestone-number {
      font-size: 14px;
      font-weight: 700;
      color: var(--text-primary);
      line-height: 1;
    }

    .milestone-badge.unlocked .milestone-number {
      color: var(--accent-success);
    }

    .milestone-label {
      font-size: 8px;
      color: var(--text-secondary);
      text-transform: uppercase;
      line-height: 1;
      margin-top: 2px;
    }

    .milestone-badge.unlocked .milestone-label {
      color: var(--accent-success);
    }

    @media (prefers-reduced-motion: reduce) {
      .milestone-badge.just-unlocked {
        animation: none;
      }
    }

    .progress-section {
      background: var(--bg-elevated);
      padding: var(--space-5);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border-default);
      box-shadow: var(--shadow-card);
    }

    .progress-label {
      color: var(--text-secondary);
      font-size: 14px;
      margin-bottom: 0.5rem;
    }

    .progress-bar-container {
      height: 8px;
      background: var(--bg-hover);
      border-radius: var(--radius-sm);
      overflow: hidden;
    }

    .progress-bar {
      height: 100%;
      background: var(--accent-success);
      border-radius: var(--radius-sm);
      transition: width var(--transition-normal) ease;
      width: 0%;
    }

    .words-section {
      background: var(--bg-elevated);
      padding: var(--space-5);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border-default);
      box-shadow: var(--shadow-card);
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 200px;
    }

    .words-label {
      color: var(--text-secondary);
      font-size: var(--font-sm);
      font-weight: var(--font-semibold);
      margin-bottom: var(--space-4);
    }

    .words-list {
      flex: 1;
      overflow-y: auto;
      max-height: 300px;
    }

    .word-item {
      padding: var(--space-2);
      margin-bottom: var(--space-2);
      background: var(--bg-primary);
      border-left: 3px solid var(--border-default);
      border-radius: var(--radius-sm);
      display: flex;
      justify-content: space-between;
      align-items: center;
      animation: fadeIn var(--transition-fast) ease;
    }

    /* Recent Words Highlight */
    .word-item.newly-added {
      animation: fadeIn var(--transition-fast) ease, wordHighlight 1.5s ease-out;
    }

    @keyframes wordHighlight {
      0% {
        background: var(--tile-bg-selected);
        transform: scale(1.02);
      }
      100% {
        background: var(--bg-primary);
        transform: scale(1);
      }
    }

    /* Color-Coded Word Scores */
    .word-item.score-low {
      border-left-color: var(--text-secondary);
    }

    .word-item.score-medium {
      border-left-color: var(--accent-warning);
    }

    .word-item.score-high {
      border-left-color: var(--accent-success);
    }

    .word-item.score-very-high {
      border-left-color: var(--accent-success);
      border-left-width: 3px;
    }

    @media (prefers-reduced-motion: reduce) {
      .word-item.newly-added {
        animation: fadeIn var(--transition-fast) ease;
      }
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(-10px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .word-text {
      color: var(--text-primary);
      font-weight: 600;
    }

    .word-points {
      color: var(--accent-success);
      font-weight: var(--font-bold);
    }

    .best-score-section {
      background: var(--bg-elevated);
      padding: var(--space-5);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border-default);
      box-shadow: var(--shadow-card);
    }

    /* Session Statistics Section */
    .session-stats-section {
      background: var(--bg-elevated);
      padding: var(--space-5);
      border-radius: var(--radius-lg);
      border: 1px solid var(--border-default);
      box-shadow: var(--shadow-card);
    }

    .session-stats-toggle {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: var(--space-3);
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-md);
      color: var(--text-primary);
      font-size: var(--font-sm);
      font-weight: var(--font-semibold);
      cursor: pointer;
      transition: all var(--transition-fast);
    }

    .session-stats-toggle:hover {
      background: var(--bg-hover);
      border-color: var(--border-hover);
    }

    .session-stats-toggle:focus {
      outline: 2px solid var(--accent-info);
      outline-offset: 2px;
    }

    .toggle-icon {
      transition: transform var(--transition-fast) ease;
      font-size: 12px;
    }

    .session-stats-toggle[aria-expanded="true"] .toggle-icon {
      transform: rotate(180deg);
    }

    .session-stats-content {
      margin-top: 1rem;
      display: none;
    }

    .session-stats-content[aria-hidden="false"] {
      display: block;
    }

    .session-stat-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.75rem 0;
      border-bottom: 1px solid rgba(0, 243, 255, 0.1);
    }

    .session-stat-item:last-child {
      border-bottom: none;
    }

    .session-stat-label {
      color: var(--text-secondary);
      font-size: 14px;
    }

    .session-stat-value {
      color: var(--accent-neon);
      font-size: 16px;
      font-weight: 700;
    }

    /* ============================================================================
       CONTROLS (Removed - mode toggles moved to grid panel)
       ============================================================================ */
    @media (max-width: 767px) {
      
      /* Mobile modal improvements */
      .modal-content {
        width: 95%;
        max-height: 95vh;
        padding: 1.5rem;
        margin: 1rem;
      }
      
      /* Prevent pull-to-refresh on mobile */
      body {
        overscroll-behavior-y: contain;
      }
      
      /* Better keyboard handling */
      .main-container {
        padding-bottom: env(keyboard-inset-height, 0);
      }
    }

    .mode-btn {
      padding: var(--space-2) var(--space-4);
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-full);
      color: var(--text-primary);
      font-size: var(--font-sm);
      font-weight: var(--font-semibold);
      cursor: pointer;
      transition: all var(--transition-fast);
    }

    .mode-btn:hover:not(:disabled) {
      background: var(--bg-hover);
      border-color: var(--border-hover);
    }

    .mode-btn.active {
      background: var(--accent-success);
      border-color: var(--accent-success);
      color: var(--text-on-accent);
    }

    .mode-btn:focus {
      outline: 2px solid var(--accent-info);
      outline-offset: 2px;
    }

    .action-buttons {
      display: flex;
      gap: var(--space-2);
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
    }

    /* Make primary action button more prominent */
    .action-buttons .btn-primary {
      min-width: 140px;
      font-size: var(--font-lg);
      padding: var(--space-3) var(--space-6);
    }

    /* Secondary buttons smaller for faster scanning */
    .action-buttons .btn-secondary {
      min-width: 90px;
      font-size: var(--font-sm);
    }

    @media (max-width: 767px) {
      .action-buttons {
        gap: var(--space-2);
      }
      
      .action-buttons .btn-primary {
        min-width: 120px;
        font-size: var(--font-base);
      }
      
      .action-buttons .btn-secondary {
        min-width: 80px;
        font-size: var(--font-sm);
      }
    }

    .btn {
      padding: var(--space-3) var(--space-5);
      border: none;
      border-radius: var(--radius-md);
      font-size: var(--font-base);
      font-weight: var(--font-semibold);
      cursor: pointer;
      transition: all var(--transition-fast);
      min-width: 120px;
      min-height: 44px;
      touch-action: manipulation;
      font-family: var(--font-family);
    }

    @media (max-width: 767px) {
      .btn {
        min-width: 100px;
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-sm);
      }
    }

    .btn:focus {
      outline: 2px solid var(--accent-info);
      outline-offset: 2px;
    }

    .btn-primary {
      background: var(--accent-success);
      color: var(--text-on-accent);
      box-shadow: var(--shadow-md);
    }

    .btn-primary:hover:not(:disabled) {
      background: var(--accent-success-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-lg);
    }

    .btn-primary:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: var(--shadow-sm);
    }

    .btn-secondary {
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      color: var(--text-primary);
    }

    .btn-secondary:hover:not(:disabled) {
      background: var(--bg-hover);
      border-color: var(--border-hover);
    }

    .btn-secondary:active:not(:disabled) {
      transform: scale(0.98);
    }

    .btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    /* ============================================================================
       STATUS LINE
       ============================================================================ */
    .status-line {
      padding: 1rem 2rem;
      text-align: center;
      min-height: 3rem;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .status-line.info {
      color: var(--text-secondary);
    }

    .status-line.success {
      color: var(--success);
      animation: pulse var(--transition-normal) ease;
    }

    .status-line.error {
      color: var(--error);
      animation: pulse var(--transition-normal) ease;
    }

    @keyframes pulse {
      0%, 100% {
        opacity: 1;
      }
      50% {
        opacity: 0.7;
      }
    }

    /* ============================================================================
       MODAL (Summary)
       ============================================================================ */
    .modal {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.8);
      z-index: 1000;
      align-items: center;
      justify-content: center;
      /* Safe area insets for modals on mobile */
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
    }

    .modal[aria-hidden="false"] {
      display: flex;
    }

    .modal-content {
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-lg);
      padding: var(--space-6);
      max-width: 500px;
      width: 90%;
      box-shadow: var(--shadow-xl);
      animation: modalSlideIn var(--transition-normal) ease;
    }

    @keyframes modalSlideIn {
      from {
        opacity: 0;
        transform: translateY(-50px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .modal-title {
      font-size: 1.5rem;
      margin-bottom: 1.5rem;
      text-align: center;
      color: var(--accent-neon);
    }

    .summary-stats {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      margin-bottom: 1.5rem;
    }

    .summary-stat {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 1rem;
      background: var(--bg-primary);
      border-radius: 8px;
    }

    .summary-label {
      color: var(--text-secondary);
      font-size: 14px;
    }

    .summary-value {
      color: var(--accent-neon);
      font-size: 20px;
      font-weight: 700;
    }

    .modal-actions {
      display: flex;
      justify-content: center;
    }

    .achievement-notification {
      position: fixed;
      top: 20px;
      right: 20px;
      background: linear-gradient(135deg, var(--accent-neon), var(--accent-purple));
      border: 2px solid var(--accent-pink);
      border-radius: 12px;
      padding: 1rem 1.5rem;
      display: flex;
      align-items: center;
      gap: 1rem;
      box-shadow: 0 8px 30px rgba(0, 243, 255, 0.5);
      z-index: 2000;
      transform: translateX(400px);
      opacity: 0;
      transition: all 0.5s ease;
      max-width: 350px;
    }

    .achievement-notification.show {
      transform: translateX(0);
      opacity: 1;
    }

    .achievement-icon {
      font-size: 2rem;
      flex-shrink: 0;
    }

    .achievement-content {
      flex: 1;
    }

    .achievement-name {
      font-weight: 700;
      font-size: 1.1rem;
      color: var(--bg-primary);
      margin-bottom: 0.25rem;
    }

    .achievement-desc {
      font-size: 0.9rem;
      color: rgba(10, 10, 15, 0.8);
    }

    /* ============================================================================
       UTILITY CLASSES
       ============================================================================ */
    .hidden {
      display: none !important;
    }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border-width: 0;
    }

    /* Score Breakdown Tooltip */
    .score-wrapper {
      position: relative;
      display: inline-block;
    }

    .score-tooltip {
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      margin-bottom: 0.5rem;
      background: var(--bg-secondary);
      border: 2px solid var(--accent-neon);
      border-radius: 8px;
      padding: 0.75rem;
      min-width: 200px;
      box-shadow: 0 4px 20px rgba(0, 243, 255, 0.3);
      opacity: 0;
      pointer-events: none;
      transition: opacity var(--transition-fast) ease;
      z-index: 1000;
      white-space: nowrap;
    }

    .score-tooltip[aria-hidden="false"],
    .score-wrapper:hover .score-tooltip,
    .score-wrapper:focus-within .score-tooltip {
      opacity: 1;
      pointer-events: auto;
    }

    .tooltip-content {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }

    .tooltip-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--accent-neon);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin-bottom: 0.25rem;
    }

    .tooltip-breakdown {
      font-size: 11px;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .tooltip-breakdown-line {
      display: flex;
      justify-content: space-between;
      margin: 0.25rem 0;
    }

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

    .tooltip-breakdown-value {
      color: var(--accent-neon);
      font-weight: 600;
      margin-left: 1rem;
    }

    @media (max-width: 767px) {
      .score-tooltip {
        left: auto;
        right: 0;
        transform: none;
        min-width: 180px;
      }
    }

    /* Ad Container Styles */
    .ad-container {
      min-height: 100px;
      margin: 1rem 0;
      padding: 0.5rem;
    }

    .ad-desktop {
      display: block;
    }

    .ad-mobile {
      display: none;
    }

    @media (max-width: 767px) {
      .ad-desktop {
        display: none;
      }
      
      .ad-mobile {
        display: block;
      }
    }

    /* ============================================================================
       GDPR CONSENT BANNER & PANEL
       ============================================================================ */
    
    .consent-banner {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: var(--bg-elevated);
      border-top: 2px solid var(--border-default);
      box-shadow: var(--shadow-xl);
      z-index: 10000;
      padding: 1.5rem;
      animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
      from {
        transform: translateY(100%);
        opacity: 0;
      }
      to {
        transform: translateY(0);
        opacity: 1;
      }
    }

    .consent-banner-content {
      max-width: 1200px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }

    .consent-banner-header h2 {
      margin: 0 0 0.5rem 0;
      color: var(--text-primary);
      font-size: calc(1.2rem * var(--font-size-multiplier));
    }

    .consent-banner-description {
      margin: 0;
      color: var(--text-secondary);
      font-size: calc(0.9rem * var(--font-size-multiplier));
      line-height: 1.5;
    }

    .consent-banner-actions {
      display: flex;
      gap: 1rem;
      flex-wrap: wrap;
      align-items: center;
    }

    .consent-btn {
      padding: 0.75rem 1.5rem;
      border: none;
      border-radius: 6px;
      font-size: calc(1rem * var(--font-size-multiplier));
      font-weight: 600;
      cursor: pointer;
      transition: all var(--transition-normal);
      font-family: inherit;
    }

    .consent-btn-primary {
      background: var(--accent-success);
      color: var(--text-on-accent);
      font-weight: var(--font-semibold);
    }

    .consent-btn-primary:hover {
      background: var(--accent-success-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-lg);
    }

    .consent-btn-secondary {
      background: var(--bg-elevated);
      color: var(--text-primary);
      border: 2px solid var(--border-default);
      font-weight: var(--font-semibold);
    }

    .consent-btn-secondary:hover {
      background: var(--bg-hover);
      border-color: var(--border-hover);
    }

    .consent-btn-link {
      background: transparent;
      color: var(--text-secondary);
      text-decoration: underline;
      padding: 0.75rem 1rem;
      font-weight: var(--font-medium);
    }

    .consent-btn-link:hover {
      color: var(--text-primary);
      text-decoration: none;
    }

    /* Consent Panel (Modal) */
    .consent-panel {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(4px);
      z-index: 10001;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1rem;
      animation: fadeIn 0.3s ease-out;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }

    .consent-panel-content {
      background: var(--bg-elevated);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-lg);
      max-width: 600px;
      width: 100%;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: var(--shadow-xl);
      animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
      from {
        transform: translateY(-20px);
        opacity: 0;
      }
      to {
        transform: translateY(0);
        opacity: 1;
      }
    }

    .consent-panel-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: var(--space-5);
      border-bottom: 1px solid var(--border-default);
    }

    .consent-panel-header h2 {
      margin: 0;
      color: var(--text-primary);
      font-size: calc(1.5rem * var(--font-size-multiplier));
    }

    .consent-panel-close {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: 2rem;
      line-height: 1;
      cursor: pointer;
      padding: 0;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      transition: all var(--transition-fast);
    }

    .consent-panel-close:hover {
      color: var(--text-primary);
      background: var(--bg-hover);
    }

    .consent-panel-body {
      padding: 1.5rem;
    }

    .consent-panel-body > p {
      margin: 0 0 1.5rem 0;
      color: var(--text-secondary);
      font-size: calc(0.95rem * var(--font-size-multiplier));
    }

    .consent-option {
      margin-bottom: var(--space-5);
      padding: var(--space-4);
      background: var(--bg-primary);
      border-radius: var(--radius-md);
      border: 1px solid var(--border-default);
    }

    .consent-option-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0.5rem;
    }

    .consent-option-header label {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      cursor: pointer;
      color: var(--text-primary);
      font-size: calc(1rem * var(--font-size-multiplier));
      font-weight: 600;
    }

    .consent-option-header input[type="checkbox"] {
      width: 20px;
      height: 20px;
      cursor: pointer;
      accent-color: var(--accent-success);
    }

    .consent-option-status {
      font-size: calc(0.85rem * var(--font-size-multiplier));
      color: var(--text-secondary);
      font-weight: normal;
    }

    .consent-option-description {
      margin: 0;
      color: var(--text-secondary);
      font-size: calc(0.9rem * var(--font-size-multiplier));
      line-height: 1.5;
      padding-left: 2rem;
    }

    .consent-panel-actions {
      display: flex;
      gap: var(--space-3);
      flex-wrap: wrap;
      margin-top: var(--space-6);
      padding-top: var(--space-5);
      border-top: 1px solid var(--border-default);
    }

    @media (max-width: 768px) {
      .consent-banner {
        padding: 1rem;
      }

      .consent-banner-actions {
        flex-direction: column;
      }

      .consent-btn {
        width: 100%;
      }

      .consent-panel-content {
        max-width: 100%;
        margin: 0;
      }

      .consent-panel-actions {
        flex-direction: column;
      }

      .consent-panel-actions .consent-btn {
        width: 100%;
      }
    }

    /* ============================================================================
       SERVICE WORKER UPDATE NOTIFICATION
       ============================================================================ */

    #sw-update-notification {
      position: fixed;
      bottom: 20px;
      right: 20px;
      background: var(--bg-elevated);
      border: 2px solid var(--accent-success);
      border-radius: var(--radius-lg);
      padding: var(--space-4);
      box-shadow: var(--shadow-xl), 0 0 20px rgba(106, 170, 100, 0.3);
      z-index: 10000;
      max-width: 360px;
      animation: slideUpBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
      cursor: default;
      outline: none;
    }

    #sw-update-notification:focus {
      outline: 2px solid var(--accent-success);
      outline-offset: 2px;
    }

    @keyframes slideUpBounce {
      0% {
        transform: translateY(100%) scale(0.9);
        opacity: 0;
      }
      60% {
        transform: translateY(-5px) scale(1.02);
      }
      100% {
        transform: translateY(0) scale(1);
        opacity: 1;
      }
    }

    .sw-update-header {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      margin-bottom: var(--space-3);
    }

    .sw-update-icon {
      font-size: var(--font-2xl);
      animation: rotate 2s linear infinite;
      filter: drop-shadow(0 2px 4px rgba(106, 170, 100, 0.3));
    }

    @keyframes rotate {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }

    .sw-update-title {
      font-weight: var(--font-bold);
      font-size: var(--font-lg);
      color: var(--text-primary);
      flex: 1;
    }

    .sw-update-message {
      font-size: var(--font-sm);
      color: var(--text-secondary);
      line-height: var(--leading-relaxed);
      margin-bottom: var(--space-3);
    }

    .sw-update-countdown {
      font-size: var(--font-xs);
      color: var(--text-muted);
      text-align: center;
      padding: var(--space-2);
      background: var(--bg-hover);
      border-radius: var(--radius-md);
      margin-bottom: var(--space-3);
      transition: all var(--transition-fast);
    }

    .sw-update-countdown.sw-countdown-urgent {
      background: rgba(255, 71, 87, 0.1);
      color: var(--accent-error);
      font-weight: var(--font-semibold);
      animation: pulse 1s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% {
        opacity: 1;
      }
      50% {
        opacity: 0.7;
      }
    }

    #sw-countdown-time {
      font-weight: var(--font-bold);
      font-size: var(--font-sm);
    }

    .sw-update-actions {
      display: flex;
      gap: var(--space-2);
    }

    .sw-update-btn {
      padding: var(--space-3) var(--space-5);
      border-radius: var(--radius-md);
      cursor: pointer;
      font-weight: var(--font-semibold);
      font-size: var(--font-sm);
      transition: all var(--transition-fast);
      border: none;
      flex: 1;
      min-height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .sw-update-btn:focus {
      outline: 2px solid var(--accent-info);
      outline-offset: 2px;
    }

    .sw-update-btn-primary {
      background: var(--accent-success);
      color: var(--text-on-accent);
      box-shadow: var(--shadow-md);
    }

    .sw-update-btn-primary:hover {
      background: var(--accent-success-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-lg);
    }

    .sw-update-btn-primary:active {
      transform: translateY(0);
      box-shadow: var(--shadow-sm);
    }

    .sw-update-btn-secondary {
      background: var(--bg-hover);
      color: var(--text-primary);
      border: 1px solid var(--border-default);
    }

    .sw-update-btn-secondary:hover {
      background: var(--bg-elevated);
      border-color: var(--border-hover);
    }

    .sw-update-btn-secondary:active {
      transform: scale(0.98);
    }

    @media (max-width: 767px) {
      #sw-update-notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: var(--space-3);
      }

      .sw-update-header {
        margin-bottom: var(--space-2);
      }

      .sw-update-title {
        font-size: var(--font-base);
      }

      .sw-update-message {
        font-size: var(--font-xs);
        margin-bottom: var(--space-2);
      }

      .sw-update-countdown {
        margin-bottom: var(--space-2);
        padding: var(--space-1) var(--space-2);
      }

      .sw-update-btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-xs);
        min-height: 40px;
      }
    }

    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
      #sw-update-notification {
        animation: slideUp 0.2s ease-out;
      }

      .sw-update-icon {
        animation: none;
      }

      .sw-update-countdown.sw-countdown-urgent {
        animation: none;
      }
    }
  