:root {
  color-scheme: dark;
  --bg: #101a24;
  --panel: #182532;
  --panel-strong: #203446;
  --text: #f7fbff;
  --muted: #9eb2c7;
  --grass: #5fa043;
  --grass-dark: #396b35;
  --path: #d4b07a;
  --path-edge: #8a6641;
  --gold: #ffc44d;
  --danger: #ff6b5f;
  --blue: #48c7ff;
  --line: rgba(255, 255, 255, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 0%, rgba(72, 199, 255, 0.16), transparent 32rem),
    linear-gradient(180deg, #101a24 0%, #122335 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.brand {
  min-width: 0;
}

.brand img {
  display: block;
  width: min(260px, 52vw);
  height: auto;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 8px;
}

.stat {
  min-width: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 37, 50, 0.86);
  text-align: center;
}

.stat span,
.tool small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1rem, 3vw, 1.35rem);
  line-height: 1;
}

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

#game {
  display: block;
  width: min(100%, calc(100vh - 178px));
  width: min(100%, calc(100dvh - 178px));
  max-width: 720px;
  aspect-ratio: 1;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #315934;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  touch-action: manipulation;
}

.result-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(82%, 300px);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(16, 26, 36, 0.94);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.44);
  text-align: center;
}

.result-panel strong {
  display: block;
  font-size: 1.45rem;
}

.result-panel span {
  display: block;
  margin: 6px 0 14px;
  color: var(--muted);
}

.result-panel button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--gold);
  color: #1c1608;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tool {
  min-width: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 37, 50, 0.92);
  text-align: left;
  cursor: pointer;
}

.tool:active {
  transform: translateY(1px);
}

.tool.is-active {
  border-color: rgba(255, 196, 77, 0.76);
  background: rgba(53, 44, 27, 0.92);
}

.tool:disabled {
  cursor: default;
  opacity: 0.58;
}

.tool-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--gold);
  font-weight: 900;
}

.tool strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(0.78rem, 2.7vw, 0.98rem);
  line-height: 1.05;
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .brand img {
    width: min(100%, 320px);
  }

  #game {
    width: min(100%, calc(100dvh - 250px));
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .tool {
    min-height: 54px;
  }
}

@media (max-width: 360px) {
  .stats {
    gap: 6px;
  }

  .stat {
    padding: 7px 6px;
  }
}
