
:root {
  --page-bg-1: #edf1ff;
  --page-bg-2: #d7def5;
  --panel-bg: rgba(255, 255, 255, 0.84);
  --panel-border: rgba(100, 112, 145, 0.14);
  --text-main: #1e273c;
  --text-soft: #657390;
  --accent: #5966ff;
  --accent-2: #8a5cf8;
  --accent-3: #07b2c9;
  --shadow-lg: 0 26px 70px rgba(53, 63, 94, 0.22);
  --shadow-md: 0 14px 28px rgba(44, 54, 89, 0.16);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-stack: "Avenir Next", Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shell-top: #f4f3ef;
  --shell-mid: #e7e6e0;
  --shell-deep: #cdccc7;
  --screen-bezel-top: #9b96af;
  --screen-bezel-bottom: #767389;
  --button-plum: #a81f73;
  --button-plum-dark: #6e124b;
  --dpad-face: #25242b;
  --dpad-highlight: #3b3a44;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-stack);
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(126, 91, 239, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(0, 181, 199, 0.14), transparent 28%),
    linear-gradient(180deg, var(--page-bg-1), var(--page-bg-2));
}

button, input, select { font: inherit; }

.page-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.hero-card,
.panel {
  backdrop-filter: blur(12px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-lg);
}

.hero-card {
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
}

.hero-card h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.02;
}

.hero-copy {
  margin: 10px 0 0;
  max-width: 720px;
  color: var(--text-soft);
  line-height: 1.55;
}

.hero-badge {
  flex: 0 0 auto;
  border-radius: 20px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(95, 101, 255, 0.12), rgba(0, 168, 168, 0.14));
  color: #36415e;
  font-weight: 800;
  text-align: center;
  min-width: 124px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(280px, 360px);
  gap: 22px;
  align-items: start;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--text-soft);
  line-height: 1.5;
}

.control-stack {
  margin-top: 20px;
  display: grid;
  gap: 14px;
}

.file-picker,
.field-block,
.stats-box,
.export-grid {
  border-radius: var(--radius-lg);
}

.file-picker,
.field-block,
.stats-box {
  background: rgba(248, 250, 255, 0.92);
  border: 1px solid rgba(92, 104, 140, 0.12);
}

.file-picker {
  padding: 18px 18px;
  display: block;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
  border: 2px dashed rgba(76, 86, 118, 0.55);
  background: rgba(228, 233, 244, 0.88);
}

.file-picker:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: rgba(89, 102, 255, 0.7);
  background: rgba(236, 240, 250, 0.96);
}

.file-picker-title {
  display: block;
  font-weight: 800;
}

.file-picker-subtitle {
  display: block;
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-block {
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.field-block.is-muted {
  opacity: 0.54;
  transition: opacity 160ms ease;
}

.field-block.is-muted.is-active { opacity: 1; }

.field-label {
  font-size: 0.94rem;
  font-weight: 700;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.field-value {
  color: var(--text-soft);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  padding: 4px 2px;
}

.toggle-row input {
  inline-size: 20px;
  block-size: 20px;
  accent-color: var(--accent-2);
}

select,
input[type="range"] { width: 100%; }

select {
  border-radius: 14px;
  border: 1px solid rgba(94, 104, 145, 0.18);
  background: #fff;
  padding: 12px 14px;
  color: var(--text-main);
}

.slider {
  appearance: none;
  height: 10px;
  border-radius: 999px;
  outline: none;
}

.slider-violet { background: linear-gradient(90deg, #98a2ff, #6b63ff, #8d59f7); }
.slider-cyan { background: linear-gradient(90deg, #86edf3, #2dc7db, #1f90df); }
.slider-magenta { background: linear-gradient(90deg, #f6b0dd, #ef63bf, #a82b7b); }
.slider-gold { background: linear-gradient(90deg, #ffe3a1, #ffc450, #ee9d1b); }

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(87, 100, 155, 0.5);
  box-shadow: 0 6px 14px rgba(82, 94, 146, 0.2);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(87, 100, 155, 0.5);
  box-shadow: 0 6px 14px rgba(82, 94, 146, 0.2);
  cursor: pointer;
}

.stats-box {
  margin-top: 18px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.stat-line span { color: var(--text-soft); }
.stat-line strong { text-align: right; }

.export-grid {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.action-button {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(95, 101, 255, 0.10);
  color: #2c3560;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.action-button.primary {
  background: linear-gradient(135deg, #5865ff, #7c3aed);
  color: #fff;
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.panel-preview { display: grid; align-content: start; }
.panel-output { position: sticky; top: 18px; }

.handheld {
  position: relative;
  margin: 22px auto 8px;
  width: min(100%, 540px);
  padding: 20px 24px 26px;
  border-radius: 24px 24px 96px 24px;
  background: linear-gradient(145deg, var(--shell-top) 0%, #ecebe7 52%, var(--shell-deep) 100%);
  box-shadow:
    inset 12px 12px 18px rgba(255, 255, 255, 0.75),
    inset -14px -18px 20px rgba(142, 144, 151, 0.18),
    0 42px 90px rgba(57, 67, 95, 0.28);
  overflow: hidden;
  height: 820px;
}

.handheld::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.88),
    inset -1px -1px 0 rgba(120,124,136,0.18);
  pointer-events: none;
}

.handheld-topline {
  height: 8px;
  border-radius: 999px;
  margin: 0 8px 18px;
  background: linear-gradient(90deg, #5a4dbc, #504cb1 30%, #24306f 31%, #24306f 40%, #c14fa0 74%, #c14fa0 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.power-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  margin-bottom: 8px;
}

.power-led {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #8a8c92;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.28);
  transition: background 180ms ease, box-shadow 180ms ease;
}

.power-led.is-on {
  background: radial-gradient(circle at 30% 30%, #ffd7d7, #ff5f5f 58%, #c31212);
  box-shadow: 0 0 15px rgba(255, 82, 82, 0.78);
}

.power-text {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: #6b7082;
  font-weight: 800;
}

.screen-frame {
  margin: 2px auto 0;
  width: 86%;
  padding: 18px 18px 24px;
  border-radius: 18px 18px 42px 18px;
  background: linear-gradient(180deg, var(--screen-bezel-top), var(--screen-bezel-bottom));
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.14),
    inset 0 -6px 12px rgba(21, 25, 36, 0.2);
}

.screen-bezel-text {
  text-align: center;
  color: #eceff8;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

#previewCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  image-rendering: pixelated;
  background: #9bbc0f;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 4px rgba(31, 46, 16, 0.18),
    inset 0 16px 28px rgba(255,255,255,0.08);
}

.brand-row {
  display: flex;
  align-items: center;
  margin-top: 18px;
  padding: 0 14px;
}

.brand-nintendo {
  display: inline-block;
  font-size: 0.78rem;
  color: #243f9c;
  font-weight: 700;
  margin-right: 6px;
}

.brand-mark {
  display: inline-block;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  font-style: italic;
  font-weight: 900;
  color: #334e9d;
  letter-spacing: 0.03em;
}

.brand-submark {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #65708b;
  font-weight: 800;
}

.controls-row {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px 0 8px;
}

.dpad {
  position: relative;
  width: 106px;
  height: 106px;
}

.dpad-arm {
  position: absolute;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--dpad-highlight), var(--dpad-face));
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.10),
    inset -2px -2px 0 rgba(0,0,0,0.22),
    0 7px 12px rgba(0,0,0,0.18);
}

.dpad-arm-vertical {
  width: 34px;
  height: 98px;
  left: 36px;
  top: 4px;
}

.dpad-arm-horizontal {
  width: 98px;
  height: 34px;
  left: 4px;
  top: 36px;
}

.dpad-core {
  position: absolute;
  width: 34px;
  height: 34px;
  left: 36px;
  top: 36px;
  border-radius: 8px;
  background: linear-gradient(145deg, #33323a, #1f1f25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}

.action-buttons-shell {
  width: 160px;
  display: flex;
  justify-content: flex-end;
}

.action-buttons {
  position: relative;
  width: 152px;
  height: 92px;
  transform: rotate(-22deg);
}

.action-button-shell {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: rgba(255,255,255,0.92);
  background: radial-gradient(circle at 30% 30%, #d14596, var(--button-plum) 55%, var(--button-plum-dark));
  box-shadow:
    inset 0 3px 8px rgba(255,255,255,0.18),
    inset 0 -4px 8px rgba(74, 8, 44, 0.35),
    0 8px 14px rgba(70, 17, 49, 0.25);
}

.action-button-b { left: 18px; top: 30px; }
.action-button-a { left: 88px; top: 8px; }

.system-buttons {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 8px;
}

.system-button-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: rotate(-22deg);
}

.system-button {
  width: 44px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(145deg, #898995, #5d6272);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.45),
    inset -1px -1px 0 rgba(0,0,0,0.15);
}

.system-button-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: #656f88;
  font-weight: 800;
}

.speaker-area {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  padding: 8px 18px 0;
}

.speaker-grill {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  transform: rotate(-24deg);
}

.speaker-grill span {
  width: 8px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #8c93a7, #667086);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.65),
    inset 0 -1px 0 rgba(0,0,0,0.10);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

input[type="range"]:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 1180px) {
  .workspace-grid {
    grid-template-columns: minmax(300px, 380px) minmax(380px, 1fr);
  }

  .panel-output {
    grid-column: 1 / -1;
    position: static;
  }

  .export-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

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

  .panel-output { position: static; }

  .handheld {
    width: min(100%, 520px);
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 18px, 100%);
    margin-top: 10px;
  }

  .hero-card,
  .panel {
    padding: 18px;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .export-grid {
    grid-template-columns: 1fr;
  }

  .handheld {
    padding: 18px 16px 24px;
    border-radius: 22px 22px 76px 22px;
    height: 760px;
  }

  .controls-row {
    padding-right: 8px;
  }

  .dpad {
    transform: scale(0.88);
    transform-origin: left center;
  }

  .action-buttons {
    transform: rotate(-22deg) scale(0.88);
    transform-origin: right center;
  }
}
