:root {
  --bg: #04121f;
  --panel: #0c2030;
  --grid: #143246;
  --accent: #3ad6c5;        /* lagoon teal */
  --accent-dim: #2aa99b;
  --attack: #ff7a59;        /* coral attack button */
  --dodge: #4db1ff;         /* dodge / surface button */
  --text: #e6f4f7;
  --muted: #7fa4b3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.board {
  position: relative;
  width: min(440px, 94vw);
  aspect-ratio: 3 / 4;
  max-height: 86vh;
  border: 2px solid var(--grid);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #0a3a5c 0%, #062a44 55%, #04121f 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* HUD bar overlaid at the top of the board */
.bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  pointer-events: none;
  z-index: 3;
}

.bar h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.5px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }

.scores { display: flex; align-items: center; gap: 8px; }
.score { font-size: 12px; color: var(--muted); text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.score strong { color: var(--text); margin-left: 3px; }

/* HUD buttons (mute / fullscreen / home) */
.mute {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(12, 32, 48, 0.7);
  border: 1px solid var(--grid);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px; line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  text-decoration: none;
}
.mute:hover { border-color: var(--accent); }

/* Overlays (start / game over) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(4, 18, 31, 0.82);
  text-align: center;
  padding: 16px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  z-index: 4;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
#overlay-title { font-size: 28px; font-weight: 700; }
#overlay-sub { font-size: 14px; color: var(--muted); max-width: 280px; }

/* Animal picker */
.pick {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 18, 31, 0.92);
  padding: 18px;
  z-index: 5;
}
.pick.hidden { display: none; }
.pick-title { font-size: 20px; font-weight: 700; }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
.animal-card {
  background: var(--panel);
  border: 2px solid var(--grid);
  border-radius: 12px;
  padding: 10px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  color: var(--text);
}
.animal-card:hover { transform: translateY(-2px); }
.animal-card.selected { border-color: var(--accent); background: #123448; }
.animal-card .a-emoji { font-size: 34px; line-height: 1; }
.animal-card .a-name { font-size: 12px; font-weight: 700; }
.animal-card .a-desc { font-size: 9px; color: var(--muted); text-align: center; }
.animal-card .a-fly { font-size: 9px; color: var(--dodge); }

/* Colour picker */
.colour-preview {
  font-size: 64px;
  line-height: 1;
  filter: none;
}
.colour-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 280px;
}
.colour-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--grid);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #06202f;
}
.colour-swatch:hover { transform: translateY(-2px); }
.colour-swatch.selected { border-color: var(--text); }

.play {
  background: var(--accent);
  color: #06202a;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  padding: 10px 28px;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}
.play:disabled { opacity: .4; cursor: not-allowed; }
.play:not(:disabled):hover { transform: translateY(-1px); }

/* Action buttons (attack + dodge) — always shown; the game is button-driven. */
.touch {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 14px 16px;
  z-index: 3;
  pointer-events: none;
}
.tbtn {
  pointer-events: auto;
  border-radius: 50%;
  border: 2px solid var(--grid);
  color: #06202a;
  font-weight: 700;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.tbtn:active { transform: translateY(2px); box-shadow: none; }
.tbtn.attack { width: 76px; height: 76px; font-size: 30px; background: var(--attack); border-color: #d4583b; }
.tbtn.dodge  { width: 66px; height: 66px; font-size: 13px; background: var(--dodge); border-color: #2f8bd1; }

.foot { font-size: 11px; color: var(--muted); }
