*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif;
  --font-mono: 'SF Mono', Menlo, monospace;
  --accent-red: #ff3a3a;
}

body {
  background: #050505;
  color: #e5e5e5;
  font-family: var(--font-sans);
  font-size: 13px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.Retro-Stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.Retro-Upload {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 4/3;
  border: 1px dashed #2a2a2a;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  color: #555;
  transition: border-color 0.25s, color 0.25s;
}
.Retro-Upload:hover, .Retro-Upload[data-over] {
  border-color: #888;
  color: #aaa;
}
.Retro-Upload-Icon {
  width: 36px;
  height: 36px;
  opacity: 0.6;
}
.Retro-Upload-Title {
  font-size: 12px;
  letter-spacing: 0.14em;
}
.Retro-Upload-Sub {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: #3a3a3a;
  font-family: var(--font-mono);
}
.Retro-Canvas {
  display: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
.Retro-FileInput {
  display: none;
}
.Retro-Panel {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 252px;
  background: rgba(15, 15, 15, 0.86);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  z-index: 100;
}
.Retro-Panel-Header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  cursor: grab;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  touch-action: none;
}
.Retro-Panel-Header:active {
  cursor: grabbing;
}
.Retro-Panel-Grip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  opacity: 0.4;
}
.Retro-Panel-Grip-Dot {
  width: 2.5px;
  height: 2.5px;
  background: #888;
  border-radius: 50%;
}
.Retro-Panel-Rec {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--accent-red);
}
.Retro-Panel-Rec-Dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 8px rgba(255, 58, 58, 0.6);
  animation: retro-pulse 1.8s ease-in-out infinite;
}
.Retro-Panel-Modes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 10px;
  gap: 4px;
}
.Retro-Panel-Mode {
  padding: 7px 2px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  color: #888;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
}
.Retro-Panel-Mode:hover {
  color: #ccc;
}
.Retro-Panel-Mode[data-active] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.Retro-Panel-Sliders {
  padding: 2px 14px 12px;
}
.Retro-Panel-Slider {
  padding: 7px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.Retro-Panel-Slider-Label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #999;
}
.Retro-Panel-Slider-Value {
  font-family: var(--font-mono);
  color: #ddd;
  font-size: 10px;
}
.Retro-Panel-Slider-Range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  outline: none;
}
.Retro-Panel-Slider-Range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #e5e5e5;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.Retro-Panel-Slider-Range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #e5e5e5;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
}
.Retro-Panel-Empty {
  color: #444;
  font-size: 10px;
  text-align: center;
  padding: 28px 0;
  letter-spacing: 0.15em;
  font-family: var(--font-mono);
}
.Retro-Panel-Actions {
  display: flex;
  gap: 4px;
  padding: 0 10px 10px;
}
.Retro-Panel-Button {
  flex: 1;
  padding: 10px 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: #ccc;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.Retro-Panel-Button:hover {
  background: rgba(255, 255, 255, 0.08);
}
.Retro-Panel-Button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.Retro-Panel-Button[data-action=save] {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}
.Retro-Panel-Button[data-action=save]:hover {
  background: #ff5050;
}
.Retro-Panel-Button[data-action=save]:disabled {
  background: var(--accent-red);
}
.Retro[data-has-image] .Retro-Upload {
  display: none;
}
.Retro[data-has-image] .Retro-Canvas {
  display: block;
}

@keyframes retro-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
@media (max-width: 480px) {
  .Retro-Panel {
    width: calc(100% - 24px);
    top: auto;
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
  }
  .Retro-Panel-Sliders {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
  }
}