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

.page-wrap {
  max-width: 1320px !important;
}

.site-navbar {
  width: 100vw !important;
  max-width: 100vw !important;
  margin-left: calc(50% - 50vw) !important;
  box-sizing: border-box !important;
}

.site-header .site-description {
  text-shadow: 2px 2px 0 #143018, -1px 0 0 #143018, 0 -1px 0 #143018 !important;
}

.page-wrap.page-wrap--narrow {
  max-width: 720px !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}

.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.nav-search {
  display: flex;
  align-items: center;
}

.nav-search input {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  font-size: 20px;
  color: #f5c518;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #5d4037;
  padding: 2px 8px 4px;
  width: 168px;
  outline: none;
  letter-spacing: 1px;
}

.nav-search input::placeholder {
  color: #8d6e63;
}

.nav-search input:focus {
  border-color: #f5c518;
}

.topnav-btn.active {
  border-color: #4caf50 !important;
  color: #c8e6c9 !important;
}

.panel {
  background: rgba(20, 14, 8, 0.92);
  border: 3px solid #5d4037;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  padding: 14px;
}

.panel-label,
.field-label {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 7px;
  color: #a5d6a7;
  text-shadow: 1px 1px 0 #1b5e20;
  letter-spacing: 0.04em;
  margin: 12px 0 8px;
}

.panel-label:first-child,
.editor-side .panel-label:first-child,
.editor-tools .panel-label:first-child {
  margin-top: 0;
}

.field {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  font-size: 22px;
  color: #f5c518;
  background: rgba(0, 0, 0, 0.55);
  border: 3px solid #5d4037;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  width: 100%;
  outline: none;
  letter-spacing: 0.5px;
}

.field:focus {
  border-color: #f5c518;
}

.field-area {
  min-height: 140px;
  resize: vertical;
  line-height: 1.3;
}

.pix-btn {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 7px;
  color: #a5d6a7;
  background: rgba(20, 14, 8, 0.8);
  border: 2px solid #5d4037;
  padding: 10px 8px;
  cursor: pointer;
  text-shadow: 1px 1px 0 #1b5e20;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  line-height: 1.4;
}

.pix-btn:hover {
  border-color: #a5d6a7;
  color: #c8e6c9;
}

.pix-btn.is-on {
  border-color: #f5c518;
  color: #ffe082;
  background: rgba(58, 125, 30, 0.4);
}

.pix-btn-gold,
a.pix-btn-gold {
  color: #1a1a1a;
  background: #f5c518;
  border-color: #7c5c00;
  box-shadow: 3px 3px 0 #7c5c00;
  text-shadow: none;
}

.pix-btn-gold:hover,
a.pix-btn-gold:hover {
  background: #ffe066;
  color: #1a1a1a;
}

.pix-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.editor-tools .pix-btn,
.editor-side .pix-btn,
.skin-actions .pix-btn,
.stack-form .pix-btn,
.empty-panel .pix-btn {
  width: 100%;
}

.seg {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.seg .pix-btn {
  flex: 1 1 0;
  width: auto;
}

.editor-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
  width: 100%;
}

.editor-stage-view,
.viewer-stage,
.skin-card-stage {
  background-color: #120e0a;
  background-image:
    linear-gradient(45deg, #241910 25%, transparent 25%),
    linear-gradient(-45deg, #241910 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #241910 75%),
    linear-gradient(-45deg, transparent 75%, #241910 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.editor-stage-view,
.viewer-stage {
  position: relative;
  border: 3px solid #5d4037;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  touch-action: none;
  overflow: hidden;
}

.editor-stage-view {
  height: 640px;
}

.viewer-stage {
  height: 680px;
}

.viewer-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  image-rendering: auto;
  pointer-events: none;
  user-select: none;
}

.editor-stage-view canvas,
.viewer-stage canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.bg-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bg-pick .pix-btn {
  width: 100%;
  white-space: nowrap;
}

.editor-hint,
.fine,
.tool-copy,
.limb-hint,
.result-count {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  color: #d7ccc8;
  letter-spacing: 0.4px;
}

.editor-hint,
.fine {
  margin: 8px 0 0;
  text-align: center;
  font-size: 18px;
}

.limb-hint,
.tool-copy {
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 10px;
}

.result-count {
  margin: 0 0 8px;
  font-size: 20px;
  color: #ffe082;
}

.picker {
  position: relative;
  width: 210px;
  height: 210px;
  margin: 0 auto 8px;
}

#hueWheel {
  display: block;
  width: 210px;
  height: 210px;
  cursor: crosshair;
}

#svBox {
  position: absolute;
  left: 57px;
  top: 57px;
  width: 96px;
  height: 96px;
  cursor: crosshair;
  border: 2px solid #2a2118;
}

.hue-marker,
.sv-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.hex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hex-swatch {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 2px solid #5d4037;
  background: #e53935;
}

.hex-row .field {
  flex: 1;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 18px;
  margin-bottom: 4px;
}

.swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #3e2723;
  cursor: pointer;
}

.swatch:hover {
  border-color: #f5c518;
}

.tex-thumb {
  display: block;
  width: 160px;
  height: 160px;
  margin: 0 auto;
  image-rendering: pixelated;
  background-color: #120e0a;
  background-image:
    linear-gradient(45deg, #241910 25%, transparent 25%),
    linear-gradient(-45deg, #241910 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #241910 75%),
    linear-gradient(-45deg, transparent 75%, #241910 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 2px solid #5d4037;
}

.body-map {
  --u: 6px;
  --gap: 4px;
  position: relative;
  width: calc(var(--u) * 16 + var(--gap) * 2);
  height: calc(var(--u) * 32 + var(--gap) * 2);
  margin: 4px auto 12px;
}

.limb {
  display: block;
  position: absolute;
  padding: 0;
  border: 2px solid #3e2723;
  background: #3a322c;
  cursor: pointer;
}

.limb-head {
  width: calc(var(--u) * 8);
  height: calc(var(--u) * 8);
  left: calc(var(--u) * 4 + var(--gap));
  top: 0;
}

.limb-body {
  width: calc(var(--u) * 8);
  height: calc(var(--u) * 12);
  left: calc(var(--u) * 4 + var(--gap));
  top: calc(var(--u) * 8 + var(--gap));
}

.limb-armR,
.limb-armL {
  width: calc(var(--u) * 4);
  height: calc(var(--u) * 12);
  top: calc(var(--u) * 8 + var(--gap));
}

.limb-armR { left: 0; }
.limb-armL { left: calc(var(--u) * 12 + var(--gap) * 2); }

.limb-legR,
.limb-legL {
  width: calc(var(--u) * 4);
  height: calc(var(--u) * 12);
  top: calc(var(--u) * 20 + var(--gap) * 2);
}

.limb-legR { left: calc(var(--u) * 4 + var(--gap)); }
.limb-legL { left: calc(var(--u) * 8 + var(--gap) * 2); }

.limb.is-on {
  background: #d7ccc8;
  border-color: #a5d6a7;
}

.limb.is-off {
  background: #2a241f;
  border-color: #3e2723;
}

.limb.is-solo {
  background: #ffe082;
  border-color: #f5c518;
}

.editor-msg {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  font-size: 18px;
  min-height: 1.2em;
  margin: 8px 0;
  line-height: 1.3;
  color: #b0bec5;
}

.editor-msg.is-ok { color: #69f0ae; }
.editor-msg.is-err { color: #ff8a80; }

.editor-side .field,
.stack-form .field {
  margin-bottom: 8px;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
}

.skin-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  background: rgba(20, 14, 8, 0.9);
  border: 3px solid #5d4037;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
  padding: 10px;
  min-width: 0;
}

.skin-card:hover {
  border-color: #a5d6a7;
}

.skin-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.skin-card-name,
.skin-side-name {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 7px;
  color: #f5c518;
  text-shadow: 1px 1px 0 #7c5c00;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.skin-card-id,
.skin-id {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  color: #a5d6a7;
  font-size: 20px;
  flex: 0 0 auto;
}

.skin-card-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 2px solid #3e2723;
}

.skin-card-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.skin-fallback {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 8px;
  height: 8px;
  object-fit: none;
  object-position: -8px -8px;
  transform: translateX(-50%) scale(8);
  transform-origin: top center;
  image-rendering: pixelated;
}

.skin-card-stage.is-ready .skin-fallback {
  display: none;
}

.skin-card-cat,
.skin-cat-link {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 6px;
  color: #a5d6a7;
  border: 1px solid #3a7d1e;
  background: rgba(58, 125, 30, 0.18);
  padding: 6px 8px;
  text-shadow: 1px 1px 0 #1b5e20;
  text-decoration: none;
  width: max-content;
  max-width: 100%;
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  align-items: start;
}

.skin-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skin-side .skin-id,
.skin-side .skin-side-name,
.skin-side .fine {
  margin: 0;
}

.skin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-panel {
  background: rgba(20, 14, 8, 0.9);
  border: 3px solid #5d4037;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  padding: 28px 18px;
  text-align: center;
}

.empty-title {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 10px;
  color: #f5c518;
  text-shadow: 2px 2px 0 #7c5c00;
  margin: 0 0 12px;
}

.empty-panel .pix-btn {
  max-width: 240px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.page-btn {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 8px;
  line-height: 1;
  color: #a5d6a7;
  background: rgba(20, 14, 8, 0.75);
  border: 2px solid #5d4037;
  min-width: 34px;
  padding: 10px 8px;
  text-align: center;
  text-decoration: none;
}

a.page-btn:hover {
  background: rgba(58, 125, 30, 0.45);
  border-color: #a5d6a7;
  color: #e8f5e9;
}

.page-btn.is-current {
  background: #2e7d32;
  border-color: #c5e1a5;
  color: #ffe082;
}

.page-btn.is-disabled {
  opacity: 0.35;
}

.page-gap {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 8px;
  color: #78909c;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  border: 3px dashed #8d6e63;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  text-align: center;
  padding: 18px;
}

.dropzone.is-over {
  border-color: #f5c518;
  background: rgba(245, 197, 24, 0.08);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-family: 'Press Start 2P', 'PS2P Fallback', monospace;
  font-size: 8px;
  color: #a5d6a7;
  text-shadow: 1px 1px 0 #1b5e20;
}

.dropzone-sub,
.contact-mail {
  font-family: 'VT323', 'VT323 Fallback', monospace;
  font-size: 20px;
  color: #d7ccc8;
}

.contact-mail a,
.legal-body a {
  color: #81d4fa;
}

.legal-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-form {
  display: flex;
  flex-direction: column;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: #fff;
}

.c1 { width: 80px; height: 24px; top: 10%; left: 5%; animation: drift 18s linear infinite; }
.c1::before { width: 40px; height: 24px; top: -16px; left: 12px; }
.c1::after { width: 28px; height: 16px; top: -8px; left: 40px; }
.c2 { width: 100px; height: 28px; top: 18%; right: 10%; animation: drift 24s linear infinite reverse; }
.c2::before { width: 48px; height: 28px; top: -18px; left: 16px; }
.c2::after { width: 36px; height: 18px; top: -10px; left: 50px; }
.c3 { width: 64px; height: 20px; top: 6%; left: 55%; animation: drift 20s linear infinite 5s; }
.c3::before { width: 32px; height: 20px; top: -14px; left: 10px; }

.sun {
  animation: sunpulse 3s ease-in-out infinite;
}

@keyframes drift {
  from { transform: translateX(-200px); }
  to { transform: translateX(110vw); }
}

@keyframes sunpulse {
  0%, 100% { box-shadow: 0 0 0 8px #ffe97a, 0 0 0 16px rgba(255, 220, 50, 0.25); }
  50% { box-shadow: 0 0 0 12px #ffe97a, 0 0 0 24px rgba(255, 220, 50, 0.35); }
}

@media (max-width: 1100px) {
  .editor-layout,
  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .editor-stage { order: -1; }
  .viewer-main { order: -1; }

  .editor-stage-view,
  .viewer-stage {
    height: 520px;
  }
}

@media (max-width: 980px) {
  .site-navbar > .site-navbar-top > .topnav {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  .nav-search {
    flex: 1 1 100%;
  }

  .nav-search input {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cloud,
  .sun {
    animation: none !important;
  }
}
