/* CSS Custom Properties */
:root {
  /* Background colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-panel: #131a2e;
  --bg-panel-alpha: rgba(19, 26, 46, 0.85);
  --bg-card: #0d1424;
  --bg-input: #0c1220;
  --bg-hover: #1a2744;
  --bg-header: #111827;

  /* Text colors */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;

  /* Accent colors */
  --accent-cyan: #22d3ee;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-orange: #f97316;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #22d3ee 100%);
  --gradient-accent: linear-gradient(135deg, #22d3ee 0%, #a855f7 100%);

  /* Borders */
  --border-color: #1e293b;
  --border-subtle: #1a2236;
  --border-active: #3b82f6;
  --border-glow: rgba(59, 130, 246, 0.5);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --table-max-height: 600px;
  --scrollframe-height: 600px;
}

/* Base Styles */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at top, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* Card */
.card {
  background: var(--bg-panel-alpha);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
}

/* Typography */
h1 {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 1.75rem;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  margin: 0 0 16px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

h2::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--gradient-primary);
  border-radius: 2px;
}

.sub {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 8px;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

/* Section Labels */
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-color) 0%, transparent 100%);
}

/* Layout Grid */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(280px, 380px) minmax(300px, 500px);
  justify-content: center;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .container { padding: 16px 12px; }
  .card { padding: 16px; border-radius: var(--radius-lg); }
  h1 { font-size: 1.4rem; }
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.03) 0%, transparent 100%);
  padding: 32px 24px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all var(--transition-normal);
  cursor: pointer;
}

@media (max-width: 480px) {
  .dropzone { padding: 24px 16px; min-height: 140px; }
  .dropzone-icon { font-size: 2rem; }
  .dropzone-text { font-size: 0.9rem; }
  .dz-btn { padding: 8px 14px; font-size: 0.85rem; }
}

.dropzone:hover {
  border-color: var(--accent-blue);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
}

.dropzone.dragover {
  border-color: var(--accent-cyan);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.1) 0%, transparent 100%);
  box-shadow: var(--shadow-glow);
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.7;
}

.dropzone-text {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.dropzone-text strong {
  color: var(--accent-cyan);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: var(--accent-blue);
  background: var(--bg-hover);
  box-shadow: none;
}

.ghost-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ghost-btn:hover {
  border-color: var(--accent-blue);
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.dz-btn {
  margin-top: 12px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dz-btn:hover {
  border-color: var(--accent-blue);
  background: var(--bg-hover);
}

/* Panel */
.panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: var(--bg-secondary);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

@media (max-width: 480px) {
  .panel-header { gap: 8px; }
  .panel-title { font-size: 0.85rem; }
  .ghost-btn { padding: 6px 10px; font-size: 0.75rem; }
}

.panel-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Collapsible Panels */
.collapsible-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  overflow: hidden;
}

.collapsible-panel > summary.panel-header {
  cursor: pointer;
  padding: 14px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
  transition: background var(--transition-fast);
  list-style: none;
}

.collapsible-panel > summary.panel-header::-webkit-details-marker {
  display: none;
}

.collapsible-panel > summary.panel-header .panel-title::before {
  content: '▼';
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  display: inline-block;
}

.collapsible-panel:not([open]) > summary.panel-header .panel-title::before {
  transform: rotate(-90deg);
}

.collapsible-panel:not([open]) > summary.panel-header {
  border-bottom: none;
}

.collapsible-panel > summary.panel-header:hover {
  background: var(--bg-hover);
}

.collapsible-panel > .panel-body {
  padding: 16px 20px;
}

.collapsible-panel > .panel-body.awards-grid {
  padding: 20px;
}

.collapsible-panel > .panel-body.replays-grid {
  padding: 16px;
}

/* Checkboxes */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .checkbox-group { grid-template-columns: 1fr 1fr; gap: 6px; }
  .checkbox { padding: 8px 10px; font-size: 0.8rem; }
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
}

.checkbox:hover {
  border-color: var(--border-color);
  background: var(--bg-hover);
}

.checkbox:has(input:checked) {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.checkbox input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.checkbox input[type="checkbox"]:checked {
  background: var(--gradient-primary);
  border-color: transparent;
}

.checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* File List */
.file-list {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 16px;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.file-list-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  max-height: 120px;
  overflow-y: auto;
}

.chip {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(168, 85, 247, 0.1) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--text-secondary);
}

.chip span {
  color: var(--accent-blue);
  font-weight: 600;
}

.chip strong {
  color: var(--text-primary);
  font-weight: 500;
}

.chip .remove {
  background: transparent;
  border: none;
  color: var(--accent-red);
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.chip .remove:hover {
  opacity: 1;
}

/* Select */
.select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select:hover {
  border-color: var(--accent-blue);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

/* Ensure sticky cells maintain background on hover */
tbody tr:hover td:first-child {
  background: var(--bg-hover);
}

table.compact th,
table.compact td {
  padding: 8px 10px;
}

table.compact thead th {
  position: sticky;
  top: 0;
  background: var(--bg-header);
  z-index: 10;
}

/* First column header - sticky both ways, highest z-index */
table.compact thead th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  background: var(--bg-header);
  z-index: 20;
  box-shadow: 1px 0 0 var(--border-subtle);
}

/* First column body cells - sticky left */
table.compact tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-secondary);
  z-index: 5;
  box-shadow: 1px 0 0 var(--border-subtle);
}

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

th.sortable:hover {
  color: var(--accent-cyan);
}

th.sortable.active {
  color: var(--accent-blue);
}

th[title] {
  cursor: help;
}
th.sortable[title] {
  /* Sortable headers stay click-to-sort; tooltip still appears on hover. */
  cursor: pointer;
}

/* Results */
.results-panel {
  margin-top: 24px;
}

.results-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .results-grid { gap: 12px; }
  details.result > summary { padding: 12px 14px; font-size: 0.9rem; }
  details.result .content { padding: 12px; }
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpi { padding: 10px; }
  .kpi .label { font-size: 0.6rem; }
  .kpi .val { font-size: 1.2rem; }
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.kpi:nth-child(1)::before { background: linear-gradient(90deg, #ef4444, #f97316); }
.kpi:nth-child(2)::before { background: linear-gradient(90deg, #f59e0b, #eab308); }
.kpi:nth-child(3)::before { background: linear-gradient(90deg, #22c55e, #10b981); }
.kpi:nth-child(4)::before { background: linear-gradient(90deg, #14b8a6, #06b6d4); }
.kpi:nth-child(5)::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.kpi:nth-child(6)::before { background: linear-gradient(90deg, #8b5cf6, #a855f7); }
.kpi:nth-child(7)::before { background: linear-gradient(90deg, #d946ef, #ec4899); }
.kpi:nth-child(8)::before { background: linear-gradient(90deg, #f43f5e, #e11d48); }
.kpi:nth-child(9)::before { background: linear-gradient(90deg, #64748b, #475569); }

.kpi .label {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi .val {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 4px;
  color: var(--text-primary);
}

/* Result Details */
details.result {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

details.result > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  background: var(--bg-card);
  border-bottom: 1px solid transparent;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}

details.result > summary::-webkit-details-marker {
  display: none;
}

details.result > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-right: 10px;
  transition: transform var(--transition-fast);
}

details.result[open] > summary::before {
  transform: rotate(90deg);
}

details.result[open] > summary {
  background: var(--bg-hover);
  border-bottom-color: var(--border-color);
}

details.result > summary:hover {
  background: var(--bg-hover);
}

.section-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  margin-left: 4px;
}

details.result .content {
  padding: 16px;
  overflow: hidden;
}

/* Scrollframe */
.scrollframe {
  overflow: auto;
  max-height: var(--scrollframe-height);
  border-radius: var(--radius-sm);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
  .scrollframe { max-height: 400px; }
  th, td { padding: 8px 8px; font-size: 0.8rem; }
  .icon-name img { width: 36px; height: 36px; }
  .icon-name { gap: 6px; }
}

/* Wide Sortable Tables */
.wide-sortable {
  width: 100%;
  border-collapse: collapse;
}

.wide-sortable thead th {
  position: sticky;
  top: 0;
  background: var(--bg-header);
  z-index: 10;
}

/* First column header - sticky both ways, highest z-index */
.wide-sortable thead th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  background: var(--bg-header);
  z-index: 20;
  box-shadow: 1px 0 0 var(--border-subtle);
}

/* First column body cells - sticky left */
.wide-sortable tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-secondary);
  z-index: 5;
  box-shadow: 1px 0 0 var(--border-subtle);
}

/* Icon Name Cell */
.icon-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-name img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: auto;
  position: static;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
}

.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.2s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--accent-red);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-of-type {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* Publish Messages */
.publish-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-top: 16px;
}

.publish-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-top: 16px;
}

.publish-success a {
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===========================================
   MOBILE-SPECIFIC REDESIGN
   =========================================== */
@media (max-width: 640px) {
  /* Root adjustments for mobile */
  :root {
    --table-max-height: 350px;
    --scrollframe-height: 350px;
  }

  /* Full-width container with minimal padding */
  .container {
    padding: 12px 8px;
    max-width: 100%;
  }

  /* Simplified card */
  .card {
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    border-left: none;
    border-right: none;
    border-radius: 0;
    margin: 0 -8px;
  }

  /* Header - stacked and centered */
  .card > header {
    flex-direction: column;
    align-items: stretch !important;
    text-align: center;
    gap: 12px;
    margin-bottom: 16px !important;
  }

  .card > header > div {
    order: 1;
  }

  .card > header > a.ghost-btn {
    order: 0;
    align-self: flex-start;
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  /* Typography adjustments */
  h1 {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .sub {
    font-size: 0.85rem;
    margin-bottom: 16px;
  }

  /* Hide section labels decorations */
  .section-label::after {
    display: none;
  }

  /* Compact dropzone */
  .dropzone {
    min-height: 100px;
    padding: 16px 12px;
    border-radius: var(--radius-md);
  }

  .dropzone-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
  }

  .dropzone-text {
    font-size: 0.85rem;
  }

  .dropzone > div > div:nth-child(3) {
    display: none; /* Hide ".html or .txt files" hint */
  }

  .dz-btn {
    margin-top: 8px;
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  /* Compact file list */
  .file-list {
    padding: 12px;
    margin-top: 12px;
  }

  .file-list-header {
    margin-bottom: 8px;
  }

  .file-list-title {
    font-size: 0.8rem;
  }

  .chips {
    gap: 6px;
  }

  .chip {
    padding: 4px 10px;
    font-size: 0.75rem;
    gap: 6px;
  }

  .hint {
    font-size: 0.7rem;
    margin-top: 6px;
  }

  /* Panel adjustments */
  .panel {
    padding: 14px 12px;
    border-radius: var(--radius-md);
  }

  .panel-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    gap: 8px;
  }

  .panel-title {
    font-size: 0.85rem;
  }

  /* Checkbox grid - horizontal scroll */
  .checkbox-group {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    margin: 0 -12px 16px -12px;
    padding: 4px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .checkbox-group::-webkit-scrollbar {
    display: none;
  }

  .checkbox {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.8rem;
    gap: 6px;
    white-space: nowrap;
  }

  .checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
  }

  .checkbox input[type="checkbox"]:checked::after {
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
  }

  /* Full-width stacked buttons */
  .panel > div:last-child:has(.btn) {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.9rem;
    justify-content: center;
  }

  .btn-secondary {
    order: 1;
  }

  /* Results panel */
  .results-panel {
    margin-top: 16px;
  }

  #results .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .results-toolbar {
    justify-content: center;
    margin-bottom: 0;
  }

  .ghost-btn {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  /* KPIs - horizontal scroll strip */
  .kpis {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    margin: 0 -12px 16px -12px;
    padding: 4px 12px 8px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .kpis::-webkit-scrollbar {
    display: none;
  }

  .kpi {
    flex-shrink: 0;
    min-width: 90px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
  }

  .kpi .label {
    font-size: 0.6rem;
  }

  .kpi .val {
    font-size: 1.1rem;
    margin-top: 2px;
  }

  /* Result sections */
  .results-grid {
    gap: 10px;
  }

  details.result {
    border-radius: var(--radius-md);
  }

  details.result > summary {
    padding: 12px;
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  details.result > summary::before {
    border-left-width: 4px;
    border-top-width: 3px;
    border-bottom-width: 3px;
    margin-right: 8px;
  }

  .section-count {
    font-size: 0.75rem;
  }

  /* Move view dropdown below title on mobile */
  details.result > summary > div[style*="margin-left:auto"] {
    width: 100%;
    margin-left: 0 !important;
    margin-top: 4px;
    justify-content: flex-start;
  }

  details.result .content {
    padding: 10px;
  }

  /* Table adjustments for mobile */
  .scrollframe {
    border-radius: 0;
  }

  table.compact th,
  table.compact td,
  .wide-sortable th,
  .wide-sortable td {
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  th {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
  }

  /* Smaller sprites on mobile */
  .icon-name {
    gap: 6px;
  }

  .icon-name img {
    width: 32px;
    height: 32px;
  }

  .icon-name span {
    font-size: 0.75rem;
    word-break: break-word;
  }

  /* Name column adjustments for mobile */
  .wide-sortable thead th:first-child,
  .wide-sortable tbody td:first-child,
  table.compact thead th:first-child,
  table.compact tbody td:first-child {
    min-width: 140px;
    max-width: 160px;
  }

  /* Clean text wrapping in name cells */
  .icon-name {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .icon-name span {
    font-size: 0.7rem;
    line-height: 1.3;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Modal - nearly fullscreen */
  .modal {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 10;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    background: var(--bg-panel);
  }

  .form-input {
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Empty state */
  .empty {
    padding: 20px 16px;
    font-size: 0.85rem;
  }

  .empty > div:first-child {
    font-size: 1.5rem !important;
  }

  /* Loading state */
  .loading {
    padding: 24px;
    font-size: 0.85rem;
  }

  .loading::before {
    width: 16px;
    height: 16px;
  }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 380px) {
  h1 {
    font-size: 1.15rem;
  }

  .checkbox {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .kpi {
    min-width: 80px;
    padding: 8px 10px;
  }

  .kpi .val {
    font-size: 1rem;
  }

  .icon-name img {
    width: 28px;
    height: 28px;
  }

  .wide-sortable thead th:first-child,
  .wide-sortable td:first-child {
    max-width: 100px;
    min-width: 80px;
  }
}

/* ===========================================
   COMPACT CONTROLS LAYOUT
   =========================================== */

/* Collapsible controls section */
.controls-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  margin-bottom: 0;
}

.controls-section[open] {
  margin-bottom: 0;
}

.controls-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  list-style: none;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.controls-section[open] .controls-toggle {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid var(--border-subtle);
}

.controls-toggle::-webkit-details-marker {
  display: none;
}

.controls-toggle:hover {
  background: var(--bg-hover);
}

.toggle-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.controls-content {
  padding: 16px;
}

/* Upload row - dropzone and files side by side */
.upload-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.upload-row > * {
  flex: 1;
}

/* Compact dropzone */
.dropzone-compact {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.03) 0%, transparent 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all var(--transition-normal);
  cursor: pointer;
  min-height: 100px;
}

.dropzone-compact:hover {
  border-color: var(--accent-blue);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
}

.dropzone-compact.dragover {
  border-color: var(--accent-cyan);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.1) 0%, transparent 100%);
  box-shadow: var(--shadow-glow);
}

.dropzone-compact .dropzone-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
  opacity: 0.7;
}

.dropzone-compact div {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dropzone-compact strong {
  color: var(--accent-cyan);
}

/* Link-styled button */
.link-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  padding: 0;
}

.link-btn:hover {
  color: var(--accent-cyan);
}

/* Compact files panel */
.files-compact {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.files-compact .file-list-header {
  margin-bottom: 8px;
}

.files-compact .file-list-title {
  font-size: 0.8rem;
}

.files-compact .chips {
  flex: 1;
  max-height: 80px;
  min-height: 40px;
}

/* Options row - checkboxes and buttons inline */
.options-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Compact checkbox group - wrapping flex */
.checkbox-group-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

/* Compact checkbox styling */
.checkbox-compact {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.checkbox-compact:hover {
  border-color: var(--border-color);
  background: var(--bg-hover);
}

.checkbox-compact:has(input:checked) {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.checkbox-compact input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.checkbox-compact input[type="checkbox"]:checked {
  background: var(--gradient-primary);
  border-color: transparent;
}

.checkbox-compact input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Action buttons group */
.action-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-buttons .btn {
  padding: 10px 16px;
}

.action-buttons .btn-secondary {
  padding: 10px 12px;
}

/* Mobile adjustments for compact controls */
@media (max-width: 768px) {
  .upload-row {
    flex-direction: column;
    gap: 12px;
  }

  .options-row {
    flex-direction: column;
    gap: 12px;
  }

  .checkbox-group-compact {
    /* Horizontal scroll on mobile */
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .checkbox-group-compact::-webkit-scrollbar {
    display: none;
  }

  .checkbox-compact {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons .btn {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .controls-toggle {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .controls-content {
    padding: 12px;
  }

  .dropzone-compact {
    min-height: 80px;
    padding: 12px;
  }

  .dropzone-compact .dropzone-icon {
    font-size: 1.25rem;
  }

  .files-compact {
    padding: 10px;
  }

  .checkbox-compact {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .checkbox-compact input[type="checkbox"] {
    width: 12px;
    height: 12px;
  }

  .checkbox-compact input[type="checkbox"]:checked::after {
    left: 2px;
    width: 3px;
    height: 6px;
  }
}

/* ===========================================
   AWARDS CARDS
   =========================================== */
.awards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.award-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.award-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.award-card-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: var(--text-muted);
}

.award-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.award-card-content {
  padding: 16px;
}

.award-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.award-card-winner {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.award-card-stat {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: var(--radius-sm);
  display: inline-block;
}

.award-card-flavor {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
}

.award-card-error {
  color: var(--accent-red);
  font-size: 0.8rem;
  margin-top: 8px;
}

.awards-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.awards-loading::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
  vertical-align: middle;
}

.awards-progress {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  padding: 4px 10px;
  background: rgba(34, 211, 238, 0.1);
  border-radius: var(--radius-sm);
  margin-left: auto;
}

.award-image-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
}

.image-loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@media (max-width: 640px) {
  .awards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .award-card-content {
    padding: 14px;
  }

  .award-card-title {
    font-size: 1rem;
  }
}

/* ===========================================
   REPLAYS SECTION
   =========================================== */
.replays-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding: 16px;
}

.replay-series {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.replay-series-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.replay-series-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.replay-series-games {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
}

.replay-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  text-align: center;
  min-width: 100px;
}

.replay-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
  border-color: var(--accent-blue);
}

.replay-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.replay-card-winner {
  font-size: 0.75rem;
  color: var(--accent-green);
  font-weight: 500;
  margin-bottom: 2px;
}

.replay-card-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.replay-card-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.replay-card-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.replay-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.replay-action-btn:hover {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: var(--bg-hover);
}

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

/* Replay Modal */
.modal-replay {
  max-width: 95vw;
  width: 1200px;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.replay-modal-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
  display: flex;
}

.replay-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

@media (max-width: 768px) {
  .replays-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .replay-series-games {
    gap: 6px;
    padding: 8px;
  }

  .replay-card {
    flex: 1 1 calc(33% - 6px);
    min-width: 70px;
    padding: 6px 8px;
  }

  .modal-replay {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .replay-iframe {
    border-radius: 0;
  }
}
