/* PokeStation DMG-01 CSS: Authentic Handheld & Modern Interface */

:root {
  --bg-main: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-light: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
  --accent-yellow: #eab308;

  /* Game Boy DMG Body Colors */
  --dmg-body: #d8d6cf;
  --dmg-body-shadow: #b8b6ae;
  --dmg-body-highlight: #ebe9e3;
  --dmg-bezel: #686b76;
  --dmg-bezel-inner: #45474f;
  --dmg-screen-bg: #8bac0f;
  --dmg-button-a: #9f1239;
  --dmg-button-a-active: #881337;
  --dmg-dpad: #1e293b;
  --dmg-dpad-active: #0f172a;
  --dmg-rubber: #475569;
  --dmg-logo-blue: #1e3a8a;
  --dmg-stripe-magenta: #9d174d;
  --dmg-stripe-blue: #1e40af;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-main);
  background-image: radial-gradient(#1e293b 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.header {
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.brand-logo span {
  color: var(--accent-blue);
}

.badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-demo {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.badge-active {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.header-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px currentColor;
}

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

/* Button styles */
.btn {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-panel-light);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: white;
}

/* Main Container */
.main-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 32px;
}

/* ---------------------------------------------------- */
/* Game Boy DMG-01 Physical Shell */
/* ---------------------------------------------------- */
.gameboy-console {
  width: 380px;
  background: var(--dmg-body);
  border-radius: 16px 16px 60px 16px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px var(--dmg-body-highlight),
    inset 0 -6px 8px var(--dmg-body-shadow),
    inset 3px 0 6px var(--dmg-body-highlight),
    inset -3px 0 6px var(--dmg-body-shadow);
  padding: 24px 20px 32px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 2px solid #a8a69e;
}

/* Top Power Notch */
.power-switch-area {
  position: absolute;
  top: -12px;
  left: 50px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #78716c;
  letter-spacing: 0.5px;
}

.power-switch-slider {
  width: 32px;
  height: 10px;
  background: #44403c;
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  position: relative;
}

.power-switch-slider::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 1px;
  width: 14px;
  height: 8px;
  background: #a8a29e;
  border-radius: 2px;
}

/* Screen Bezel */
.screen-bezel {
  background: var(--dmg-bezel);
  border-radius: 12px 12px 36px 12px;
  padding: 16px 20px 18px 20px;
  box-shadow:
    inset 0 4px 6px rgba(0, 0, 0, 0.5),
    inset 0 -2px 4px rgba(255, 255, 255, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.2);
  border: 1px solid #4a4d57;
  position: relative;
}

/* Bezel Header Stripes & Text */
.bezel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.bezel-stripes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.stripe-magenta {
  height: 3px;
  background: var(--dmg-stripe-magenta);
  border-radius: 1px;
}

.stripe-blue {
  height: 3px;
  background: var(--dmg-stripe-blue);
  border-radius: 1px;
}

.bezel-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.5px;
  padding: 0 8px;
  white-space: nowrap;
}

/* Screen Wrapper & Battery LED */
.screen-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.battery-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.battery-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 10px #ef4444, inset 0 1px 2px rgba(255,255,255,0.6);
  border: 1px solid #991b1b;
}

.battery-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* LCD Viewport */
.screen-viewport {
  position: relative;
  background: var(--dmg-screen-bg);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.6),
    inset 0 -1px 2px rgba(255, 255, 255, 0.2);
  width: 240px;
  height: 216px; /* 1.5x integer scale */
  display: flex;
  align-items: center;
  justify-content: center;
}

#gb-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* LCD Grid & Scanline Shader Overlay */
.screen-shader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.screen-shader-overlay.effect-grid {
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 1px, transparent 1px);
  background-size: 1.5px 1.5px;
}

.screen-shader-overlay.effect-scanline {
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 3px;
}

/* Nintendo GAME BOY Branding */
.console-branding {
  margin: 14px 0 12px 10px;
}

.nintendo-label {
  font-family: "Times New Roman", Times, serif;
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--dmg-logo-blue);
  letter-spacing: 1px;
}

.gameboy-label {
  font-family: "Arial Black", "Impact", sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--dmg-logo-blue);
  letter-spacing: -0.5px;
  display: inline-block;
  transform: skewX(-6deg);
}

.gameboy-label span {
  font-size: 0.8rem;
  font-style: normal;
  vertical-align: super;
}

/* Controls Section (D-Pad & Buttons) */
.controls-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 0 10px;
}

/* Authentic D-Pad Cross */
.dpad-container {
  width: 110px;
  height: 110px;
  position: relative;
}

.dpad-cross {
  width: 100%;
  height: 100%;
  position: relative;
}

.dpad-btn {
  position: absolute;
  background: var(--dmg-dpad);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: var(--dmg-dpad-active);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.dpad-btn-up {
  top: 0;
  left: 36px;
  width: 38px;
  height: 38px;
  border-radius: 4px 4px 0 0;
}

.dpad-btn-down {
  bottom: 0;
  left: 36px;
  width: 38px;
  height: 38px;
  border-radius: 0 0 4px 4px;
}

.dpad-btn-left {
  left: 0;
  top: 36px;
  width: 38px;
  height: 38px;
  border-radius: 4px 0 0 4px;
}

.dpad-btn-right {
  right: 0;
  top: 36px;
  width: 38px;
  height: 38px;
  border-radius: 0 4px 4px 0;
}

.dpad-center {
  position: absolute;
  top: 36px;
  left: 36px;
  width: 38px;
  height: 38px;
  background: var(--dmg-dpad);
}

/* Center Divot */
.dpad-center-divot {
  position: absolute;
  top: 45px;
  left: 45px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #0f172a 40%, #1e293b 80%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
}

.dpad-arrow {
  width: 0;
  height: 0;
  border-style: solid;
}

.dpad-btn-up .dpad-arrow {
  border-width: 0 5px 7px 5px;
  border-color: transparent transparent #475569 transparent;
}
.dpad-btn-down .dpad-arrow {
  border-width: 7px 5px 0 5px;
  border-color: #475569 transparent transparent transparent;
}
.dpad-btn-left .dpad-arrow {
  border-width: 5px 7px 5px 0;
  border-color: transparent #475569 transparent transparent;
}
.dpad-btn-right .dpad-arrow {
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent #475569;
}

/* Action Buttons (A & B) */
.action-buttons-group {
  display: flex;
  gap: 14px;
  transform: rotate(-25deg);
  margin-top: -10px;
  margin-right: 6px;
}

.action-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--dmg-button-a);
  border: 1px solid #700d27;
  box-shadow:
    0 5px 8px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  position: relative;
  transition: all 0.08s ease;
}

.round-btn:active, .round-btn.pressed {
  background: var(--dmg-button-a-active);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    inset 0 2px 6px rgba(0, 0, 0, 0.7);
  transform: translateY(3px);
}

.btn-label {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--dmg-logo-blue);
  transform: rotate(25deg); /* Counteract parent rotation */
}

/* Bottom Select & Start Pills + Speaker Grille */
.console-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 24px;
  padding: 0 24px;
}

.pill-buttons-group {
  display: flex;
  gap: 18px;
  margin-bottom: 8px;
}

.pill-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pill-btn {
  width: 50px;
  height: 14px;
  background: var(--dmg-rubber);
  border-radius: 10px;
  border: none;
  transform: rotate(-25deg);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.3),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.08s ease;
}

.pill-btn:active, .pill-btn.pressed {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
  transform: rotate(-25deg) translateY(2px);
}

.pill-label {
  font-family: Arial, sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--dmg-logo-blue);
  letter-spacing: 0.5px;
}

/* Speaker Grille Slants */
.speaker-grille {
  display: flex;
  gap: 6px;
  transform: rotate(-25deg);
  margin-bottom: 12px;
  margin-right: -4px;
}

.speaker-slot {
  width: 6px;
  height: 52px;
  background: #a8a69e;
  border-radius: 3px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------- */
/* Right Sidebar: Control Deck & Info Dashboard */
/* ---------------------------------------------------- */
.control-deck {
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cartridge-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 0.8rem;
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  font-weight: 600;
  text-align: right;
  color: #e2e8f0;
}

/* Quick Control Buttons */
.quick-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-controls-grid .btn {
  justify-content: center;
  padding: 10px 8px;
}

/* Audio Mixer */
.audio-mixer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-slider {
  flex: 1;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.channel-toggles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  font-size: 0.75rem;
}

.channel-tag {
  background: var(--bg-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* Settings Selectors */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.select-input {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

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

/* Save States Bar */
.save-slots-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.slot-btn {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 0;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
}

.slot-btn.active {
  background: #0369a1;
  border-color: #38bdf8;
  color: white;
}

.save-actions-row {
  display: flex;
  gap: 8px;
}

.save-actions-row .btn {
  flex: 1;
  justify-content: center;
}

/* ---------------------------------------------------- */
/* Modals */
/* ---------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 90%;
  max-width: 540px;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-backdrop.open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

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

.modal-close:hover {
  color: white;
}

/* Drag & Drop Zone inside Modal */
.dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.05);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover {
  border-color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.1);
}

.dropzone-icon {
  font-size: 2.4rem;
}

.dropzone-text {
  font-size: 0.95rem;
  font-weight: 600;
}

.dropzone-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Legal Guidance Alert */
.legal-guidance {
  background: rgba(30, 41, 59, 0.8);
  border-left: 4px solid var(--accent-blue);
  padding: 12px 14px;
  border-radius: 4px 8px 8px 4px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #cbd5e1;
}

.legal-guidance strong {
  color: var(--accent-blue);
  display: block;
  margin-bottom: 4px;
}

/* Fullscreen Drag Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 165, 233, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drop-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.drop-overlay h2 {
  font-size: 2rem;
  font-weight: 800;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: #1e293b;
  color: white;
  border-left: 4px solid var(--accent-blue);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
  animation: slideIn 0.25s ease forwards;
}

.toast-success { border-left-color: var(--accent-green); }
.toast-error { border-left-color: var(--accent-red); }
.toast-info { border-left-color: var(--accent-blue); }

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

.toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

/* ---------------------------------------------------- */
/* Responsive Mobile & Tablet Layout */
/* ---------------------------------------------------- */
@media (max-width: 860px) {
  .main-layout {
    flex-direction: column;
    padding: 12px 8px;
    gap: 20px;
  }

  .gameboy-console {
    width: 100%;
    max-width: 360px;
    border-radius: 12px 12px 40px 12px;
    padding: 16px 14px 24px 14px;
  }

  .screen-viewport {
    width: 200px;
    height: 180px;
  }

  .control-deck {
    width: 100%;
    max-width: 360px;
  }
}
