:root {
  color-scheme: dark;
  --void: #07111d;
  --night: #0c1b2a;
  --moss: #4cd964;
  --leaf: #87f29a;
  --amber: #ffd166;
  --orange: #ff9f1c;
  --water: #55d6ff;
  --cyan: #2aa7c9;
  --bloom: #ff6f91;
  --petal: #ffb3c7;
  --violet: #8b5cf6;
  --shadow: rgba(3, 8, 16, 0.72);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
  color: inherit;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: radial-gradient(circle at 50% 35%, #17314a 0%, #07111d 68%);
  touch-action: none;
}

.hud-layer {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr auto;
  align-items: start;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

.brand-mark,
.resource-strip,
.score-pill,
.objective-card,
.tool-dock,
.modal-panel {
  border: 1px solid rgba(135, 242, 154, 0.26);
  background: linear-gradient(135deg, rgba(7, 17, 29, 0.76), rgba(12, 27, 42, 0.58));
  box-shadow: 0 18px 44px var(--shadow), inset 0 0 28px rgba(85, 214, 255, 0.08);
  backdrop-filter: blur(14px);
}

.brand-mark {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 8px;
}

.mark-core {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--amber) 0 22%, transparent 23%),
    conic-gradient(from 0deg, var(--water), var(--leaf), var(--bloom), var(--amber), var(--water));
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.65);
}

.brand-mark strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
}

.brand-mark small {
  display: block;
  margin-top: 4px;
  color: rgba(229, 255, 239, 0.72);
  font-size: 12px;
}

.resource-strip {
  min-height: 60px;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.resource-strip span,
.score-pill {
  min-width: 96px;
  display: grid;
  place-items: center;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(240, 255, 247, 0.74);
  font-size: 12px;
}

.resource-strip b,
.score-pill b {
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
}

.score-pill {
  min-width: 112px;
  min-height: 60px;
  border-radius: 8px;
}

.objective-card {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 5;
  width: min(360px, calc(100vw - 28px));
  min-height: 72px;
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border-radius: 8px;
  pointer-events: none;
}

.objective-card strong {
  font-size: 14px;
  color: var(--amber);
}

.objective-card span {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(244, 255, 248, 0.78);
}

.tool-dock {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 6;
  width: min(760px, calc(100vw - 28px));
  min-height: 86px;
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr)) minmax(112px, 0.78fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
}

.tool-button,
.pulse-button {
  min-height: 66px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 2px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.tool-button:hover,
.pulse-button:hover {
  transform: translateY(-2px);
  border-color: rgba(135, 242, 154, 0.55);
}

.tool-button.selected {
  border-color: var(--amber);
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.24), rgba(76, 217, 100, 0.14));
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.25);
}

.tool-button span:not(.tool-glyph) {
  font-size: 13px;
  font-weight: 800;
}

.tool-button small {
  color: rgba(235, 255, 242, 0.62);
  font-size: 11px;
}

.tool-glyph {
  width: 28px;
  height: 28px;
  display: block;
  border-radius: 50%;
  position: relative;
}

.tool-glyph.garden {
  background: radial-gradient(circle, var(--amber) 0 20%, var(--moss) 22% 64%, transparent 66%);
  box-shadow: 0 0 16px rgba(76, 217, 100, 0.55);
}

.tool-glyph.relay {
  background: conic-gradient(var(--water), var(--amber), var(--water));
  clip-path: polygon(50% 0, 100% 88%, 0 88%);
  border-radius: 0;
}

.tool-glyph.purifier {
  background:
    linear-gradient(90deg, transparent 42%, var(--water) 43% 57%, transparent 58%),
    linear-gradient(0deg, transparent 42%, var(--leaf) 43% 57%, transparent 58%),
    radial-gradient(circle, var(--night) 0 25%, var(--water) 28% 62%, transparent 64%);
}

.tool-glyph.shield {
  background: radial-gradient(circle at 50% 62%, transparent 0 35%, var(--violet) 37% 52%, var(--petal) 54%);
  clip-path: polygon(50% 0, 92% 18%, 82% 76%, 50% 100%, 18% 76%, 8% 18%);
  border-radius: 0;
}

.pulse-button {
  background: linear-gradient(135deg, rgba(76, 217, 100, 0.34), rgba(85, 214, 255, 0.18));
  border-color: rgba(135, 242, 154, 0.4);
  font-weight: 900;
  color: #ffffff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 42%, rgba(85, 214, 255, 0.13), rgba(7, 17, 29, 0.72) 62%);
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.modal-panel {
  width: min(460px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.modal-eyebrow {
  color: var(--leaf);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-panel h1 {
  margin: 8px 0 10px;
  font-size: clamp(34px, 7vw, 62px);
  line-height: 0.95;
  letter-spacing: 0;
}

.modal-panel p {
  margin: 0 auto 18px;
  max-width: 34rem;
  color: rgba(241, 255, 247, 0.72);
  line-height: 1.45;
}

#modalPrimary {
  min-width: 160px;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--moss), var(--water));
  color: #062016;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(76, 217, 100, 0.26);
}

@media (max-width: 760px) {
  .hud-layer {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .brand-mark {
    min-height: 54px;
    padding: 8px 10px;
  }

  .brand-mark strong {
    font-size: 14px;
  }

  .resource-strip {
    grid-column: 1 / -1;
    order: 3;
    min-height: 48px;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 7px;
  }

  .resource-strip span {
    min-width: 82px;
    padding: 6px 8px;
  }

  .resource-strip b,
  .score-pill b {
    font-size: 17px;
  }

  .score-pill {
    min-width: 86px;
    min-height: 54px;
  }

  .objective-card {
    bottom: calc(162px + env(safe-area-inset-bottom));
    min-height: 62px;
  }

  .tool-dock {
    min-height: 138px;
    grid-template-columns: repeat(4, minmax(68px, 1fr));
    grid-template-rows: auto auto;
  }

  .pulse-button {
    grid-column: 1 / -1;
    min-height: 48px;
  }

  .tool-button {
    min-height: 72px;
  }
}

@media (max-width: 430px) {
  .tool-button span:not(.tool-glyph) {
    font-size: 11px;
  }

  .tool-button small {
    font-size: 10px;
  }

  .tool-glyph {
    width: 24px;
    height: 24px;
  }
}
