:root {
  color-scheme: dark;
  --night: #0b1510;
  --panel: #14231a;
  --panel-2: #1b2e21;
  --line: #36503d;
  --ink: #f6f6e8;
  --muted: #b9c8b7;
  --leaf: #d6f36f;
  --mint: #7ce0b1;
  --honey: #ffc45b;
  --soil: #9a633b;
  --danger: #ff8b73;
  --display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  min-width: 280px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 4%, rgba(124, 224, 177, .11), transparent 30rem),
    var(--night);
  font-family: var(--body);
  line-height: 1.5;
}

button, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }

.site-header, main, footer {
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; color: var(--night); background: var(--leaf); border-radius: 9px; font-family: var(--display); }
.all-games { color: var(--muted); font-size: .82rem; font-weight: 800; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; }
.all-games:hover, .all-games:focus-visible { color: var(--leaf); }

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 36px;
  align-items: end;
  padding: 48px 0 30px;
}

.eyebrow { margin: 0 0 9px; color: var(--leaf); font-size: .72rem; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-family: var(--display); font-size: clamp(2.8rem, 6vw, 5rem); line-height: .95; letter-spacing: -.055em; }
.game-heading > p { margin: 0 0 4px; color: var(--muted); font-size: 1.02rem; }

.game-shell { padding: 16px; background: rgba(20, 35, 26, .94); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 28px 80px rgba(0, 0, 0, .24); }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.hud > div { min-width: 0; padding: 10px 13px; background: #0e1b13; border: 1px solid #2a4332; border-radius: 12px; }
.hud span { display: block; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hud strong { display: block; overflow: hidden; font-size: .98rem; text-overflow: ellipsis; white-space: nowrap; }

.play-layout { display: grid; grid-template-columns: minmax(0, 840px) minmax(230px, 1fr); gap: 14px; align-items: start; }
.board-wrap { position: relative; overflow: hidden; background: #294d2f; border: 1px solid #47684d; border-radius: 16px; }
#game-canvas { display: block; width: 100%; height: auto; aspect-ratio: 21 / 13; outline: none; touch-action: none; user-select: none; }
#game-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--leaf); }

.build-panel { display: grid; gap: 12px; }
.panel-heading { display: flex; gap: 10px; align-items: center; }
.panel-heading > span { display: grid; flex: 0 0 27px; height: 27px; place-items: center; color: var(--night); background: var(--leaf); border-radius: 50%; font-size: .75rem; font-weight: 900; }
.panel-heading strong, .panel-heading small { display: block; }
.panel-heading strong { font-size: .9rem; }
.panel-heading small { color: var(--muted); font-size: .72rem; line-height: 1.35; }

.tower-list { display: grid; gap: 7px; }
.tower-choice {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 60px;
  padding: 8px 9px;
  color: var(--ink);
  background: #101e15;
  border: 1px solid #304937;
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
}
.tower-choice:hover, .tower-choice:focus-visible, .tower-choice.is-selected { border-color: var(--leaf); background: #1c3021; outline: none; }
.tower-choice.is-selected { box-shadow: inset 3px 0 var(--leaf); }
.tower-choice strong, .tower-choice small { display: block; }
.tower-choice strong { font-size: .78rem; }
.tower-choice small { color: var(--muted); font-size: .65rem; line-height: 1.3; }
.tower-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; font-size: 1.2rem; font-weight: 900; }
.tower-icon--pebble { color: #ebe8db; background: #59675e; }
.tower-icon--mint { color: #09251a; background: var(--mint); }
.tower-icon--honey { color: #4a2607; background: var(--honey); }

.selection-card { display: grid; gap: 10px; padding: 12px; background: #0e1b13; border: 1px solid #2a4332; border-radius: 12px; }
.upgrade-button, .game-controls button, .outcome button {
  min-height: 43px;
  padding: 8px 14px;
  color: var(--ink);
  background: #243a2b;
  border: 1px solid #496251;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 850;
}
.upgrade-button:hover:not(:disabled), .upgrade-button:focus-visible, .game-controls button:hover:not(:disabled), .game-controls button:focus-visible { border-color: var(--leaf); outline: none; }
button:disabled { cursor: not-allowed; opacity: .48; }

.game-controls { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(3, minmax(100px, 1fr)); gap: 8px; margin-top: 12px; }
.game-controls .primary, .outcome button { color: #15200e; background: var(--leaf); border-color: var(--leaf); }
.message { min-height: 24px; margin: 9px 4px 0; color: var(--muted); font-size: .82rem; text-align: center; }
.message.is-alert { color: var(--danger); }

.outcome { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; padding: 28px; text-align: center; background: rgba(6, 16, 10, .88); backdrop-filter: blur(4px); }
.outcome[hidden] { display: none; }
.outcome-kicker { margin-bottom: 6px; color: var(--leaf); font-size: .75rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.outcome h2 { margin-bottom: 8px; font-family: var(--display); font-size: clamp(2rem, 6vw, 4.6rem); letter-spacing: -.04em; }
.outcome p:not(.outcome-kicker) { max-width: 440px; margin: 0 auto 18px; color: var(--muted); }
.outcome button { justify-self: center; min-width: 150px; }

.instructions { display: grid; grid-template-columns: minmax(0, .85fr) minmax(420px, 1.15fr); gap: clamp(32px, 7vw, 90px); padding: 70px 0; }
.instructions h2 { margin-bottom: 14px; font-family: var(--display); font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1; letter-spacing: -.045em; }
.instructions > div > p:last-child, .enemy-guide p { color: var(--muted); }
.enemy-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.enemy-guide article { display: flex; gap: 11px; align-items: center; padding: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.enemy-guide h3, .enemy-guide p { margin: 0; }
.enemy-guide h3 { font-size: .84rem; }
.enemy-guide p { font-size: .72rem; }
.ant-mark { position: relative; flex: 0 0 36px; height: 20px; }
.ant-mark::before, .ant-mark::after { position: absolute; top: 5px; content: ""; background: #171510; border: 2px solid #e9e3c8; border-radius: 50%; }
.ant-mark::before { left: 2px; width: 12px; height: 9px; }
.ant-mark::after { right: 1px; width: 17px; height: 12px; }
.ant-mark--scout { border-top: 3px double var(--leaf); }
.ant-mark--guard::after { border-width: 4px; border-radius: 45%; }
.ant-mark--queen { display: grid; height: 36px; place-items: center; color: var(--honey); border: 2px solid var(--honey); border-radius: 50%; font-size: 1.2rem; }
.ant-mark--queen::before, .ant-mark--queen::after { display: none; }

footer { display: flex; justify-content: space-between; padding: 26px 0 42px; color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; }
footer a { color: var(--ink); font-weight: 850; text-decoration: none; }

@media (max-width: 900px) {
  .game-heading { grid-template-columns: 1fr; gap: 14px; }
  .play-layout { grid-template-columns: 1fr; }
  .build-panel { grid-template-columns: minmax(0, 1.25fr) minmax(220px, .75fr); }
  .build-panel > .panel-heading { grid-column: 1 / -1; }
  .tower-list { grid-template-columns: repeat(3, 1fr); }
  .tower-choice { grid-template-columns: 34px minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .site-header, main, footer { width: min(100% - 20px, 1180px); }
  .site-header { min-height: 62px; }
  .game-heading { padding: 28px 2px 20px; }
  .game-heading > p { font-size: .9rem; }
  h1 { font-size: 2.75rem; }
  .game-shell { padding: 8px; border-radius: 15px; }
  .hud { grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 7px; }
  .hud > div { padding: 6px 9px; border-radius: 9px; }
  .hud span { font-size: .58rem; }
  .hud strong { font-size: .83rem; }
  .board-wrap { border-radius: 10px; }
  .build-panel { grid-template-columns: 1fr; gap: 8px; }
  .build-panel > .panel-heading { display: none; }
  .tower-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .tower-choice { display: flex; min-height: 70px; padding: 6px; flex-direction: column; gap: 3px; text-align: center; }
  .tower-icon { width: 30px; height: 25px; border-radius: 7px; font-size: .95rem; }
  .tower-choice strong { font-size: .67rem; line-height: 1.12; }
  .tower-choice small { font-size: .56rem; }
  .selection-card { padding: 8px; grid-template-columns: minmax(0, 1fr) minmax(125px, auto); align-items: center; }
  .selection-card .panel-heading > span { display: none; }
  .selection-card .panel-heading { gap: 0; }
  .selection-card .panel-heading strong { font-size: .74rem; }
  .selection-card .panel-heading small { font-size: .62rem; }
  .upgrade-button { min-height: 40px; padding: 6px 8px; font-size: .68rem; }
  .game-controls { grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
  .game-controls button { min-height: 42px; padding: 6px; font-size: .75rem; }
  .message { margin-top: 6px; font-size: .72rem; }
  .instructions { grid-template-columns: 1fr; gap: 24px; padding: 52px 2px; }
  .enemy-guide { gap: 6px; }
  .enemy-guide article { gap: 7px; padding: 8px; }
  .enemy-guide p { display: none; }
  .ant-mark { flex-basis: 29px; transform: scale(.8); }
  footer { gap: 20px; }
}

@media (max-width: 350px) {
  .tower-choice small { display: none; }
  .selection-card { grid-template-columns: 1fr; }
  .enemy-guide { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
