:root {
  --bg-primary: #0a0c10;
  --bg-secondary: #121620;
  --bg-card: #181d2a;
  --border-color: #262e42;
  --accent-blue: #00d2ff;
  --accent-cyan: #38ef7d;
  --accent-yellow: #f8c034;
  --accent-red: #ff3860;
  --ps-cross: #4d88ff;
  --ps-circle: #ff4d6a;
  --ps-square: #ff77d2;
  --ps-triangle: #32e096;
  --text-main: #e2e8f0;
  --text-muted: #8b9bb4;
  --font-retro: 'Courier New', monospace;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-ui);
  line-height: 1.6;
  overflow-x: hidden;
  padding-bottom: 60px;
}

/* Header & Banner */
header {
  background: linear-gradient(180deg, #161b26 0%, #0d1017 100%);
  border-bottom: 2px solid var(--border-color);
  padding: 1.25rem 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ps-badge {
  background: #000;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 1px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ps-logo-dots {
  display: inline-flex;
  gap: 2px;
}
.ps-logo-dots span:nth-child(1) { color: var(--ps-red, #f54242); }
.ps-logo-dots span:nth-child(2) { color: var(--ps-yellow, #f5d142); }
.ps-logo-dots span:nth-child(3) { color: var(--ps-blue, #4287f5); }
.ps-logo-dots span:nth-child(4) { color: var(--ps-green, #42f560); }

.title-group h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ffffff 0%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.title-group p {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.header-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.badge {
  background: rgba(0, 210, 255, 0.1);
  border: 1px solid rgba(0, 210, 255, 0.3);
  color: var(--accent-blue);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge.pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse 1.5s infinite;
}

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

/* Main Container */
.main-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

/* Arcade Monitor Section */
.arcade-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.arcade-bezel {
  position: relative;
  background: #1b1e26;
  border-radius: 18px;
  padding: 1.5rem 1.5rem 1.25rem 1.5rem;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.8),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    inset 0 -2px 6px rgba(0, 0, 0, 0.7);
  border: 4px solid #2a3140;
  max-width: 740px;
  width: 100%;
}

.bezel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0 0.5rem;
  color: #7d889b;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.bezel-power-led {
  display: flex;
  align-items: center;
  gap: 6px;
}

.led-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38ef7d;
  box-shadow: 0 0 8px #38ef7d;
}

.screen-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 480px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
}

.screen-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* CRT Shader Overlay */
.crt-overlay {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.crt-scanlines {
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.4) 50%
  );
  background-size: 100% 4px;
  opacity: 0.85;
}

.crt-trinitron {
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,0.5) 100%),
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.45) 50%);
  background-size: 100% 100%, 100% 4px;
  opacity: 0.95;
  box-shadow: inset 0 0 40px rgba(0, 210, 255, 0.05);
}

/* Arcade Controls Toolbar */
.arcade-toolbar {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem;
  background: #11141c;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-tool {
  background: #1c2230;
  border: 1px solid #313c54;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-tool:hover {
  background: #2a3449;
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.btn-tool.active {
  background: rgba(0, 210, 255, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.select-tool {
  background: #1c2230;
  border: 1px solid #313c54;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

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

/* Controller & Quick Guide Section */
.controller-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
}

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

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--accent-blue);
  border-radius: 2px;
}

/* Controls Grid */
.controls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.controls-table th,
.controls-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.controls-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.key-badge {
  display: inline-block;
  background: #1e2638;
  border: 1px solid #374663;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  font-weight: bold;
  color: #a5b4fc;
  box-shadow: 0 2px 0 #131926;
}

.ps-symbol {
  font-weight: 800;
  font-size: 0.95rem;
}
.sym-cross { color: var(--ps-cross); }
.sym-circle { color: var(--ps-circle); }
.sym-square { color: var(--ps-square); }
.sym-triangle { color: var(--ps-triangle); }

/* Virtual Gamepad Visualizer */
.gamepad-visualizer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0d14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  position: relative;
}

.controller-svg-wrap {
  width: 100%;
  max-width: 380px;
}

.controller-status-bar {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}

.status-dot.connected {
  background: #38ef7d;
  box-shadow: 0 0 8px #38ef7d;
}

/* Tabbed Content Hub */
.hub-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.hub-tabs {
  display: flex;
  background: #0d1017;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 1rem 1.5rem;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  background: rgba(0, 210, 255, 0.04);
}

.tab-content {
  padding: 2rem;
  display: none;
}

.tab-content.active {
  display: block;
}

/* Manual & Dossier Typography */
.tab-content h3 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  color: #fff;
}

.tab-content h4 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem 0;
  color: var(--accent-yellow);
}

.tab-content p {
  color: #cbd5e1;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.feature-card {
  background: #181d28;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
}

.feature-card h5 {
  color: var(--accent-blue);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Artwork Showcase */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  align-items: center;
  justify-items: center;
  margin-top: 1rem;
}

.art-card {
  background: #11141c;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  width: 100%;
  max-width: 340px;
}

.art-card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  margin-bottom: 0.75rem;
}

.art-card span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Download Cards */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.download-card {
  background: #161b26;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.download-card h4 {
  color: #fff;
  margin-top: 0;
}

.download-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(90deg, #0088cc 0%, #00b4d8 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-download:hover {
  background: linear-gradient(90deg, #0099e6 0%, #00c8f0 100%);
  box-shadow: 0 0 15px rgba(0, 180, 216, 0.4);
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
}

/* ==========================================================================
   PS1 Mobile On-Screen Touch Controller
   ========================================================================== */
.touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: radial-gradient(circle at 50% 0%, #242a38 0%, #151820 100%);
  border-radius: 20px;
  border: 2px solid #2e3748;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    0 10px 30px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  position: relative;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.touch-controls.touch-hidden {
  display: none !important;
}

/* Button Reset for Virtual Pad */
.touch-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Controller Clusters */
.touch-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.touch-shoulder-row {
  margin-bottom: 8px;
}

.touch-btn-shoulder {
  width: 84px;
  height: 32px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #323b4c 0%, #222734 100%);
  border: 1px solid #414d64;
  color: #94a3b8;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.12);
  transition: all 0.08s ease;
}

.touch-btn-shoulder:active,
.touch-btn-shoulder.active {
  background: #00d2ff;
  color: #0b1118;
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.7);
  transform: translateY(2px);
}

/* --- D-Pad --- */
.touch-dpad {
  position: relative;
  width: 130px;
  height: 130px;
}

.touch-dpad-dish {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #12151c;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.9),
    0 1px 2px rgba(255, 255, 255, 0.05);
}

.touch-dpad-core {
  position: absolute;
  top: 43px;
  left: 43px;
  width: 44px;
  height: 44px;
  background: #202633;
  z-index: 2;
  pointer-events: none;
}

.touch-dpad-btn {
  position: absolute;
  z-index: 3;
  background: #293140;
  color: #8493a8;
  border: 1px solid #3c4659;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.06s ease;
}

.touch-dpad-up {
  top: 2px;
  left: 43px;
  width: 44px;
  height: 44px;
  border-radius: 8px 8px 2px 2px;
}

.touch-dpad-down {
  bottom: 2px;
  left: 43px;
  width: 44px;
  height: 44px;
  border-radius: 2px 2px 8px 8px;
}

.touch-dpad-left {
  top: 43px;
  left: 2px;
  width: 44px;
  height: 44px;
  border-radius: 8px 2px 2px 8px;
}

.touch-dpad-right {
  top: 43px;
  right: 2px;
  width: 44px;
  height: 44px;
  border-radius: 2px 8px 8px 2px;
}

.touch-dpad-btn:active,
.touch-dpad-btn.active {
  background: #3b82f6 !important;
  color: #fff !important;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.8) !important;
  transform: scale(0.95);
}

/* --- Action Buttons (▲ ● ✖ ■) --- */
.touch-actions {
  position: relative;
  width: 130px;
  height: 130px;
}

.touch-actions-dish {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #12151c;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.9),
    0 1px 2px rgba(255, 255, 255, 0.05);
}

.touch-action-btn {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #202532;
  border: 2px solid #323c4d;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 3;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
  transition: all 0.06s ease;
}

.touch-action-triangle {
  top: 3px;
  left: 44px;
}

.touch-action-circle {
  top: 44px;
  right: 3px;
}

.touch-action-cross {
  bottom: 3px;
  left: 44px;
}

.touch-action-square {
  top: 44px;
  left: 3px;
}

.ps-glyph.glyph-triangle { color: #32e096; }
.ps-glyph.glyph-circle   { color: #ff4d6a; }
.ps-glyph.glyph-cross    { color: #4d88ff; }
.ps-glyph.glyph-square   { color: #ff77d2; }

.touch-action-triangle:active,
.touch-action-triangle.active {
  background: rgba(50, 224, 150, 0.3) !important;
  border-color: #32e096 !important;
  box-shadow: 0 0 18px #32e096 !important;
  transform: scale(0.92);
}

.touch-action-circle:active,
.touch-action-circle.active {
  background: rgba(255, 77, 106, 0.3) !important;
  border-color: #ff4d6a !important;
  box-shadow: 0 0 18px #ff4d6a !important;
  transform: scale(0.92);
}

.touch-action-cross:active,
.touch-action-cross.active {
  background: rgba(77, 136, 255, 0.3) !important;
  border-color: #4d88ff !important;
  box-shadow: 0 0 18px #4d88ff !important;
  transform: scale(0.92);
}

.touch-action-square:active,
.touch-action-square.active {
  background: rgba(255, 119, 210, 0.3) !important;
  border-color: #ff77d2 !important;
  box-shadow: 0 0 18px #ff77d2 !important;
  transform: scale(0.92);
}

/* --- Center Section: SELECT & START --- */
.touch-center {
  justify-content: space-between;
  height: 100%;
  min-height: 120px;
  padding-bottom: 6px;
}

.touch-brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
}

.touch-brand-sony {
  font-family: var(--font-retro);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #556276;
  font-weight: bold;
}

.touch-brand-dots {
  display: flex;
  gap: 4px;
  font-size: 0.6rem;
}

.touch-brand-dots span:nth-child(1) { color: #32e096; }
.touch-brand-dots span:nth-child(2) { color: #ff4d6a; }
.touch-brand-dots span:nth-child(3) { color: #4d88ff; }
.touch-brand-dots span:nth-child(4) { color: #ff77d2; }

.touch-center-buttons {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.touch-pill-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.touch-btn-pill {
  width: 42px;
  height: 16px;
  border-radius: 8px;
  background: #252b38;
  border: 1px solid #3b4557;
  transform: rotate(-25deg);
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.08s ease;
}

.touch-pill-group label {
  font-family: monospace;
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.touch-btn-pill:active,
.touch-btn-pill.active {
  background: #00d2ff !important;
  box-shadow: 0 0 12px #00d2ff !important;
  transform: rotate(-25deg) scale(0.92);
}

/* --- Mobile Landscape Floating Controls --- */
@media (orientation: landscape) and (max-width: 1024px),
       (orientation: landscape) and (max-height: 520px) {
  .touch-controls {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    padding: 16px 24px;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  .touch-controls .touch-left {
    pointer-events: auto;
    background: rgba(20, 24, 32, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 14px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  }

  .touch-controls .touch-right {
    pointer-events: auto;
    background: rgba(20, 24, 32, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 14px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  }

  .touch-controls .touch-center {
    pointer-events: auto;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 24, 32, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    flex-direction: row;
    gap: 16px;
    align-items: center;
    min-height: auto;
    height: auto;
  }

  .touch-controls .touch-brand-mark {
    display: none;
  }
}

/* Mobile Portrait Responsive Tweaks */
@media (max-width: 600px) {
  .arcade-bezel {
    padding: 0.75rem 0.5rem;
  }
  .touch-controls {
    padding: 0.75rem 0.5rem;
    margin-top: 0.75rem;
  }
  .touch-dpad,
  .touch-actions {
    width: 114px;
    height: 114px;
  }
  .touch-dpad-dish,
  .touch-actions-dish {
    width: 114px;
    height: 114px;
  }
  .touch-dpad-core {
    top: 38px;
    left: 38px;
    width: 38px;
    height: 38px;
  }
  .touch-dpad-up {
    top: 2px;
    left: 38px;
    width: 38px;
    height: 38px;
  }
  .touch-dpad-down {
    bottom: 2px;
    left: 38px;
    width: 38px;
    height: 38px;
  }
  .touch-dpad-left {
    top: 38px;
    left: 2px;
    width: 38px;
    height: 38px;
  }
  .touch-dpad-right {
    top: 38px;
    right: 2px;
    width: 38px;
    height: 38px;
  }
  .touch-action-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .touch-action-triangle {
    top: 2px;
    left: 39px;
  }
  .touch-action-circle {
    top: 39px;
    right: 2px;
  }
  .touch-action-cross {
    bottom: 2px;
    left: 39px;
  }
  .touch-action-square {
    top: 39px;
    left: 2px;
  }
  .touch-btn-shoulder {
    width: 72px;
    height: 28px;
    font-size: 0.75rem;
  }
  .touch-center-buttons {
    gap: 8px;
  }
  .touch-btn-pill {
    width: 34px;
    height: 14px;
  }
}

/* ROM Cache Manager */
.cache-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #2a3449;
  color: #94a3b8;
  margin-left: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.cache-badge.cached {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.cache-badge.streaming {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.cache-badge.downloading {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.cache-modal {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-width: 480px;
  background: #151922;
  border: 2px solid #2a3449;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 210, 255, 0.15);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cache-modal[hidden] {
  display: none !important;
}

.cache-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #222a3a;
  padding-bottom: 0.6rem;
}

.cache-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cache-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  background: #0d1017;
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid #1e2535;
}

.cache-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #cbd5e1;
}

.cache-file-status {
  font-weight: 600;
  font-size: 0.75rem;
}

.cache-progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cache-progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #1e2535;
  border-radius: 4px;
  overflow: hidden;
}

.cache-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d2ff, #3b82f6);
  width: 0%;
  transition: width 0.2s ease;
}

.cache-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   TrackMania Track Studio Styles
   ========================================================================== */

.studio-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

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

.studio-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.studio-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.studio-label {
  font-family: var(--font-retro);
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--accent-blue);
  text-transform: uppercase;
}

.studio-input {
  background: #0d1017;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 8px 10px;
  color: #fff;
  font-family: var(--font-retro);
  font-size: 0.9rem;
  font-weight: bold;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.2s;
}

.studio-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.3);
}

.studio-stats-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-retro);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-value {
  color: #fff;
  font-weight: bold;
}

.studio-badge {
  font-family: var(--font-retro);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 6px 8px;
  border-radius: 4px;
  text-align: center;
  letter-spacing: 0.5px;
}

.studio-badge.invalid {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
}

.studio-badge.valid {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #6ee7b7;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.palette-btn {
  background: #0f131c;
  border: 1px solid #262e42;
  border-radius: 6px;
  padding: 6px 4px;
  color: var(--text-main);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  user-select: none;
}

.palette-btn:hover {
  background: #182030;
  border-color: #3b82f6;
}

.palette-btn.active {
  background: #1e283d;
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.palette-btn .blk-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.rotation-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.rotation-bar span {
  font-family: var(--font-retro);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.rot-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.rot-btn {
  background: #0f131c;
  border: 1px solid #262e42;
  border-radius: 4px;
  padding: 4px 2px;
  font-family: var(--font-retro);
  font-size: 0.7rem;
  color: #94a3b8;
  cursor: pointer;
}

.rot-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #000;
  font-weight: bold;
}

.palette-tools, .template-buttons, .action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-tool-btn, .preset-btn, .studio-action-btn {
  background: #0f131c;
  border: 1px solid #262e42;
  border-radius: 6px;
  padding: 7px 10px;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.studio-tool-btn:hover, .preset-btn:hover, .studio-action-btn:hover {
  background: #182030;
  border-color: #475569;
  color: #fff;
}

.studio-tool-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fca5a5;
}

.studio-tool-btn.danger {
  color: #f87171;
}

.studio-tool-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.studio-action-btn.primary {
  background: linear-gradient(135deg, #00d2ff, #0088cc);
  border-color: #00d2ff;
  color: #000;
  font-weight: bold;
  text-align: center;
}

.studio-action-btn.primary:hover {
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.5);
}

.studio-action-btn.success {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #6ee7b7;
}

.studio-action-btn.success:hover {
  background: #10b981;
  color: #000;
  font-weight: bold;
}

.studio-canvas-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.canvas-header-info {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.canvas-wrapper {
  background: #0b0e14;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

#studio-canvas {
  width: 100%;
  max-width: 600px;
  height: auto;
  aspect-ratio: 1 / 1;
  cursor: crosshair;
  background: #090c12;
  border-radius: 4px;
}

