:root {
  color-scheme: dark;
  --moss: #183829;
  --fern: #28523d;
  --leaf: #5aa46a;
  --gold: #f0cf6a;
  --berry: #d96a61;
  --bark: #6b4a2e;
  --ink: #f5f2dc;
  --panel: rgba(18, 27, 22, 0.9);
  --line: rgba(245, 242, 220, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at 20% 0%, #294b35 0, #13271f 42%, #0b1613 100%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
a {
  font: inherit;
}

.game-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.top-bar,
.control-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(12px, 3vw, 28px);
  background: var(--panel);
  border-color: var(--line);
}

.top-bar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: grid;
  gap: 2px;
  min-width: 152px;
}

.brand-title {
  color: var(--gold);
  font-size: 22px;
  font-weight: 800;
}

.brand-subtitle {
  color: #bad2b5;
  font-size: 12px;
  text-transform: uppercase;
}

.stat-strip {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 4vw, 40px);
  flex: 1;
  font-weight: 700;
}

.stat-strip span {
  min-width: 88px;
  text-align: center;
}

.feedback-link,
.control-bar button,
.build-menu button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.feedback-link {
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  background: rgba(90, 164, 106, 0.18);
}

.play-area {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}

#gameCanvas {
  width: min(100vw, calc((100vh - 152px) * 16 / 9));
  max-width: 100vw;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #1f4a2f;
  touch-action: manipulation;
}

.message {
  position: absolute;
  left: 50%;
  top: 18px;
  width: min(620px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid rgba(240, 207, 106, 0.34);
  border-radius: 8px;
  background: rgba(13, 23, 19, 0.84);
  color: #fff4a9;
  text-align: center;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.message.is-visible {
  opacity: 1;
}

.build-menu {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: grid;
  gap: 12px;
  width: min(440px, calc(100% - 28px));
  padding: 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(240, 207, 106, 0.34);
  border-radius: 8px;
  background: rgba(13, 23, 19, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.build-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--gold);
  font-size: 16px;
  font-weight: 800;
}

.build-menu-header button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: rgba(245, 242, 220, 0.08);
  cursor: pointer;
}

.build-menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.build-menu-actions button {
  min-height: 68px;
  padding: 10px 12px;
  background: rgba(245, 242, 220, 0.08);
  color: var(--ink);
  cursor: pointer;
}

.build-menu-actions button span {
  display: block;
  color: #c7d6bd;
  font-size: 12px;
  line-height: 1.2;
}

.control-bar {
  justify-content: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}

.control-bar button {
  min-width: 134px;
  padding: 8px 14px;
  background: rgba(245, 242, 220, 0.08);
  cursor: pointer;
}

.control-bar button span {
  display: block;
  color: #c7d6bd;
  font-size: 12px;
  line-height: 1.2;
}

.control-bar button:hover:not(:disabled),
.build-menu button:hover:not(:disabled),
.feedback-link:hover {
  border-color: rgba(240, 207, 106, 0.72);
  background: rgba(240, 207, 106, 0.16);
}

.control-bar button.is-selected,
.build-menu button.is-selected {
  border-color: var(--gold);
  background: rgba(240, 207, 106, 0.2);
}

.control-bar button:disabled,
.build-menu button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.control-bar .primary-action {
  color: #101711;
  background: var(--gold);
  border-color: #ffe49b;
  font-weight: 800;
}

.info-page {
  display: grid;
  min-height: 100%;
  background:
    linear-gradient(rgba(8, 18, 14, 0.66), rgba(8, 18, 14, 0.82)),
    radial-gradient(circle at 24% 18%, #315d39 0, transparent 34%),
    #0b1613;
}

.info-shell {
  display: grid;
  align-content: center;
  gap: 24px;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.back-link,
.primary-link {
  color: var(--ink);
  text-decoration: none;
}

.back-link {
  width: fit-content;
  color: #bad2b5;
}

.back-link:hover,
.primary-link:hover {
  color: var(--gold);
}

.info-panel {
  display: grid;
  gap: 18px;
  padding: clamp(24px, 6vw, 44px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 27, 22, 0.92);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.24);
}

.info-panel h1,
.info-panel p {
  margin: 0;
}

.info-panel h1 {
  color: var(--gold);
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1;
}

.info-panel p {
  color: #d6e2cf;
  font-size: 18px;
  line-height: 1.55;
}

.eyebrow {
  color: #98d08a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.primary-link {
  display: inline-grid;
  place-items: center;
  width: fit-content;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #ffe49b;
  border-radius: 8px;
  background: var(--gold);
  color: #101711;
  font-weight: 800;
}

@media (max-width: 720px) {
  .top-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .brand-lockup,
  .stat-strip,
  .feedback-link {
    width: 100%;
  }

  .brand-lockup {
    text-align: center;
  }

  .stat-strip {
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
  }

  .stat-strip span {
    min-width: 0;
  }

  #gameCanvas {
    width: min(100vw, calc((100vh - 238px) * 16 / 9));
  }

  .control-bar {
    gap: 8px;
    padding: 10px;
  }

  .control-bar button {
    flex: 1 1 142px;
    min-width: 0;
    padding-inline: 8px;
  }

  .build-menu {
    bottom: 10px;
  }

  .build-menu-actions {
    grid-template-columns: 1fr;
  }
}
