:root {
  --bg-deep: #0d1b3e;
  --panel: #e8eef7;
  --panel-edge: #a8bbd8;
  --accent: #ff7a1a;
  --accent2: #7cf03a;
  --blue1: #3d6fd6;
  --blue2: #7aa8f0;
  --ink: #17233d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'VT323', monospace;
  color: var(--ink);
  background: linear-gradient(160deg, #1b2a56 0%, #0d1b3e 60%, #05091c 100%);
  position: relative;
  overflow-x: hidden;
}

.bg-tile {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    linear-gradient(45deg, #4a6bb0 25%, transparent 25%),
    linear-gradient(-45deg, #4a6bb0 25%, transparent 25%);
  background-size: 40px 40px;
}

/* ---- Header ---- */
.app-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 22px 12px 10px;
}
.app-header h1 {
  font-family: 'Bungee', cursive;
  font-size: clamp(28px, 6vw, 52px);
  margin: 0;
  color: #fff;
  text-shadow: 3px 3px 0 var(--accent), 6px 6px 0 rgba(0,0,0,0.4);
  letter-spacing: 1px;
}
.tagline {
  font-size: clamp(16px, 3vw, 24px);
  color: var(--accent2);
  margin: 4px 0 12px;
  text-shadow: 1px 1px 0 #000;
}
.blink-strip {
  display: block;
  max-width: 760px;
  margin: 0 auto;
  background: repeating-linear-gradient(90deg, #000 0 10px, #1a1a2e 10px 20px);
  color: #ffd166;
  font-size: 18px;
  padding: 4px 0;
  border: 2px ridge #666;
  border-radius: 4px;
}

/* ---- Layout ---- */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 12px auto;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---- Fake window ---- */
.fake-window {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 8px 8px 4px 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 0 2px #fff;
  overflow: hidden;
}
.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, var(--blue2), var(--blue1));
  color: #fff;
  padding: 5px 10px;
  font-size: 18px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}
.tb-btns i {
  display: inline-block;
  width: 20px; height: 18px;
  line-height: 18px;
  text-align: center;
  background: #dbe6f7;
  color: #17233d;
  border: 1px solid #7089b8;
  border-radius: 3px;
  margin-left: 4px;
  font-style: normal;
  font-size: 13px;
}
.canvas-wrap {
  position: relative;
  background: #000;
  display: flex;
  justify-content: center;
}
#canvas {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(5,9,28,0.82);
  color: #cfe0ff;
  font-size: 22px;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  transition: background .2s;
}
.overlay.drag { background: rgba(255,122,26,0.35); }
.spinner {
  width: 46px; height: 46px;
  border: 5px solid #3a4d7a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Transport ---- */
.transport {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---- Buttons ---- */
.glossy {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: #fff;
  padding: 8px 16px;
  border: 1px solid #1f4fae;
  border-radius: 8px;
  background: linear-gradient(180deg, #6fa0ee 0%, var(--blue1) 50%, #2a55b0 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 3px 0 #16336e, 0 5px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
  transition: transform .06s;
}
.glossy:hover { filter: brightness(1.08); }
.glossy:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 0 #16336e; }
.glossy:disabled { opacity: 0.5; cursor: not-allowed; }
.glossy.alt {
  background: linear-gradient(180deg, #ffb06a, var(--accent) 55%, #d85e00);
  border-color: #c25200;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 3px 0 #a04600, 0 5px 8px rgba(0,0,0,0.4);
}
.glossy.big { width: 100%; font-size: 22px; padding: 12px; }
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---- Control panels ---- */
.controls { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), inset 0 0 0 2px #fff;
}
.panel h2 {
  font-family: 'Bungee', cursive;
  font-size: 16px;
  margin: 0 0 12px;
  color: var(--blue1);
  border-bottom: 2px dashed var(--panel-edge);
  padding-bottom: 6px;
}
.panel label {
  display: block;
  font-size: 19px;
  margin-bottom: 14px;
}
.panel label output {
  color: var(--accent);
  font-weight: bold;
}
input[type=range] {
  width: 100%;
  accent-color: var(--blue1);
  margin-top: 4px;
}
.toggle { cursor: pointer; }
.toggle input { transform: scale(1.4); margin-right: 8px; vertical-align: middle; }

.presets { margin: 8px 0 14px; }
.presets-label { font-size: 18px; color: var(--ink); }
.chip {
  font-family: 'VT323', monospace;
  font-size: 16px;
  margin: 5px 4px 0 0;
  padding: 4px 10px;
  border: 1px solid var(--blue1);
  border-radius: 20px;
  background: #fff;
  color: var(--blue1);
  cursor: pointer;
}
.chip:hover { background: #eaf1ff; }
.chip.active { background: var(--accent); color: #fff; border-color: #c25200; }

.btn-row { display: flex; gap: 8px; }
.btn-row .glossy { flex: 1; font-size: 17px; }

/* ---- Progress ---- */
.progress-wrap { margin-top: 12px; }
.progress {
  height: 18px;
  background: #cdd8ea;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  overflow: hidden;
}
.progress #progBar {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(45deg, var(--accent2) 0 10px, #5cc820 10px 20px);
  transition: width .2s;
}
.prog-msg { font-size: 17px; margin: 6px 0 0; color: var(--ink); }

/* ---- Footer ---- */
.app-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 12px 40px;
  color: #9fb6e6;
}
.webring {
  font-size: 16px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.app-footer a {
  color: var(--accent2);
  font-size: 20px;
  text-decoration: none;
  border-bottom: 2px dotted var(--accent2);
}
.app-footer a:hover { color: #fff; }