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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- control panel ---------- */

#panel-root {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 300px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  color: #cfd8cf;
  font-size: 12px;
  scrollbar-width: thin;
  scrollbar-color: #3a4a3a transparent;
}

.pl-panel {
  background: rgba(8, 12, 8, 0.88);
  border: 1px solid #1d2a1d;
  border-radius: 6px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.pl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #1d2a1d;
}

.pl-header .pl-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #e6efe6;
}

.pl-section {
  border-bottom: 1px solid #172117;
}
.pl-section:last-child { border-bottom: none; }

.pl-section-head {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 600;
  color: #9fb59f;
}
.pl-section-head:hover { color: #d8e8d8; }
.pl-section-head .arrow {
  margin-left: auto;
  transition: transform 0.15s;
  font-size: 9px;
}
.pl-section.collapsed .arrow { transform: rotate(180deg); }
.pl-section.collapsed .pl-section-body { display: none; }

.pl-section-body { padding: 4px 12px 10px; }

.pl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
  min-height: 20px;
}

.pl-row label {
  flex: 0 0 108px;
  color: #8fa58f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-row input[type="range"] {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #26332638;
  border: 1px solid #2c3a2c;
  border-radius: 2px;
  outline: none;
}
.pl-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 18px;
  border-radius: 2px;
  background: #dfe8df;
  border: 1px solid #666;
  cursor: pointer;
}
.pl-row input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 18px;
  border-radius: 2px;
  background: #dfe8df;
  border: 1px solid #666;
  cursor: pointer;
}

.pl-row .val {
  flex: 0 0 40px;
  font-size: 11px;
  text-align: right;
  color: #d5e5d5;
  font-variant-numeric: tabular-nums;
}

.pl-row input[type="text"], .pl-row input[type="number"] {
  flex: 1;
  min-width: 0;
  background: #f2f5f2;
  color: #111;
  border: none;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 12px;
}

.pl-btn {
  background: transparent;
  color: #9fe89f;
  border: 1px solid #3f6a3f;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.pl-btn:hover { background: #1c2e1c; color: #c9ffc9; }
.pl-btn.warn { color: #e8b06a; border-color: #7a5a2c; }
.pl-btn.warn:hover { background: #2e2413; color: #ffd9a0; }
.pl-btn.wide { width: 100%; margin: 4px 0; }

.pl-check {
  width: 15px;
  height: 15px;
  accent-color: #6fbf6f;
  cursor: pointer;
}

.pl-info {
  color: #7d917d;
  font-size: 11px;
  line-height: 1.5;
}
.pl-info b { color: #cfe5cf; font-weight: 600; }

/* ---------- matrix editor ---------- */

.pl-matrix {
  display: grid;
  gap: 2px;
  margin: 6px 0 2px;
  touch-action: none;
}
.pl-matrix .mcell {
  aspect-ratio: 1;
  border-radius: 2px;
  cursor: ns-resize;
  position: relative;
}
.pl-matrix .mhead {
  aspect-ratio: 1;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  width: 60%;
}
.pl-matrix .mcorner { background: transparent; }

.pl-hint {
  color: #63755f;
  font-size: 10px;
  margin-top: 4px;
}

@media (max-width: 640px) {
  #panel-root { width: 260px; font-size: 11px; }
  .pl-row label { flex-basis: 92px; }
}

/* ---------- build 02: header badge + menu link ---------- */

.pl-menu-link {
  color: #6fbf6f;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  padding: 0 4px;
  line-height: 1;
}
.pl-menu-link:hover { color: #c9ffc9; }

.pl-build-badge {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: #6fbf6f;
  border: 1px solid #3f6a3f;
  border-radius: 3px;
  padding: 2px 5px;
  white-space: nowrap;
}

/* ---------- build 02: presets ---------- */

.pl-select {
  flex: 1;
  min-width: 0;
  background: #101710;
  color: #cfe5cf;
  border: 1px solid #2c3a2c;
  border-radius: 3px;
  padding: 5px 6px;
  font-size: 12px;
}

/* ---------- build 02: matrix mutation flash ---------- */

@keyframes pl-mutate-flash {
  0% { box-shadow: 0 0 0 2px #fff, 0 0 12px 4px #9fe89f; }
  100% { box-shadow: none; }
}
.pl-matrix .mcell.mutated { animation: pl-mutate-flash 1.2s ease-out; }

/* ---------- build 02: achievements ---------- */

.pl-ach-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.pl-ach {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  border: 1px solid #172117;
  border-radius: 4px;
  opacity: 0.55;
}
.pl-ach.got { opacity: 1; border-color: #3f6a3f; background: #0d140d; }
.pl-ach-name { font-size: 11px; font-weight: 600; color: #cfe5cf; }
.pl-ach-desc { font-size: 10px; color: #7d917d; }

/* ---------- build 02: toasts ---------- */

.pl-toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
  pointer-events: none;
}
.pl-toast {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(10, 18, 10, 0.95);
  border: 1px solid #3f6a3f;
  border-radius: 6px;
  padding: 10px 14px;
  min-width: 220px;
  max-width: 320px;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  box-shadow: 0 6px 24px rgba(60, 160, 60, 0.25);
}
.pl-toast.show { transform: translateX(0); }
.pl-toast b { font-size: 10px; letter-spacing: 0.12em; color: #9fe89f; }
.pl-toast span { font-size: 14px; font-weight: 600; color: #e6efe6; }
.pl-toast em { font-size: 11px; font-style: normal; color: #8fa58f; }

/* header: keep title + badge + restart on one line */
.pl-header { flex-wrap: nowrap; }
.pl-header .pl-title { font-size: 12px; white-space: nowrap; flex: 0 1 auto; }
.pl-header .pl-build-badge { margin-right: auto; }
