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

:root {
  --yl-ink: #f8f0c8;
  --yl-gold: #fff8a0;
  --yl-leaf: #90ee60;
  --yl-panel: rgba(0, 0, 0, 0.42);
  --yl-edge: #5cb832;
}

body {
  font-family: 'Press Start 2P', monospace;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(144, 238, 96, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(80, 140, 40, 0.18) 0%, transparent 45%),
    linear-gradient(180deg, #143208 0%, #2a6018 42%, #1a4010 100%);
  min-height: 100vh;
  color: var(--yl-ink);
  font-size: 10px;
  line-height: 1.6;
}

#yl-app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.yl-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.yl-brand {
  font-size: 8px;
  color: var(--yl-leaf);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.yl-header h1 {
  font-size: clamp(14px, 3vw, 22px);
  color: var(--yl-gold);
  margin-bottom: 8px;
  line-height: 1.45;
  text-shadow: 3px 3px 0 #204010;
}

.yl-tagline {
  font-size: 9px;
  opacity: 0.85;
  max-width: 520px;
}

.yl-header-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 8px;
}

.yl-header-links a {
  color: var(--yl-leaf);
  text-decoration: none;
}

.yl-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.yl-sidebar {
  background: var(--yl-panel);
  border: 3px solid var(--yl-leaf);
  border-radius: 12px;
  padding: 12px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 10px;
}

.yl-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.yl-tab {
  font-family: inherit;
  font-size: 7px;
  padding: 8px 8px;
  background: #16380e;
  border: 2px solid #408028;
  color: var(--yl-ink);
  border-radius: 6px;
  cursor: pointer;
}

.yl-tab.active {
  border-color: var(--yl-gold);
  background: #306818;
  color: var(--yl-gold);
}

.yl-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.yl-piece {
  font-family: inherit;
  font-size: 7px;
  padding: 8px 8px 8px 8px;
  background: #1a4010;
  border: 2px solid var(--yl-edge);
  color: var(--yl-ink);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  min-height: 44px;
}

.yl-piece-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.35);
  flex-shrink: 0;
  image-rendering: pixelated;
}

.yl-piece-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.yl-piece-name { color: #fff; }
.yl-piece-count { color: #c8e8a0; font-size: 6px; }

.yl-piece.active {
  border-color: var(--yl-gold);
  background: #306818;
  box-shadow: 0 0 0 2px rgba(255, 248, 160, 0.22);
}

.yl-piece:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.yl-budget {
  font-size: 7px;
  color: #c8e8a0;
  line-height: 1.7;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
}

.yl-tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.yl-btn {
  font-family: inherit;
  font-size: 8px;
  padding: 11px 10px;
  background: #4080e0;
  border: none;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.yl-btn--muted { background: #505050; }
.yl-btn--sim {
  background: linear-gradient(180deg, #a050d0, #7030a0);
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 10px;
  font-size: 9px;
}
.yl-btn.active { outline: 2px solid var(--yl-gold); }
.yl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.yl-theme-label {
  display: block;
  font-size: 7px;
  color: #c8e8a0;
  margin: 4px 0 10px;
}

.yl-select {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-family: inherit;
  font-size: 7px;
  padding: 10px 8px;
  background: #1a4010;
  color: var(--yl-ink);
  border: 2px solid var(--yl-edge);
  border-radius: 6px;
}

.yl-hint {
  font-size: 7px;
  color: #c8e8a0;
  line-height: 1.7;
  opacity: 0.9;
}

.yl-main {
  min-width: 0;
}

.yl-canvas-wrap {
  position: relative;
  border: 4px solid #f8f0c8;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  background: #1e5010;
}

#yl-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
}

.yl-sim-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(20, 10, 30, 0.88);
  border-top: 2px solid #c080e0;
  font-size: 8px;
}

.yl-msg {
  text-align: center;
  margin-top: 12px;
  font-size: 8px;
  line-height: 1.8;
  color: #e8f0c0;
}

.yl-result {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}

.yl-result[hidden] { display: none !important; }

.yl-result-card {
  background: #1a4010;
  border: 3px solid var(--yl-gold);
  border-radius: 12px;
  padding: 24px 20px;
  max-width: 560px;
  text-align: center;
}

.yl-stars {
  font-size: 18px;
  color: var(--yl-gold);
  letter-spacing: 0.2em;
  margin-bottom: 12px;
}

.yl-result-card p {
  font-size: 10px;
  line-height: 2;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.yl-result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .yl-layout {
    grid-template-columns: 1fr;
  }
  .yl-sidebar {
    position: static;
  }
  .yl-palette {
    max-height: 220px;
  }
}

@media (max-width: 720px) {
  #yl-app { padding: 12px 8px 28px; }
  .yl-piece { font-size: 6px; min-height: 40px; }
  .yl-btn { font-size: 7px; }
}
