:root {
  --leaf: #2f8f46;
  --leaf-dark: #246f36;
  --leaf-light: #dff7d8;
  --sun: #ffd84d;
  --tomato: #e83434;
  --sky: #4fb7e8;
  --ink: #1d2a22;
  --paper: #fbfff7;
  --line: #b9dfae;
  --shadow: rgba(32, 93, 45, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(79, 183, 232, 0.18), transparent 34%),
    linear-gradient(180deg, #f8fff4 0%, #e8f9e2 100%);
}

button,
canvas {
  font: inherit;
}

.app-shell {
  --board-size: min(660px, calc(100vh - 245px), calc(100vw - 430px));

  display: grid;
  grid-template-columns: var(--board-size) minmax(270px, 310px);
  justify-content: center;
  align-items: start;
  gap: 20px;
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
}

.game-area,
.info-panel {
  min-width: 0;
}

.game-area {
  width: var(--board-size);
  max-width: 100%;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--leaf-dark);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.25rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.status-pill {
  flex: 0 0 auto;
  border: 2px solid var(--leaf-dark);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.hud div,
.info-panel section {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 255, 247, 0.92);
  box-shadow: 0 12px 24px var(--shadow);
}

.hud div {
  min-height: 62px;
  padding: 10px;
}

.hud span {
  display: block;
  color: var(--leaf-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  border: 8px solid var(--leaf-dark);
  border-radius: 8px;
  background: #eefbe8;
  box-shadow: 0 20px 34px var(--shadow);
  aspect-ratio: 1;
  width: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.board-message {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 40px));
  min-height: 72px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid var(--leaf-dark);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(251, 255, 247, 0.94);
  color: var(--ink);
  transform: translate(-50%, -50%);
}

.board-message.is-visible {
  display: flex;
}

.board-message strong,
.board-message span {
  min-width: 0;
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.controls button {
  border: 2px solid var(--leaf-dark);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--sun);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.controls button:hover,
.controls button:focus-visible {
  background: #ffe785;
}

.controls p {
  flex: 1 1 240px;
  margin: 0;
  color: #315b3c;
  font-size: 0.95rem;
  font-weight: 700;
}

.info-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.info-panel section {
  padding: 14px;
}

.check-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 24px;
  line-height: 1.35;
}

.check-list li::before {
  position: absolute;
  left: 0;
  top: 0.08em;
  color: var(--leaf);
  content: "✓";
  font-weight: 900;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  line-height: 1.3;
}

.legend-item img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

#missionText {
  margin-bottom: 0;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .app-shell {
    --board-size: min(620px, calc(100vw - 24px));

    grid-template-columns: 1fr;
    width: min(100% - 24px, 680px);
    padding: 12px 0;
  }

  .game-area {
    width: var(--board-size);
    justify-self: center;
  }

  .info-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    --board-size: min(100%, calc(100vw - 20px));
    width: min(100% - 20px, 620px);
    padding: 12px 0;
  }

  .title-row,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .hud,
  .info-panel {
    grid-template-columns: 1fr 1fr;
  }

  .info-panel section:last-child {
    grid-column: 1 / -1;
  }

  .board-message {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 1.9rem;
  }

  .hud,
  .info-panel {
    grid-template-columns: 1fr;
  }
}
