:root {
  color-scheme: dark;
  --bg: #14120e;
  --panel: rgba(22, 24, 18, 0.92);
  --line: #8d7844;
  --text: #efe6d4;
  --muted: #b7ad98;
  --accent: #e0b45a;
  --good: #9dcc73;
  --danger: #e07058;
  font-family: "Segoe UI", Bahnschrift, sans-serif;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

#view {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  background: #6d5a3e;
}

#topbar, #left, #right, #bottom, #toast {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

#topbar {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  letter-spacing: 0.08em;
}

#topbar strong { font-size: 14px; }
.ver { color: var(--accent); font-size: 12px; }
#mode { color: var(--accent); font-weight: 700; font-size: 13px; }

#left, #right {
  top: 58px;
  width: 270px;
  max-height: calc(100% - 130px);
  overflow: auto;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  pointer-events: auto;
}

#left { left: 12px; }
#right { right: 12px; }
.hidden { display: none; }

h2 {
  margin: 0 0 6px;
  font-size: 15px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.lede, .fine, #place-status, #st-mobility, #st-weapon {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

#part-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }

.part {
  text-align: left;
  color: var(--text);
  background: #2a2c24;
  border: 1px solid #5c5644;
  border-radius: 3px;
  padding: 6px 8px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
}

.part small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.part b { color: var(--accent); }
.part.selected { border-color: var(--good); background: #31382a; box-shadow: inset 0 0 0 1px var(--good); }
.part.empty { opacity: 0.45; }
.part[data-family="hull"] { border-left: 3px solid #8ea05f; }
.part[data-family="engine"] { border-left: 3px solid #d7b15a; }
.part[data-family="track"] { border-left: 3px solid #6a6458; }
.part[data-family="hover_fan"] { border-left: 3px solid #7eb6d6; }
.part[data-family="wheel"] { border-left: 3px solid #c46a4a; }
.part[data-family="armor"] { border-left: 3px solid #b7c0c6; }
.part.worn { background: #34281f; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select {
  background: #12140f;
  color: var(--text);
  border: 1px solid #5c5644;
  border-radius: 3px;
  padding: 6px 8px;
}

.row { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.row button { flex: 1; }
#build-gaps { min-height: 1.2em; color: var(--accent); }
button {
  background: #3a3426;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 8px;
  cursor: pointer;
}
button:hover { background: #4a4332; }

dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin: 8px 0;
  font-size: 13px;
}
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.core { margin: 8px 0; font-size: 13px; }
.bar {
  margin-top: 4px;
  height: 8px;
  background: #2a241c;
  border: 1px solid #5c5644;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8a3a2a, #d7b15a);
}

#bottom {
  left: 292px;
  right: 292px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
  font-size: 13px;
}
#weapon { color: var(--accent); }
#heat {
  width: min(420px, 100%);
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
#heat .bar { margin-top: 3px; }
#controls { color: var(--muted); font-size: 12px; }

#toast {
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 560px;
  padding: 8px 12px;
  background: rgba(28, 22, 16, 0.94);
  border: 1px solid var(--accent);
  border-radius: 4px;
  opacity: 0;
}
#toast.show { opacity: 1; }

#reset-sandbox { width: 100%; margin-top: 8px; }

/* V0.2.2 public release shell */
.brand {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.alpha-badge {
  padding: 2px 6px;
  border: 1px solid rgba(224, 180, 90, 0.65);
  border-radius: 999px;
  color: #f1cf84;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.top-action {
  pointer-events: auto;
  padding: 4px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wide-action {
  width: 100%;
  margin-top: 6px;
}

.release-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 42%, rgba(112, 91, 52, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(10, 11, 9, 0.64), rgba(10, 9, 7, 0.9));
  backdrop-filter: blur(3px);
}

.release-overlay.hidden { display: none; }

.release-card {
  width: min(760px, 100%);
  padding: 30px;
  border: 1px solid #8d7844;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(31, 31, 24, 0.98), rgba(18, 19, 15, 0.98));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.04);
}

.release-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.release-card h1 {
  margin: 6px 0 0;
  font-size: clamp(38px, 7vw, 72px);
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.release-tagline {
  margin: 10px 0 6px;
  color: #f1cf84;
  font-size: clamp(18px, 2.5vw, 25px);
  font-weight: 650;
  letter-spacing: 0.04em;
}

.release-copy {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.release-actions {
  display: flex;
  gap: 10px;
  margin: 22px 0 18px;
  flex-wrap: wrap;
}

.release-actions button {
  min-width: 180px;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-action {
  border-color: #d2a64f;
  background: #5b4926;
  color: #fff2cf;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 145, 0.12);
}

.primary-action:hover { background: #725b2f; }

.quick-start {
  padding-top: 14px;
  border-top: 1px solid rgba(141, 120, 68, 0.45);
}

.quick-start h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.starter-grid button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 58px;
  padding: 9px 11px;
  text-align: left;
}

.starter-grid b { color: var(--text); }
.starter-grid span { color: var(--muted); font-size: 11px; }

.release-note {
  margin: 16px 0 0;
  color: #8f8877;
  font-size: 11px;
  line-height: 1.45;
}

#help-dialog {
  width: min(780px, calc(100vw - 30px));
  max-height: min(760px, calc(100vh - 30px));
  overflow: auto;
  padding: 22px;
  color: var(--text);
  background: #181914;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

#help-dialog::backdrop {
  background: rgba(6, 7, 5, 0.76);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  margin-top: 5px;
  font-size: 24px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.help-grid section {
  padding: 12px;
  background: #21231c;
  border: 1px solid #514b3b;
  border-radius: 5px;
}

.help-grid h3 {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.help-grid p, .dialog-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.control-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0;
}

.control-table span {
  padding: 7px 8px;
  background: #11130f;
  border: 1px solid #3f3b30;
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  display: inline-block;
  min-width: 24px;
  margin-right: 4px;
  padding: 2px 5px;
  color: #fff0c7;
  background: #373124;
  border: 1px solid #6c5d39;
  border-radius: 3px;
  font: 600 11px "Segoe UI", sans-serif;
  text-align: center;
}

.setting-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 14px;
  color: var(--text);
  font-size: 12px;
}

.setting-row input { accent-color: #d7b15a; }

@media (max-width: 1500px) {
  #left, #right { width: 245px; }
  #bottom { left: 262px; right: 262px; }
  .part { padding: 5px 7px; }
  .part small { font-size: 10px; }
}

@media (max-width: 1200px) {
  #left, #right { width: 224px; top: 54px; max-height: calc(100% - 118px); padding: 9px; }
  #left { left: 8px; }
  #right { right: 8px; }
  #bottom { left: 240px; right: 240px; bottom: 7px; font-size: 12px; }
  #controls { font-size: 10px; }
  #topbar { top: 7px; padding: 6px 9px; gap: 10px; }
  .alpha-badge { display: none; }
  dl { font-size: 12px; }
}

@media (max-height: 800px) {
  #left, #right { top: 50px; max-height: calc(100% - 106px); }
  #part-list { gap: 4px; margin: 5px 0; }
  .part { padding-top: 4px; padding-bottom: 4px; }
  .lede, .fine, #place-status, #st-mobility, #st-weapon { font-size: 10px; }
  .release-card { padding: 22px; }
}

@media (max-width: 760px) {
  .starter-grid, .help-grid, .control-table { grid-template-columns: 1fr; }
  .release-overlay { padding: 14px; }
  .release-card { padding: 18px; }
}
