/**
 * GEMMA BLOCKS - Minimalist Clean Theme
 * Pure simplicity, balanced proportions, high-readability typography, and zero visual clutter.
 */

:root {
  /* Neutral Color Palette (Tailwind Zinc inspired) */
  --bg-app: #09090b;
  --bg-surface: #121215;
  --bg-card: #141418;
  --bg-card-subtle: #1c1c21;
  --bg-input: #0e0e11;
  
  --border-subtle: #222226;
  --border-medium: #2e2e34;
  --border-focus: #52525b;
  
  --text-main: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --accent-primary: #ffffff;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-focus);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 16px 32px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   1. APP HEADER
   ========================================================================== */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 860px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: 4px;
}

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

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-ghost.btn-off {
  opacity: 0.45;
}

/* ==========================================================================
   2. GAME STAGE (BALANCED 3-COLUMN LAYOUT)
   ========================================================================== */

.game-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  max-width: 860px;
}

.col-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.col-left {
  width: 110px;
  flex-shrink: 0;
}

.col-right {
  width: 280px;
  flex-shrink: 0;
}

/* Standard Clean Card Container */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
}

.card-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 72px;
}

.preview-box canvas {
  width: 72px;
  height: 72px;
}

.card-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

kbd {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Stats Section */
.stats-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-group {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  margin-top: 2px;
}

.stat-val.muted {
  color: var(--text-secondary);
}

.stat-divider {
  height: 1px;
  background: var(--border-subtle);
}

/* ==========================================================================
   3. BOARD COLUMN (CENTERSTAGE)
   ========================================================================== */

.col-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.board-frame {
  position: relative;
  background: #0c0d10;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

#board-canvas {
  display: block;
  width: 300px;
  height: 660px;
  aspect-ratio: 10 / 22;
}

.keybar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 4px;
}

/* ==========================================================================
   4. MODALS & OVERLAYS
   ========================================================================== */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  padding: 24px 20px;
  width: 100%;
  max-width: 250px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

.modal h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.modal p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 18px;
}

.btn-primary {
  width: 100%;
  background: #ffffff;
  color: #09090b;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: #e4e4e7;
}

.btn-primary.full-width {
  width: 100%;
}

.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gameover-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* ==========================================================================
   5. RIGHT COLUMN: NEXT & AI CONTROLS
   ========================================================================== */

.next-stack {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.next-stack canvas {
  width: 58px;
  height: 58px;
}

/* AI Assistant Card */
.ai-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Segmented Tab Switcher */
.tab-bar {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tab-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tab-view.hidden {
  display: none !important;
}

/* Status Row */
.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

.status-dot.idle {
  background: var(--text-muted);
}

.status-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Prompt Box */
.prompt-box {
  display: flex;
  gap: 6px;
}

.prompt-box input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.prompt-box input:focus {
  border-color: var(--border-focus);
}

.prompt-box input::placeholder {
  color: var(--text-muted);
}

.btn-action {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action:hover {
  background: var(--border-subtle);
}

/* Suggestion Chips */
.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 3px 9px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.preset-chip:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.preset-chip.active {
  background: #27272a;
  border-color: #52525b;
  color: #ffffff;
}

/* Live Stream / Output Box */
.stream-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 72px;
  max-height: 105px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.stream-content {
  font-family: var(--font-sans);
}

.stream-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  white-space: pre-wrap;
  color: #cbd5e1;
  word-break: break-all;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.thought-bubble {
  border-left: 2px solid var(--border-medium);
  padding-left: 8px;
}

.thought-quote {
  color: var(--text-main);
  font-size: 0.72rem;
}

.thought-meta {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Active Rules List */
.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.btn-sub-reset {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
}

.btn-sub-reset:hover {
  color: var(--accent-red);
}

.active-mods-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 80px;
  overflow-y: auto;
}

.empty-mods-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 0;
}

.mod-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.mod-item-name {
  color: var(--text-main);
}

.mod-item-actions {
  display: flex;
  gap: 4px;
}

.btn-mod-toggle {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
}

.btn-mod-toggle.off {
  color: var(--text-muted);
}

.btn-mod-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 2px;
}

.btn-mod-delete:hover {
  color: var(--accent-red);
}

/* Subtle Checkbox */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 4px;
}

.toggle-row input {
  accent-color: var(--accent-purple);
}

/* Autoplay View Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.range-slider {
  width: 100%;
  accent-color: #ffffff;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  cursor: pointer;
}

.autoplay-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* WebGPU Compute Engine Controls */
.backend-badge {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.backend-badge.active-webgpu {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.backend-badge.active-litert {
  background: rgba(6, 182, 212, 0.12);
  color: #22d3ee;
  border-color: rgba(6, 182, 212, 0.3);
}

.backend-badge.active-fallback {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.backend-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.backend-select:focus {
  border-color: var(--border-focus);
}

.webgpu-load-box {
  background: var(--bg-input);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 6px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.load-text-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: #c084fc;
  font-family: var(--font-mono);
}

.progress-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #06b6d4);
  transition: width 0.2s ease;
}

/* ==========================================================================
   6. MOBILE TOUCH CONTROLS
   ========================================================================== */

.touch-controls {
  display: none;
  width: 100%;
  max-width: 480px;
  margin: 12px auto 0;
  padding: 0 10px;
  box-sizing: border-box;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* Auto-display on touch devices or ?touch=1 */
body.has-touch .touch-controls {
  display: flex;
}

/* Auto-display on mobile screens or touch pointers */
@media (max-width: 820px), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 5px;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 5px;
}

@media (min-width: 400px) {
  .dpad, .action-buttons {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 48px);
    gap: 6px;
  }
}

.touch-spacer {
  pointer-events: none;
  visibility: hidden;
}

.btn-touch {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.btn-touch:active,
.btn-touch.active {
  transform: scale(0.92);
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

/* Distinct Cyberpunk Button Accents */
.btn-drop {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

.btn-hold {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.btn-pause {
  font-size: 0.95rem;
}

.btn-sound {
  font-size: 1.05rem;
}

.btn-sound.btn-off {
  opacity: 0.45;
  filter: grayscale(1);
}

/* ==========================================================================
   7. LOSSLESS 60 FPS RECORDER & GLOBAL MODALS
   ========================================================================== */

.btn-record {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.record-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-red);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn-record.recording {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.btn-record.recording .record-dot {
  animation: record-pulse 1s infinite ease-in-out;
}

@keyframes record-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

.global-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity 0.2s ease;
}

.global-overlay.hidden {
  display: none !important;
}

.record-modal-card {
  max-width: 380px;
  width: 100%;
  text-align: left;
}

.preview-modal-card {
  max-width: 440px;
  width: 100%;
  text-align: left;
}

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

.modal-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

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

.modal-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
}

.record-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.record-option-btn:hover {
  background: var(--bg-card-subtle);
  border-color: var(--border-medium);
}

.record-option-btn.highlight {
  border-color: rgba(192, 132, 252, 0.4);
  background: rgba(192, 132, 252, 0.05);
}

.record-option-btn.highlight:hover {
  border-color: rgba(192, 132, 252, 0.75);
  background: rgba(192, 132, 252, 0.12);
  box-shadow: 0 4px 16px rgba(192, 132, 252, 0.15);
}

.option-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.option-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.option-tag {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--accent-green);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
}

.option-info {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.preview-video-container {
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

#preview-video {
  width: 100%;
  max-height: 220px;
  display: block;
  object-fit: contain;
  background: #09090b;
}

.recording-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px;
}

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

.meta-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.meta-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.mp4-status-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.mp4-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-purple);
  animation: record-pulse 1.2s infinite ease-in-out;
}

.mp4-status-box.ready {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
  color: #86efac;
}

.mp4-status-box.ready .mp4-pulse-dot {
  background: var(--accent-green);
  animation: none;
}

.modal-actions-grid {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   1v1 BATTLE ARENA & TRASH TALK STYLES
   ========================================================================== */

/* ==========================================================================
   10. 1v1 ARENA MODE - RADICAL SIMPLICITY
   ========================================================================== */

.arena-mode {
  overflow-x: hidden;
  background: var(--bg-app);
  padding: 12px 16px 20px;
}

.arena-mode .app-header {
  max-width: 680px;
  margin-bottom: 12px;
  width: 100%;
}

@media (max-width: 600px) {
  .app-header {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 0 2px;
    margin-bottom: 8px;
  }
  
  .brand {
    gap: 6px;
  }
  
  .brand-title {
    font-size: 1.05rem;
  }
  
  .header-actions {
    gap: 6px;
  }
  
  .btn-ghost, .btn-record {
    padding: 4px 9px;
    font-size: 0.72rem;
  }
  
  .match-scoreboard {
    order: 3;
    width: 100%;
    justify-content: center;
    padding: 4px 12px;
    font-size: 0.75rem;
  }

  .gemma-trash-bubble {
    padding: 6px 12px;
    gap: 8px;
    border-radius: 10px;
    min-height: 36px;
  }
  
  .trash-avatar {
    font-size: 1.0rem;
  }
  
  .trash-bubble-body {
    font-size: 0.74rem;
    line-height: 1.3;
  }
}

/* Match Scoreboard */
.match-scoreboard {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 16px;
  border-radius: 9999px;
  color: var(--text-secondary);
}

.score-player {
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-gemma {
  color: #c084fc;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-digit {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.score-divider {
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.8rem;
  margin: 0 1px;
}

.match-timer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* Record Button */
.btn-record {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f4f4f5;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-record:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-record .record-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  transition: all 0.2s ease;
}

.btn-record.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.btn-record.recording .record-dot {
  box-shadow: 0 0 8px #ef4444;
  animation: pulse-rec 1s infinite alternate;
}

@keyframes pulse-rec {
  from { opacity: 0.4; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1.15); }
}

/* Arena Stage (Radical Simplicity & Balanced Symmetry) */
.arena-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  max-width: 680px;
}

/* Gemma Trash Talk Speech Bubble Banner */
.trash-talk-banner {
  width: 100%;
  display: flex;
  justify-content: center;
}

.gemma-trash-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(20, 18, 28, 0.95);
  border: 1px solid rgba(192, 132, 252, 0.35);
  border-radius: 9999px;
  padding: 8px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 16px rgba(192, 132, 252, 0.08);
  min-height: 42px;
}

.trash-avatar {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.trash-bubble-body {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  color: #f8fafc;
  font-style: italic;
}

/* Symmetrical Dual Boards Container */
.arena-boards {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(6px, 2.5vw, 28px);
  width: 100%;
  max-width: 680px;
}

.arena-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  max-width: 270px;
  gap: 6px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 2px;
  padding: 0 2px;
}

.board-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #38bdf8;
  text-transform: uppercase;
}

.board-label.gemma-label {
  color: #c084fc;
}

.score-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
}

.score-badge.gemma-score-badge {
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
  border-color: rgba(192, 132, 252, 0.25);
}

.score-badge.badge-pop {
  animation: badge-pop 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.score-badge.gemma-score-badge.badge-pop {
  animation: gemma-badge-pop 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badge-pop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(56, 189, 248, 0);
  }
  40% {
    transform: scale(1.22);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.65);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(56, 189, 248, 0);
    filter: brightness(1);
  }
}

@keyframes gemma-badge-pop {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(192, 132, 252, 0);
  }
  40% {
    transform: scale(1.22);
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.65);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(192, 132, 252, 0);
    filter: brightness(1);
  }
}

/* Symmetrical Footer Cards Under Boards */
.board-footer-card {
  width: 100%;
  background: rgba(18, 20, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 52px;
  box-sizing: border-box;
}

.player-footer-card {
  border-color: rgba(56, 189, 248, 0.2);
}

.gemma-footer-card {
  border-color: rgba(192, 132, 252, 0.25);
  background: rgba(22, 18, 32, 0.95);
}

.card-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.caption-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.caption-dot.cyan-dot {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.caption-dot.purple-dot {
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
}

.caption-dot.pulse {
  animation: pulse-dot 1.4s ease-in-out infinite alternate;
}

@keyframes pulse-dot {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 10px #c084fc; }
}

.thought-latency {
  margin-left: auto;
  font-size: 0.60rem;
  color: #a855f7;
  font-weight: 600;
}

.controls-guide-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.controls-guide-text kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.65rem;
  color: #f1f5f9;
  font-family: var(--font-mono);
}

.gemma-thought-text {
  font-size: 0.73rem;
  font-style: italic;
  line-height: 1.35;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease;
}

.gemma-thought-text.evaluating {
  opacity: 0.65;
}

.board-frame {
  position: relative;
  width: 100%;
  max-width: 270px;
  aspect-ratio: 10 / 22;
  height: auto;
  background: #0e0f14;
  border-radius: clamp(6px, 1.5vw, 12px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.2s ease;
}

.board-frame.player-frame {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 8px 30px rgba(56, 189, 248, 0.1);
}

.board-frame.gemma-frame {
  border-color: rgba(192, 132, 252, 0.35);
  box-shadow: 0 8px 30px rgba(192, 132, 252, 0.1);
}

/* Screen Shake & Line Clear Visual Flourishes */
@keyframes screen-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-4px, 3px, 0); }
  30% { transform: translate3d(4px, -3px, 0); }
  45% { transform: translate3d(-3px, -2px, 0); }
  60% { transform: translate3d(3px, 2px, 0); }
  75% { transform: translate3d(-2px, 1px, 0); }
  90% { transform: translate3d(1px, -1px, 0); }
}

.board-frame.screen-shake,
.screen-shake {
  animation: screen-shake 0.25s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes board-clear-pulse {
  0% { box-shadow: 0 0 0 rgba(0, 229, 255, 0); }
  50% { box-shadow: 0 0 24px rgba(0, 229, 255, 0.45); }
  100% { box-shadow: 0 0 0 rgba(0, 229, 255, 0); }
}

.board-frame.line-clear-glow {
  animation: board-clear-pulse 0.35s ease-out;
}

#board-canvas,
#gemma-board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
}

#gemma-board-canvas.gemma-inactive {
  filter: grayscale(85%) brightness(0.32);
  opacity: 0.35;
  transition: filter 0.4s ease, opacity 0.4s ease;
}

/* ==========================================================================
   GEMMA BOARD OVERLAY & BANNER (SOLO PRACTICE / LOADING STATES)
   ========================================================================== */

.gemma-board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 10, 15, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  z-index: 40;
  text-align: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.gemma-board-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gemma-overlay-card {
  width: 100%;
  max-width: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(18, 19, 26, 0.78);
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 12px;
  padding: 16px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.gemma-overlay-card.card-offline {
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(245, 158, 11, 0.1);
}

.gemma-overlay-card.card-loading {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 24px rgba(168, 85, 247, 0.15);
}

.gemma-overlay-card.card-ready {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 24px rgba(34, 197, 94, 0.15);
}

.gemma-overlay-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gemma-overlay-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.gemma-overlay-badge.badge-loading {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}

.gemma-overlay-badge.badge-ready {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

.gemma-overlay-chip {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gemma-overlay-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin: 2px 0;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.4));
}

.gemma-overlay-card.card-loading .gemma-overlay-icon {
  filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.5));
  animation: pulse-icon 1.8s infinite ease-in-out;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.85; }
}

.gemma-overlay-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.25;
}

.gemma-overlay-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.gemma-overlay-progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0;
}

.gemma-overlay-progress-container.hidden {
  display: none !important;
}

.gemma-overlay-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
}

.gemma-overlay-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #06b6d4);
  border-radius: 9999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

.gemma-overlay-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.gemma-overlay-callout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  margin-top: 2px;
}

.gemma-overlay-callout .callout-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.gemma-overlay-callout .callout-text {
  font-size: 0.65rem;
  color: #e0f2fe;
  line-height: 1.35;
}

@media (max-width: 600px) {
  .arena-stage {
    padding: 0 4px;
    gap: 8px;
  }

  .board-label {
    font-size: 0.64rem;
  }

  .score-badge {
    font-size: 0.58rem;
    padding: 1px 4px;
  }

  .player-footer-card .controls-guide-text {
    font-size: 0.62rem;
  }

  .player-footer-card .controls-guide-text kbd {
    padding: 0 3px;
    font-size: 0.58rem;
  }

  .board-footer-card {
    padding: 5px 8px;
    min-height: 38px;
  }

  .card-caption {
    font-size: 0.55rem;
  }

  .gemma-thought-text {
    font-size: 0.65rem;
  }

  #start-overlay,
  #pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
  }

  .gemma-board-overlay {
    padding: 8px 4px;
  }

  .gemma-overlay-card {
    padding: 10px 8px;
    gap: 6px;
    border-radius: 8px;
  }

  .gemma-overlay-icon {
    font-size: 1.35rem;
    margin: 0;
  }

  .gemma-overlay-title {
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .gemma-overlay-desc {
    font-size: 0.60rem;
    line-height: 1.3;
  }

  .gemma-overlay-badge {
    font-size: 0.52rem;
    padding: 2px 6px;
  }

  .gemma-overlay-chip {
    font-size: 0.50rem;
    padding: 1px 4px;
  }

  .gemma-overlay-callout {
    padding: 5px 6px;
    gap: 5px;
    border-radius: 6px;
  }

  .gemma-overlay-callout .callout-icon {
    font-size: 0.85rem;
  }

  .gemma-overlay-callout .callout-text {
    font-size: 0.55rem;
    line-height: 1.25;
  }
}

@media (max-height: 520px) {
  body {
    padding: 4px 8px 8px;
  }

  .arena-boards {
    gap: 12px;
  }

  .arena-col {
    width: auto;
    flex: 0 0 auto;
  }

  .board-frame {
    height: min(280px, 64vh);
    width: auto;
    aspect-ratio: 10 / 22;
  }

  .board-footer-card {
    display: none;
  }
}

/* Clean Overlays & Modals */
.clean-start-modal {
  text-align: center;
  max-width: 280px;
  padding: 22px 18px;
}

.clean-modal {
  text-align: center;
  max-width: 260px;
  padding: 24px 20px;
}

.clean-start-modal h2,
.clean-modal h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 6px;
}

.clean-start-modal p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.4;
}

.clean-start-modal .btn-primary {
  width: 100%;
  padding: 10px 18px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* Match KO Winner Overlay */
.match-modal-card {
  max-width: 400px;
  width: 100%;
  text-align: center;
  padding: 24px 20px;
  background: rgba(14, 16, 24, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(192, 132, 252, 0.12);
  box-sizing: border-box;
}

.match-winner-banner {
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  transition: all 0.3s ease;
}

/* Glassmorphism Post-Match Outcome Statistics Card (Feature 13 / R4) */
.match-stats-card {
  background: rgba(22, 25, 37, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}

.match-stats-header {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.match-stats-header::after {
  content: "1v1 BATTLE";
  font-size: 0.58rem;
  font-weight: 700;
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(192, 132, 252, 0.25);
  letter-spacing: 0.04em;
}

.match-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.match-stat-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.2s ease;
  min-width: 0;
}

.match-stat-cell:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.match-stat-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #71717a);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.match-stat-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.match-stat-cell.duration .match-stat-value {
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.match-stat-cell.score .match-stat-value {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
}

.match-stat-cell.p-attacks .match-stat-value {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.35);
}

.match-stat-cell.g-attacks .match-stat-value {
  color: #f87171;
  text-shadow: 0 0 10px rgba(248, 113, 113, 0.35);
}

@keyframes gold-victory-pulse {
  0%, 100% {
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.35), inset 0 0 12px rgba(245, 158, 11, 0.2);
    transform: scale(1);
  }
  50% {
    border-color: rgba(251, 191, 36, 1);
    box-shadow: 0 0 35px rgba(251, 191, 36, 0.65), inset 0 0 20px rgba(251, 191, 36, 0.35);
    transform: scale(1.02);
  }
}

@keyframes red-defeat-pulse {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35), inset 0 0 12px rgba(239, 68, 68, 0.2);
    transform: scale(1);
  }
  50% {
    border-color: rgba(244, 63, 94, 1);
    box-shadow: 0 0 35px rgba(244, 63, 94, 0.65), inset 0 0 20px rgba(244, 63, 94, 0.35);
    transform: scale(1.02);
  }
}

.match-winner-banner.player-won {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(34, 197, 94, 0.2) 100%);
  border: 2px solid #f59e0b;
  color: #fbbf24;
  animation: gold-victory-pulse 2s infinite ease-in-out;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.match-winner-banner.gemma-won {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(136, 19, 55, 0.25) 100%);
  border: 2px solid #ef4444;
  color: #f87171;
  animation: red-defeat-pulse 2s infinite ease-in-out;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.match-winner-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

.post-match-roast-box {
  background: rgba(18, 20, 29, 0.85);
  border: 1px solid rgba(192, 132, 252, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  text-align: center;
}

.roast-quote {
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.45;
  color: #f8fafc;
  margin: 0;
}

.modal-actions-grid {
  display: flex;
  gap: 10px;
}

.modal-actions-grid button,
.modal-actions-grid a {
  flex: 1;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 1-Click Glowing Save & Web Share Actions */
.btn-download-glow {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #7c3aed 100%) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 1px solid rgba(147, 197, 253, 0.6) !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.btn-download-glow:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.75), inset 0 1px 2px rgba(255, 255, 255, 0.5) !important;
  border-color: #93c5fd !important;
}

.btn-share-glow {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(236, 72, 153, 0.25) 100%) !important;
  color: #f3e8ff !important;
  font-weight: 600 !important;
  border: 1px solid rgba(216, 180, 254, 0.4) !important;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.3) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.btn-share-glow:hover {
  transform: translateY(-1px) scale(1.02);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.4) 0%, rgba(236, 72, 153, 0.4) 100%) !important;
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.6) !important;
  border-color: #d8b4fe !important;
}

.match-modal-actions {
  flex-wrap: wrap;
}

/* ==========================================================================
   WebGPU Model Loading & Caching Progress Card
   ========================================================================== */
.webgpu-model-card {
  background: rgba(18, 18, 22, 0.95);
  border: 1px solid rgba(192, 132, 252, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.model-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.model-badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-gpu-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
  display: inline-block;
}

.model-gpu-dot.dot-ready {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.model-gpu-dot.dot-downloading {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.model-gpu-dot.dot-warning {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.model-name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.model-pill {
  font-family: var(--font-mono);
  font-size: 0.60rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(192, 132, 252, 0.15);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.model-pill.pill-ready {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.35);
}

.model-pill.pill-downloading {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.model-pill.pill-compiling {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}

.model-pill.pill-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.model-progress-container {
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: #222226;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #c084fc, #38bdf8);
  transition: width 0.2s ease;
  border-radius: 2px;
}

.progress-fill.fill-ready {
  background: #22c55e;
}

.progress-fill.fill-compiling {
  background: #fbbf24;
}

.progress-fill.fill-warning {
  background: #f59e0b;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-secondary);
}

.model-action-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: 6px;
}

.model-device-info {
  font-size: 0.60rem;
  color: var(--text-muted);
  line-height: 1.35;
  font-family: var(--font-sans);
  text-align: left;
}

.btn-retry-webgpu {
  align-self: flex-start;
  background: rgba(192, 132, 252, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.35);
  color: #c084fc;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-retry-webgpu:hover {
  background: rgba(192, 132, 252, 0.3);
  color: #ffffff;
  border-color: rgba(192, 132, 252, 0.5);
}

.badge.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.badge.badge-downloading {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.badge.badge-ready {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.35);
}

.gemma-backend-tag {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(192, 132, 252, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   WebGPU Requirement Notice Modal & Desktop Guidance (Milestone 2 / R2)
   ========================================================================== */
.webgpu-notice-modal {
  margin-top: 10px;
  padding: 10px 10px;
  background: rgba(26, 20, 14, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  text-align: left;
  box-sizing: border-box;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(245, 158, 11, 0.15);
}

.webgpu-notice-modal.hidden {
  display: none !important;
}

.webgpu-notice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.notice-icon {
  font-size: 0.85rem;
  color: #fbbf24;
  filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
}

.notice-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fbbf24;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.webgpu-notice-desc {
  font-size: 0.62rem;
  color: var(--text-secondary);
  line-height: 1.35;
  margin: 0 0 8px 0;
}

.browser-guidance-section {
  margin-bottom: 8px;
}

.browser-guidance-heading {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
  font-weight: 600;
}

.browser-badges-row {
  display: flex;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.browser-badge {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 4px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.browser-badge.badge-chrome {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

.browser-badge.badge-chrome:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.7);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.browser-badge.badge-edge {
  background: rgba(192, 132, 252, 0.1);
  border: 1px solid rgba(192, 132, 252, 0.35);
  color: #c084fc;
}

.browser-badge.badge-edge:hover {
  background: rgba(192, 132, 252, 0.2);
  border-color: rgba(192, 132, 252, 0.7);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
}

.browser-badge .badge-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
}

.browser-badge .badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.webgpu-notice-actions {
  margin-top: 6px;
}

.btn-spectator {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.2), rgba(56, 189, 248, 0.15));
  border: 1px solid rgba(192, 132, 252, 0.45);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-spectator:hover {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.35), rgba(56, 189, 248, 0.3));
  border-color: #c084fc;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.3);
}

/* In-Game Spectator HUD Banner */
.spectator-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  width: calc(100% - 16px);
  margin: 0 auto 8px auto;
  padding: 6px 12px;
  background: rgba(15, 17, 26, 0.92);
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(192, 132, 252, 0.2);
  box-sizing: border-box;
  z-index: 80;
}

.spectator-banner.hidden {
  display: none !important;
}

.spectator-live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #c084fc;
}

.spectator-live-indicator .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c084fc;
  box-shadow: 0 0 8px #c084fc;
}

.spectator-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-takeover {
  padding: 4px 10px;
  background: #38bdf8;
  color: #09090b;
  border: none;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-takeover:hover {
  background: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.btn-exit-spec {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-exit-spec:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.badge-spectator {
  background: rgba(192, 132, 252, 0.2) !important;
  border-color: #c084fc !important;
  color: #c084fc !important;
}

@media (max-width: 380px) {
  .browser-badges-row {
    flex-direction: column;
    gap: 4px;
  }

  .match-modal-card {
    padding: 16px 12px;
  }

  .match-stats-grid {
    gap: 6px;
  }

  .match-stat-cell {
    padding: 6px 4px;
  }

  .match-stat-value {
    font-size: 0.92rem;
  }

  .match-stat-label {
    font-size: 0.56rem;
  }
}

/* Round Countdown Overlay (3, 2, 1, FIGHT!) */
.countdown-overlay,
.round-countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-overlay.hidden,
.round-countdown-overlay.hidden {
  display: none !important;
}

.countdown-text {
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.countdown-text.num-text {
  font-size: clamp(3rem, 8vw, 4.5rem);
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.8), 0 0 40px rgba(245, 158, 11, 0.4);
}

.countdown-text.fight-text {
  font-size: clamp(3.2rem, 9vw, 5rem);
  color: #ef4444;
  text-shadow: 0 0 25px rgba(239, 68, 68, 0.9), 0 0 50px rgba(239, 68, 68, 0.5);
}

@keyframes countdown-pulse {
  0% { transform: scale(0.4); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes countdown-pop {
  0% { transform: scale(0.4); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.countdown-text.pop-anim {
  animation: countdown-pulse 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

/* ==========================================================================
   Responsive Viewport Hardening (max-width: 360px and max-width: 320px)
   Zero horizontal overflow protection for ultra-compact mobile viewports
   ========================================================================== */

@media (max-width: 360px) {
  body,
  body.arena-mode {
    padding: 8px 4px 16px;
    box-sizing: border-box;
    max-width: 100vw;
  }

  .arena-stage,
  .arena-boards,
  .app-header {
    padding: 0 4px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .global-overlay {
    padding: 8px 4px;
    box-sizing: border-box;
  }

  .modal,
  .match-modal-card,
  .clean-modal,
  .clean-start-modal,
  .preview-modal-card,
  .record-modal-card {
    padding: 12px 6px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .modal-actions-grid {
    flex-direction: column;
    gap: 6px;
  }

  .touch-controls {
    padding: 0 4px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .dpad,
  .action-buttons {
    gap: 4px;
  }
}

@media (max-width: 320px) {
  body,
  body.arena-mode {
    padding: 6px 2px 12px;
    box-sizing: border-box;
    max-width: 100vw;
  }

  .arena-stage,
  .arena-boards,
  .app-header {
    padding: 0 2px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .global-overlay {
    padding: 4px 2px;
    box-sizing: border-box;
  }

  .modal,
  .match-modal-card,
  .clean-modal,
  .clean-start-modal,
  .preview-modal-card,
  .record-modal-card {
    padding: 10px 4px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .modal-actions-grid {
    flex-direction: column;
    gap: 4px;
  }

  .touch-controls {
    padding: 0 2px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .dpad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 3px;
  }

  .action-buttons {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 3px;
  }

  .arena-boards {
    gap: 4px;
  }
}




