.ants-page {
  --ants-paper: #fffaf0;
  --ants-card: #fffdf7;
  --ants-line: #e9dfc9;
  --ants-ink: #283d27;
  --ants-muted: #59644d;
  --ants-green: #315634;
  --ants-leaf: #d2e6a7;
  --ants-red: #ba3e2a;
  --ants-orange: #c94a33;
  --ants-frame-width: min(100% - 64px, 1152px);
  --ants-nav-height: 76px;
  min-height: 100dvh;
  background: var(--ants-paper);
  color: var(--ants-ink);
  font-family: Nunito, system-ui, sans-serif;
}

.ants-top, .ants-game {
  width: var(--ants-frame-width);
  margin-inline: auto;
}
.ants-game { position: relative; padding-block: 26px 34px; }

.ants-game [hidden] { display: none !important; }
.ants-game :is(h1, h2, p, dl, dd) { margin: 0; }
.ants-game :where(button) { font: inherit; touch-action: manipulation; }
.ants-game button:enabled { cursor: pointer; }
.ants-page :is(button, a):focus-visible { outline: 3px solid #513e93; outline-offset: 4px; }
.ants-top a { color: inherit; text-decoration: none; }
.ants-page .ui-icon { flex: none; }

.ants-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--ants-nav-height);
  border-bottom: 1px solid var(--ants-line);
}

.ants-back, .ants-brand, .ants-tools { display: flex; align-items: center; gap: 9px; }
.ants-back { justify-self: start; min-height: 44px; font-size: .91rem; font-weight: 900; }
.ants-back:hover, .ants-brand:hover { color: var(--ants-red); }
.ants-brand { font-size: 1rem; font-weight: 1000; white-space: nowrap; }
.ants-brand > span {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  background: #f6e6d3;
  color: var(--ants-red);
}
.ants-brand svg { width: 17px; height: 17px; }
.ants-tools { position: absolute; top: calc((var(--ants-nav-height) + 44px) / -2); right: 0; }
.ants-icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ants-line);
  border-radius: 13px;
  background: var(--ants-card);
  color: var(--ants-ink);
}
.ants-icon-button:hover { background: #f3ecd9; }
.ants-shrink, .is-fullscreen .ants-expand { display: none; }
.is-fullscreen .ants-shrink { display: block; }
.ants-page .ui-game-fullscreen.is-fullscreen,
.ants-page .ui-game-fullscreen::backdrop { background: var(--ants-paper); }
.ants-page .ui-game-fullscreen.is-fullscreen > .ui-game-fullscreen__content { padding-top: 0; }
.is-fullscreen .ants-tools { top: 13px; }

.ants-intro { margin-bottom: 23px; }
.ants-intro .ants-intro-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #4a6534;
  font-size: .75rem;
  font-weight: 1000;
  letter-spacing: .115em;
  text-transform: uppercase;
}
.ants-intro-label svg { width: 17px; height: 17px; }
.ants-intro h1 {
  margin-block: 3px 4px;
  color: var(--ants-ink);
  font-size: clamp(3rem, 5.25vw, 4.75rem);
  font-weight: 1000;
  letter-spacing: -.063em;
  line-height: 1.05;
}
.ants-intro h1 span { color: var(--ants-red); }
.ants-intro > p:last-child { color: var(--ants-muted); font-size: 1.02rem; font-weight: 700; }

.ants-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(282px, 315px);
  grid-template-areas: "board score" "board options" "board ." "guide guide";
  align-items: start;
  gap: 16px 23px;
}
.ants-board {
  grid-area: board;
  overflow: hidden;
  border: 1px solid #31492d;
  border-radius: 23px;
  background: #395830;
  box-shadow: 0 5px 0 #273e29, 0 12px 28px #273e291a;
}
.ants-board-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 5px 19px;
  background: var(--ants-green);
  color: #fffbed;
}
.ants-scene-picker { position: relative; display: flex; align-items: center; min-width: 0; }
.ants-scene-picker > svg { position: absolute; left: 9px; color: var(--ants-leaf); pointer-events: none; }
.ants-scene-picker::after {
  position: absolute;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--ants-leaf);
  border-bottom: 2px solid var(--ants-leaf);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
  content: "";
}
.ants-scene-picker select {
  appearance: none;
  max-width: 100%;
  min-height: 44px;
  padding: 0 30px 0 38px;
  border: 1px solid #afc49840;
  border-radius: 12px;
  background: #233f2b70;
  color: inherit;
  font: inherit;
  font-weight: 900;
}
.ants-scene-picker select:enabled { cursor: pointer; }
.ants-scene-picker select:focus-visible { outline: 2px solid var(--ants-leaf); outline-offset: 2px; }
.ants-scene-picker option { background: var(--ants-green); color: #fffbed; }
.ants-board-state {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid #afc49840;
  border-radius: 99px;
  background: #233f2b70;
  color: #f8f5dc;
  font-size: .77rem;
  font-weight: 900;
  white-space: nowrap;
}
.ants-board-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e8edaf; }
.ants-game[data-state="running"] .ants-board-state::before { background: #c1ed78; }
.ants-game[data-state="paused"] .ants-board-state::before { background: #ffd183; }
.ants-field {
  position: relative;
  aspect-ratio: 1.69;
  min-height: 335px;
  overflow: hidden;
  isolation: isolate;
}
.ants-stage-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.ants-field { container-type: inline-size; }
.ants-preview, .ants-key-grid, .ants-swarm {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ants-preview { visibility: hidden; }
.ants-game[data-state="ready"] .ants-preview { visibility: visible; }
.ants-preview img, .ants-target, .ants-remnant {
  position: absolute;
  width: clamp(54px, 10.8cqw, 86px);
  height: auto;
  aspect-ratio: 300 / 384;
}
.ants-preview img {
  left: var(--ant-x);
  top: var(--ant-y);
  transform: translate(-50%, -50%) rotate(var(--ant-heading)) scale(var(--ant-scale, 1));
  filter: drop-shadow(0 3px 3px #2f1d1678);
}
.ants-preview img:nth-child(1) { --ant-x: 23%; --ant-y: 57%; --ant-heading: 66deg; }
.ants-preview img:nth-child(2) { --ant-x: 46%; --ant-y: 25%; --ant-heading: 153deg; --ant-scale: .88; }
.ants-preview img:nth-child(3) { --ant-x: 78%; --ant-y: 46%; --ant-heading: -103deg; --ant-scale: .93; }
.ants-preview img:nth-child(4) { --ant-x: 59%; --ant-y: 80%; --ant-heading: -31deg; }

.ants-key-grid {
  display: none;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}
.ants-game[data-state="running"][data-keys] .ants-key-grid { display: grid; }
.ants-key-grid span {
  display: grid;
  align-items: start;
  justify-items: start;
  padding: 6px;
  border: 1px dashed #fff6ceb0;
}
.ants-key-grid kbd {
  min-width: 20px;
  padding: 1px 3px;
  border-radius: 5px;
  background: #2e482f;
  color: #fff7dc;
  font: inherit;
  font-size: .75rem;
  font-weight: 1000;
  text-align: center;
}

.ants-target {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 42%;
  background: transparent;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.ants-target:focus-visible {
  z-index: 1;
  outline-color: #fff8d2 !important;
  box-shadow: 0 0 0 7px #2c4b36;
}
.ants-sprite {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px #2f1d1678);
  pointer-events: none;
  user-select: none;
  animation: ants-step 145ms ease-in-out infinite alternate;
}
.ants-game[data-state="paused"] .ants-sprite { animation-play-state: paused; }
@keyframes ants-step {
  from { transform: rotate(-4deg) scale(.97, 1); }
  to { transform: rotate(4deg) scale(1, .98); }
}

.ants-remnant {
  transform: translate(-50%, -50%) rotate(var(--ant-heading)) scale(1.16, .59);
  filter: brightness(.79) saturate(.75);
  pointer-events: none;
  user-select: none;
  animation: ants-remnant-fade 1.15s linear both;
}
@keyframes ants-remnant-fade {
  0%, 23% { opacity: .92; }
  100% { opacity: 0; }
}

.ants-pop {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  width: max-content;
  padding: 2px 10px;
  border-radius: 99px;
  background: #fff4b3;
  box-shadow: 0 2px 0 #744321;
  color: #773414;
  font-size: 1.08rem;
  font-weight: 1000;
  pointer-events: none;
  animation: ants-pop 400ms ease-out;
}
.ants-pop svg { width: 14px; height: 14px; }
@keyframes ants-pop {
  0% { transform: translate(-50%, -50%) scale(.8); opacity: 0; }
  20%, 65% { opacity: 1; }
  100% { transform: translate(-50%, calc(-50% - 23px)) scale(1.06); opacity: 0; }
}

.ants-card {
  padding: 17px;
  border: 1px solid var(--ants-line);
  border-radius: 21px;
  background: var(--ants-card);
  box-shadow: 0 3px 0 #e9dfc958;
}
.ants-card h2 { display: flex; align-items: center; gap: 8px; font-size: 1.13rem; font-weight: 1000; }
.ants-card-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f6e8db;
  color: var(--ants-red);
}
.ants-card-icon svg { width: 17px; height: 17px; }
.ants-score-card { grid-area: score; }
.ants-score-card .ants-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.ants-stat {
  min-width: 0;
  padding: 10px 11px 8px;
  border-radius: 13px;
  background: #f7ebdf;
  color: #973723;
}
.ants-stat-time { background: #edf2e3; color: #355936; }
.ants-stat dt, .ants-record dt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .76rem;
  font-weight: 900;
  white-space: nowrap;
}
.ants-stats dt svg { width: 14px; height: 14px; }
.ants-stat dd {
  color: inherit;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 1000;
  line-height: 1.14;
}
.ants-stat small { margin-left: 2px; font-size: .9rem; font-weight: 900; }
.ants-record {
  grid-column: span 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 39px;
  padding: 4px 11px;
  border-radius: 11px;
  background: #f9efce;
  color: #76521b;
}
.ants-record dd { font-size: 1.13rem; font-variant-numeric: tabular-nums; font-weight: 1000; }
.ants-time-track { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 10px; background: #eae8d8; }
.ants-time-track span { display: block; width: 100%; height: 100%; transform-origin: left; background: #72975c; }
.ants-game[data-urgent] :is(.ants-stat-time, .ants-time-track span) { color: #a53323; }
.ants-game[data-urgent] .ants-time-track span { background: #c95944; }

.ants-options { grid-area: options; }
.ants-options .ants-card-icon { background: #edf0df; color: #45643a; }
.ants-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 11px;
  padding: 4px;
  border-radius: 12px;
  background: #f2eee2;
}
.ants-levels button {
  min-height: 38px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ants-muted);
  font-size: .89rem;
  font-weight: 900;
}
.ants-levels button:enabled:hover { background: #e8ead9; }
.ants-levels button[aria-pressed="true"] { border-color: #dce6cd; background: #fffdf1; color: var(--ants-green); box-shadow: 0 1px 2px #382c2210; }
.ants-levels button:disabled:not([aria-pressed="true"]) { opacity: .66; }
.ants-options .ants-mode-note { min-height: 2.5em; margin-block: 9px 10px; color: var(--ants-muted); font-size: .86rem; font-weight: 700; line-height: 1.28; }
.ants-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 7px; }
.ants-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 47px;
  padding: 8px 14px;
  border: 1px solid #ab3e29;
  border-radius: 12px;
  background: var(--ants-orange);
  box-shadow: 0 3px 0 #9f3926;
  color: #fffdf4;
  font-size: 1rem;
  font-weight: 1000;
}
.ants-primary:hover { background: #b83d29; }
.ants-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #9f3926; }
.ants-primary-muted { border-color: #355631; background: #45683d; box-shadow: 0 3px 0 #355631; }
.ants-primary-muted:hover { background: #365a34; }
.ants-primary-muted:active { box-shadow: 0 1px 0 #355631; }
.ants-primary-muted:disabled { background: #5b7355; }
.ants-secondary { border-color: #d9c6a9; background: #f7ecda; box-shadow: 0 3px 0 #e7d4b7; color: var(--ants-ink); }
.ants-secondary:hover { background: #f0e0c5; }
.ants-secondary:active { box-shadow: 0 1px 0 #e7d4b7; }
.ants-primary svg { width: 18px; height: 18px; }

.ants-guide {
  grid-area: guide;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  color: var(--ants-muted);
}
.ants-guide :is(p, button) { display: flex; align-items: center; gap: 7px; font-size: .88rem; font-weight: 800; }
.ants-guide svg { width: 17px; height: 17px; }
.ants-guide button {
  min-height: 44px;
  padding-inline: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ants-green);
  font-weight: 900;
  white-space: nowrap;
}
.ants-guide button:hover { background: #edeedb; }
.ants-guide kbd { display: inline-block; padding: 0 5px; border: 1px solid #e5d9c0; border-radius: 5px; background: #fffdf7; font: inherit; }
.ants-guide .ants-touch-hint { display: none; }
.ants-no-script { padding: 12px; }

.ants-pause {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #233d26a8;
}
.ants-pause-card, .ants-dialog {
  padding: 22px;
  border: 1px solid var(--ants-line);
  border-radius: 20px;
  background: var(--ants-card);
  box-shadow: 0 9px 25px #25271732;
  color: var(--ants-ink);
}
.ants-pause-card { width: min(264px, 100%); text-align: center; }
.ants-pause-card .ants-primary { padding-inline: 6px; gap: 4px; font-size: .86rem; }
.ants-pause-card .ants-primary svg { width: 14px; height: 14px; }
.ants-pause-card h2, .ants-dialog h2 { margin-block: 7px 13px; font-size: 1.46rem; font-weight: 1000; line-height: 1.2; }
.ants-pause-emblem, .ants-dialog-emblem {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #f7edcd;
  color: #885923;
}
.ants-dialog {
  position: fixed;
  inset: 0;
  width: min(calc(100% - 30px), 424px);
  max-height: calc(100dvh - 30px);
  margin: auto;
}
.ants-dialog::backdrop { background: #203a27a6; }
.ants-close { position: absolute; top: 12px; right: 12px; }
.ants-dialog :is(p, li) { margin-bottom: 8px; color: var(--ants-muted); font-size: 1rem; }
.ants-dialog ol { margin-block: 0 12px; padding-left: 22px; }
.ants-dialog .ants-primary { margin-top: 16px; }
.ants-result { max-width: 340px; text-align: center; }

@media (hover: none), (pointer: coarse) {
  .ants-guide .ants-key-hint { display: none; }
  .ants-guide .ants-touch-hint { display: flex; }
}

@media (max-width: 790px) {
  .ants-page { --ants-frame-width: min(100% - 28px, 565px); --ants-nav-height: 62px; }
  .ants-game { padding-block: 15px 14px; }
  .is-fullscreen .ants-game { padding-top: 59px; }
  .ants-intro { margin-bottom: 15px; }
  .ants-intro h1 { font-size: clamp(2.8rem, 9vw, 3.8rem); }
  .ants-intro > p:last-child { font-size: .94rem; }
  .ants-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "score" "options" "board" "guide"; gap: 10px; }
  .ants-card { padding: 8px; border-radius: 15px; }
  .ants-card h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ants-score-card .ants-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 0; }
  .ants-stat, .ants-record { display: block; padding: 6px 8px 5px; border-radius: 9px; }
  .ants-record { grid-column: auto; }
  .ants-stat dd, .ants-record dd { font-size: 1.44rem; line-height: 1.15; }
  .ants-time-track { height: 4px; margin-top: 6px; }
  .ants-options { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: center; }
  .ants-levels { margin: 0; padding: 2px; border-radius: 10px; }
  .ants-levels button { min-height: 40px; font-size: .84rem; }
  .ants-options .ants-mode-note { display: none; }
  .ants-options .ants-primary { min-height: 43px; padding-inline: 9px; box-shadow: none; font-size: .88rem; white-space: nowrap; }
  .ants-options .ants-primary svg { width: 15px; height: 15px; }
  .ants-board { border-radius: 17px; box-shadow: 0 3px 0 #273e29, 0 8px 18px #273e291a; }
  .ants-board-bar { padding: 3px 10px; }
  .ants-scene-picker select { padding-left: 32px; font-size: .89rem; }
  .ants-scene-picker > svg { width: 17px; height: 17px; }
  .ants-board-state { padding: 3px 8px; font-size: .72rem; }
  .ants-field { aspect-ratio: 1.12; min-height: 248px; }
  .ants-guide :is(p, button) { gap: 4px; font-size: .77rem; }
}

@media (max-width: 430px) {
  .ants-top { grid-template-columns: 1fr auto; }
  .ants-brand { display: none; }
  .ants-back { font-size: .83rem; }
  .ants-tools { gap: 5px; }
  .ants-intro .ants-intro-label { font-size: .67rem; }
  .ants-intro > p:last-child { max-width: 31ch; }
  .ants-stat dt, .ants-record dt { gap: 3px; font-size: .69rem; }
  .ants-stats dt svg { width: 12px; height: 12px; }
  .ants-options .ants-primary svg { display: none; }
  .ants-guide svg { width: 14px; height: 14px; }
}

@media (max-width: 355px) {
  .ants-game:is([data-state="running"], [data-state="paused"]) .ants-options { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .ants-sprite { animation: none; }
  /* The remnant fades in place without any movement. */
  .ants-remnant { animation-duration: 1.15s !important; }
  .ants-pop { animation-name: ants-pop-still; }
  @keyframes ants-pop-still {
    0%, 99% { transform: translate(-50%, -50%); opacity: 1; }
    100% { transform: translate(-50%, -50%); opacity: 0; }
  }
}
