:root {
  --wii-white: #F5F5F5;
  --wii-blue: #00A1E4;
  --wii-blue-light: #7DD3FC;
  --wii-green: #78C850;
  --wii-gray: #E8E8E8;
  --wii-dark: #2D2D2D;
  --wii-red: #E85050;
  --hex-bg: #0d1117;
  --hex-offset: #ff9800;
  --hex-bytes: #00e5ff;
  --hex-ascii: #78C850;
  --hex-selected: rgba(0,161,228,0.35);
  --hex-match: rgba(255,200,0,0.35);
  --section-header: rgba(59,130,246,0.12);
  --section-cert: rgba(234,179,8,0.10);
  --section-ticket: rgba(168,85,247,0.10);
  --section-tmd: rgba(34,197,94,0.10);
  --section-data: rgba(249,115,22,0.08);
  --section-banner: rgba(6,182,212,0.12);
  --section-audio: rgba(236,72,153,0.12);
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(180deg, #EBF5FF 0%, #F5F5F5 40%, #E8F0FE 100%);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
}

body.dark-mode {
  background: linear-gradient(180deg, #0d1117 0%, #161b22 40%, #0d1117 100%);
  color: #e0e0e0;
}

.drop-zone {
  border: 3px dashed #00A1E4;
  border-radius: 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0,161,228,0.05) 0%, transparent 70%);
  transition: all 0.3s ease;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #78C850;
  box-shadow: 0 0 30px rgba(0,161,228,0.2), inset 0 0 30px rgba(0,161,228,0.05);
  transform: scale(1.01);
}

.drop-zone:hover::before, .drop-zone.drag-over::before {
  background: radial-gradient(circle at center, rgba(0,161,228,0.12) 0%, transparent 70%);
}

.glass-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

body.dark-mode .glass-card {
  background: rgba(22, 27, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body.dark-mode .drop-zone {
  border-color: #0077aa;
}

body.dark-mode .drop-zone:hover {
  border-color: #78C850;
  box-shadow: 0 0 30px rgba(0,161,228,0.3), inset 0 0 30px rgba(0,161,228,0.08);
}

/* Hex Viewer Styles */
.hex-viewer-container {
  font-family: 'JetBrains Mono', monospace;
  background: var(--hex-bg);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.hex-row {
  display: flex;
  align-items: center;
  height: 22px;
  line-height: 22px;
  font-size: 12.5px;
  padding: 0 12px;
  white-space: nowrap;
  cursor: default;
  transition: none;
}

.hex-row:hover {
  background: rgba(255,255,255,0.03);
}

.hex-offset-col {
  color: var(--hex-offset);
  min-width: 80px;
  user-select: none;
  font-weight: 600;
}

.hex-bytes-col {
  color: var(--hex-bytes);
  min-width: 420px;
  letter-spacing: 0.5px;
}

.hex-ascii-col {
  color: var(--hex-ascii);
  min-width: 160px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.06);
}

.hex-byte {
  display: inline;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 2px;
}

.hex-byte:hover {
  background: rgba(255,255,255,0.12);
}

.hex-byte.selected {
  background: var(--hex-selected);
  color: #fff;
}

.hex-byte.match {
  background: var(--hex-match);
  color: #fff;
}

.hex-ascii-char {
  display: inline;
  cursor: pointer;
  border-radius: 1px;
}

.hex-ascii-char:hover {
  background: rgba(255,255,255,0.12);
}

.hex-ascii-char.selected {
  background: var(--hex-selected);
  color: #fff;
}

.hex-ascii-char.match {
  background: var(--hex-match);
  color: #fff;
}

/* Section color coding backgrounds */
.section-header { background: var(--section-header) !important; }
.section-cert { background: var(--section-cert) !important; }
.section-ticket { background: var(--section-ticket) !important; }
.section-tmd { background: var(--section-tmd) !important; }
.section-data { background: var(--section-data) !important; }
.section-banner { background: var(--section-banner) !important; }
.section-audio { background: var(--section-audio) !important; }

/* Minimap */
.hex-minimap {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  border-left: 1px solid rgba(255,255,255,0.06);
}

.hex-minimap-viewport {
  position: absolute;
  left: 2px;
  right: 2px;
  background: rgba(0,161,228,0.3);
  border: 1px solid rgba(0,161,228,0.6);
  border-radius: 2px;
  pointer-events: none;
}

/* Scrollbar for hex viewer */
.hex-scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
}

.hex-scroll-area::-webkit-scrollbar {
  width: 10px;
}

.hex-scroll-area::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}

.hex-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(0,161,228,0.35);
  border-radius: 5px;
}

.hex-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0,161,228,0.55);
}

/* Nav buttons */
.hex-nav-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #aaa;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.hex-nav-btn:hover {
  background: rgba(0,161,228,0.2);
  border-color: rgba(0,161,228,0.4);
  color: #fff;
}

.hex-nav-btn.active {
  background: rgba(0,161,228,0.3);
  border-color: rgba(0,161,228,0.6);
  color: #fff;
}

/* Legend */
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #888;
  margin-right: 10px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* Animations */
@keyframes spin-disc {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-disc {
  animation: spin-disc 3s linear infinite;
}

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

.fade-slide-in {
  animation: fadeSlideIn 0.5s ease forwards;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.loading-shimmer {
  background: linear-gradient(90deg, transparent 25%, rgba(0,161,228,0.15) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes terminalBoot {
  0% { opacity: 0; transform: scaleY(0.01); }
  30% { opacity: 0.5; transform: scaleY(0.3); }
  60% { opacity: 0.8; transform: scaleY(0.8); }
  100% { opacity: 1; transform: scaleY(1); }
}

.terminal-boot {
  animation: terminalBoot 0.6s ease-out forwards;
  transform-origin: top center;
}

.toast-enter {
  animation: fadeSlideIn 0.3s ease forwards;
}

/* Buttons */
.btn-wii {
  background: linear-gradient(135deg, #00A1E4, #0088cc);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,161,228,0.3);
}

.btn-wii:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,161,228,0.4);
}

.btn-green {
  background: linear-gradient(135deg, #78C850, #5ea63a);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(120,200,80,0.3);
}

.btn-green:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(120,200,80,0.4);
}

.btn-magenta {
  background: linear-gradient(135deg, #ec4899, #be185d);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(236,72,153,0.3);
}

.btn-magenta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(236,72,153,0.4);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

.status-valid {
  background: rgba(120, 200, 80, 0.15);
  color: #4a8c2a;
  border: 1px solid rgba(120, 200, 80, 0.3);
}

body.dark-mode .status-valid {
  color: #78C850;
}

.status-invalid {
  background: rgba(232, 80, 80, 0.15);
  color: #c43030;
  border: 1px solid rgba(232, 80, 80, 0.3);
}

body.dark-mode .status-invalid {
  color: #E85050;
}

/* Byte inspector panel */
.byte-inspector {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 10px 16px;
  color: #ccc;
}

.byte-inspector-label {
  color: #666;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.byte-inspector-value {
  color: #00e5ff;
  font-weight: 600;
}

/* Search input */
.hex-search-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 5px 10px;
  color: #eee;
  outline: none;
  transition: border-color 0.2s;
}

.hex-search-input:focus {
  border-color: rgba(0,161,228,0.5);
}

.hex-search-input::placeholder {
  color: #555;
}

/* Banner Player */
.banner-player-wrapper {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,161,228,0.2);
  background: #0a1628;
  box-shadow: 0 0 20px rgba(0,161,228,0.1), inset 0 0 30px rgba(0,0,0,0.3);
}

.banner-player-canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.banner-player-controls {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  gap: 3px;
  z-index: 2;
}

.banner-ctrl-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.5);
  color: #ccc;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
  padding: 0;
  line-height: 1;
}

.banner-ctrl-btn:hover {
  background: rgba(0,161,228,0.3);
  border-color: rgba(0,161,228,0.5);
  color: #fff;
}

.banner-ctrl-btn.active {
  background: rgba(0,161,228,0.25);
  border-color: rgba(0,161,228,0.4);
  color: #00A1E4;
}

.banner-pipeline-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.layout-tag {
  background: rgba(34,197,94,0.12);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.2);
}

.anim-tag {
  background: rgba(234,179,8,0.12);
  color: #eab308;
  border: 1px solid rgba(234,179,8,0.2);
}

.tex-tag {
  background: rgba(168,85,247,0.12);
  color: #a855f7;
  border: 1px solid rgba(168,85,247,0.2);
}

.banner-details-panel {
  border-radius: 8px;
  padding: 10px;
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  max-height: 300px;
  overflow-y: auto;
}

.banner-tex-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.banner-tex-thumb {
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  transition: all 0.15s;
  text-align: center;
  max-width: 80px;
}

.banner-tex-thumb:hover {
  border-color: rgba(0,161,228,0.4);
  transform: scale(1.05);
}

.banner-tex-thumb.selected {
  border-color: rgba(0,161,228,0.7);
  box-shadow: 0 0 8px rgba(0,161,228,0.3);
}

.banner-tex-canvas {
  width: 100%;
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
  display: block;
  margin: 2px auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.banner-tex-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 16px;
  margin: 2px auto;
}

.banner-tex-label {
  font-size: 7px;
  color: #888;
  padding: 1px 3px 3px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes bannerGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(0,161,228,0.1); }
  50% { box-shadow: 0 0 25px rgba(0,161,228,0.25); }
}

.banner-player-wrapper:hover {
  animation: bannerGlow 2s ease-in-out infinite;
  border-color: rgba(0,161,228,0.35);
}

/* Waveform canvas */
.waveform-canvas {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(0,161,228,0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0,161,228,0.5);
}

/* Content table */
.content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.content-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid rgba(0,161,228,0.2);
}

.content-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(128,128,128,0.1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.content-table tr:hover td {
  background: rgba(0,161,228,0.05);
}

.content-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
}

/* Responsive */
@media (max-width: 768px) {
  .hex-bytes-col {
    min-width: 220px;
    font-size: 11px;
  }
  .hex-ascii-col {
    min-width: 80px;
    font-size: 11px;
  }
  .hex-offset-col {
    min-width: 64px;
    font-size: 11px;
  }
  .hex-row {
    font-size: 11px;
    height: 20px;
    line-height: 20px;
  }
}