:root {
  --navy: #12162e;
  --panel: #1c2140;
  --gold: #f5c518;
  --red: #c0392b;
  --grass: #5aab2e;
}

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

html, body {
  height: 100%;
  background: #0a0c1c;
  font-family: 'Press Start 2P', monospace;
  color: #e8e8f0;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#ai-watermark {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 13px;
  color: #cfd8ff;
  opacity: 0.55;
  z-index: 5;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}

#canvas {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-bottom: 4px solid #000;
}

#controls {
  flex: 0 0 auto;
  background: linear-gradient(#232a52, #171b38);
  border-top: 3px solid #3a4278;
  padding: 12px 12px calc(10px + env(safe-area-inset-bottom));
}

.panel {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.mode-row { justify-content: center; }
.btn-row { justify-content: center; }

.pixbtn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #fff;
  background: #2f3a72;
  border: none;
  border-bottom: 4px solid #14183a;
  border-right: 4px solid #14183a;
  padding: 10px 12px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.05s, background 0.15s;
}
.pixbtn:hover { background: #3d4b93; }
.pixbtn:active { transform: translate(2px, 2px); border-bottom-width: 2px; border-right-width: 2px; }
.pixbtn.active { background: var(--grass); border-bottom-color: #2e5c15; border-right-color: #2e5c15; }
.pixbtn.accent { background: var(--red); border-bottom-color: #6e1a12; border-right-color: #6e1a12; }
.pixbtn.accent:hover { background: #d14839; }

.pixinput {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  width: 100%;
  padding: 14px 12px;
  background: #0d1030;
  color: var(--gold);
  border: 3px solid #3a4278;
  outline: none;
  letter-spacing: 1px;
}
.pixinput:focus { border-color: var(--gold); }
.pixinput::placeholder { color: #5a63a0; }

.decoded {
  font-size: 10px;
  color: #7fe0a0;
  word-break: break-all;
  line-height: 1.7;
  min-height: 14px;
  text-align: center;
  padding: 0 4px;
}

.history { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #cfd8ff;
  background: #262c56;
  border: 2px solid #3a4278;
  padding: 6px 8px;
  cursor: pointer;
}
.chip:hover { background: #343c72; color: #fff; }

.footer { text-align: center; margin-top: 4px; }
.footer a {
  font-size: 8px;
  color: #f6851f;
  text-decoration: none;
  border-bottom: 2px dotted #f6851f;
  padding-bottom: 2px;
}
.footer a:hover { color: var(--gold); border-color: var(--gold); }

#toast {
  position: fixed;
  top: 20px; left: 50%;
  transform: translate(-50%, -140%);
  background: var(--red);
  color: var(--gold);
  font-size: 11px;
  padding: 14px 18px;
  border: 3px solid var(--gold);
  border-radius: 2px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
  z-index: 50;
  transition: transform 0.35s cubic-bezier(.2,1.4,.4,1);
  text-align: center;
  max-width: 90vw;
}
#toast.show { transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .pixbtn { font-size: 8px; padding: 9px 8px; }
  .pixinput { font-size: 10px; }
  #controls { padding: 8px; }
}