:root {
  --ink: #173d42;
  --muted: #6a7f7b;
  --paper: #f4f2e9;
  --line: #d7dfd5;
  --teal: #16756c;
  --amber: #f1b84a;
  --coral: #d76654;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
button,
select,
.file-button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffdf5;
  color: var(--ink);
  padding: 10px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}
button:hover,
a:hover,
.file-button:hover {
  filter: brightness(0.95);
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
header {
  height: 86px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #fffdf6;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 1px;
}
.brandmark {
  position: relative;
  background: var(--ink);
  color: var(--paper);
  width: 44px;
  height: 44px;
  border-radius: 13px;
  text-align: center;
  padding-top: 7px;
  font-size: 25px;
  font-weight: 800;
}
.brandmark span {
  font-size: 17px;
  color: var(--amber);
  position: absolute;
  right: 3px;
  top: 1px;
}
.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 3px;
  margin-top: 5px;
  color: var(--muted);
}
nav {
  display: flex;
  align-items: center;
  gap: 25px;
}
nav a {
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  color: var(--ink);
}
main {
  max-width: 1500px;
  margin: auto;
  padding: 30px 4% 15px;
}
.missionbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 20px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 750;
  color: var(--teal);
}
h1 {
  font-size: 35px;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin: 8px 0;
}
p {
  line-height: 1.65;
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0;
}
.mission-select {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mission-select label {
  font-size: 9px;
  letter-spacing: 2px;
}
.mission-select select {
  max-width: 185px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 20px;
}
.battlefield {
  min-height: 610px;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #cbd8cc;
  background: #dbe6da;
  box-shadow: 0 10px 30px #203b3610;
  display: flex;
  flex-direction: column;
}
.hud {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 30px;
  pointer-events: none;
}
.hud div {
  border-right: 1px solid #b4c6b6;
  padding-right: 28px;
}
.hud small {
  display: block;
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #5e7a6c;
  font-weight: 700;
}
.hud strong {
  font-size: 23px;
  display: block;
  margin-top: 3px;
}
.pill {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 7px 10px;
  border-radius: 20px;
  background: #fffdf6b8;
  color: var(--teal);
  font-weight: 700;
}
canvas {
  display: block;
  width: 100%;
  height: 580px;
  flex: 1;
  min-height: 400px;
}
.board-footer {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #ffffff77;
  font-size: 10px;
  color: #587267;
  letter-spacing: 0.5px;
}
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #1c9471;
  border-radius: 50%;
  margin-right: 6px;
}
aside {
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.aside-heading h2 {
  font-size: 22px;
  letter-spacing: -0.7px;
  margin: 8px 0;
}
.aside-heading p {
  font-size: 11px;
  margin-bottom: 17px;
}
.tower-card {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  margin-bottom: 8px;
  padding: 7px 12px 7px 6px;
  border-radius: 11px;
  position: relative;
  min-height: 70px;
  background: #f6f5ed;
}
.tower-card.active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
  background: #e9f2e8;
}
.tower-card img {
  width: 62px;
  height: 62px;
  object-fit: contain;
}
.tower-card strong {
  display: block;
  font-size: 13px;
}
.tower-card small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  font-weight: 450;
  margin-top: 4px;
}
.tower-card .cost {
  margin-left: auto;
  font-size: 12px;
  color: var(--teal);
}
.selection {
  border-top: 1px solid var(--line);
  margin-top: 17px;
  padding-top: 14px;
  min-height: 142px;
}
.selection h3 {
  font-size: 15px;
  margin: 8px 0;
}
.selection p {
  font-size: 11px;
  min-height: 35px;
}
.row {
  display: flex;
  gap: 7px;
  align-items: center;
}
.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf4;
  padding: 13px 20px;
}
.wide {
  width: 100%;
  margin-top: 17px;
}
.quiet {
  background: transparent;
}
.transport {
  margin: 9px 0;
}
.transport button {
  flex: 1;
  font-size: 11px;
  padding: 8px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0;
}
.toggle input {
  accent-color: var(--teal);
}
.hint {
  font-size: 9px;
  line-height: 1.8;
}
.file-button {
  display: inline-block;
  font-size: 10px;
  padding: 8px;
}
.file-button input {
  display: none;
}
#save-replay {
  font-size: 10px;
  padding: 8px;
}
.overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #f1f4e9df;
  backdrop-filter: blur(4px);
  padding: 30px;
}
.overlay[hidden] {
  display: none;
}
.overlay h2 {
  font-size: 60px;
  line-height: 1;
  letter-spacing: -3px;
  margin: 20px 0;
}
.overlay p {
  font-size: 15px;
  max-width: 400px;
  margin-bottom: 25px;
}
.overlay small {
  font-size: 8px;
  letter-spacing: 1.2px;
  margin-top: 24px;
}
.overlay .primary {
  padding: 16px 30px;
}
footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 22px 0;
}
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 13px 24px;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  z-index: 10;
  font-size: 13px;
  box-shadow: 0 8px 40px #0002;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#toast.show {
  opacity: 1;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 35px;
  max-width: 550px;
  background: #fffdf6;
  color: var(--ink);
}
dialog::backdrop {
  background: #102d3cd0;
}
.close {
  float: right;
}
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}
.editor-layout textarea {
  width: 100%;
  height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5ec;
  color: var(--ink);
  font: 11px/1.5 monospace;
  padding: 10px;
}
.editor-layout label {
  font-size: 11px;
  display: block;
  margin: 12px 0 6px;
}
.editor-layout input,
.editor-layout select {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.validation {
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--coral);
}
.validation.ok {
  color: var(--teal);
}
@media (max-width: 1000px) {
  main {
    padding: 20px;
  }
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 255px;
  }
  .mission-select label {
    display: none;
  }
  .hud {
    gap: 15px;
  }
  .hud div {
    padding-right: 15px;
  }
  header {
    padding: 0 20px;
  }
  nav {
    gap: 15px;
  }
}
@media (max-width: 760px) {
  header {
    height: auto;
    min-height: 80px;
    padding: 16px;
    gap: 12px;
    flex-wrap: wrap;
  }
  nav {
    gap: 15px;
  }
  .missionbar {
    align-items: flex-start;
    flex-direction: column;
  }
  h1 {
    font-size: 28px;
  }
  .game-layout,
  .editor-layout {
    grid-template-columns: 1fr;
  }
  .battlefield {
    min-height: 480px;
  }
  canvas {
    height: 460px;
  }
  .overlay h2 {
    font-size: 42px;
  }
  .hud {
    left: 12px;
    right: 12px;
    gap: 12px;
  }
  .hud small {
    font-size: 7px;
  }
  .hud strong {
    font-size: 20px;
  }
  .hud div {
    padding-right: 12px;
  }
  footer {
    gap: 20px;
    font-size: 8px;
  }
  aside {
    padding: 18px;
  }
  .tower-card {
    width: 100%;
  }
}

/* Public demo navigation */
.demo-links{display:flex;gap:18px;font:600 12px system-ui}.demo-links a{color:inherit;text-decoration:underline;text-underline-offset:4px}@media(max-width:650px){header{flex-wrap:wrap;gap:12px}.demo-links{width:100%;justify-content:space-between}}
