/* Clean Sea Defense: helpers, drifting litter, the reef and the build tray (frame in ../game.css). */
/* the control bar under the board takes some height, so the board is sized to leave room for it */
.game { width: min(100%, 550px, calc((100svh - 400px) * 600 / 760 + 30px)); }
@media (max-width: 520px) { .game { width: 100%; } }
.board { background: #1f6fb5; cursor: pointer; }
.board__overlay { z-index: 5; } /* above the drifting litter */

.defense__hud { gap: 14px; flex-wrap: wrap; }
.defense__hud .game__stat strong { font-variant-numeric: tabular-nums; }
.defense__hud .game__stat:last-child { margin-left: auto; }
.defense__hud .is-low { color: var(--red); }

.def__helper { transform: translate(-50%, -62%); z-index: 1; }
.def__helper--boom { transform: translate(-50%, -50%) rotate(var(--turn, 0deg)); }
.def__helper--refill { transform: translate(-50%, -80%); }
.def__item { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)); will-change: left, top, transform; z-index: 2; }
.def__item.is-gone { transition: opacity .25s ease, transform .25s ease; opacity: 0; transform: translate(-50%, -50%) scale(.3); }
.def__reef { transform: translate(-50%, -100%); }
.def__select {
  position: absolute; border: 3px solid #fff; border-radius: 8px; box-shadow: 0 0 0 3px var(--ink);
  pointer-events: none; z-index: 3;
}
.def__select[hidden] { display: none; }
.defense__start { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.defense__start [hidden] { display: none; }

/* the guided first game: a pulsing ring on the spot to tap, and on the button to press */
.def__hint {
  position: absolute; border: 4px solid var(--sun); border-radius: 50%; box-shadow: 0 0 0 3px var(--ink);
  pointer-events: none; z-index: 4; animation: def-pulse 1.1s ease-in-out infinite;
}
.def__hint[hidden] { display: none; }
@keyframes def-pulse { 50% { transform: scale(1.18); opacity: .7; } }
.is-hinted { box-shadow: 0 0 0 4px var(--sun), 0 0 0 7px var(--ink); animation: def-glow 1.1s ease-in-out infinite; }
@keyframes def-glow { 50% { box-shadow: 0 0 0 7px var(--sun), 0 0 0 10px var(--ink); } }
.def-skip {
  position: absolute; top: .6%; left: 50%; transform: translateX(-50%); z-index: 4;
  padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: #fff;
  font: 800 .8rem/1 var(--body); color: var(--ink); cursor: pointer;
}
.def-skip[hidden] { display: none; }

/* ---------- the control bar ---------- */
.defense__controls { display: grid; gap: 8px; margin-top: 10px; }
.defense__controls.is-idle > * { visibility: hidden; }
.defense__menu, .defense__actions {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border: 2px solid var(--ink); border-radius: 14px; background: var(--accent-tint); overflow: hidden;
}
.defense__menu { height: 76px; }
.defense__actions { height: 60px; background: #fff; }
.defense__status { flex: 1; min-width: 0; margin: 0; font-weight: 800; font-size: .9rem; color: var(--ink); }
.defense__msg { flex: 1; margin: 0; font-weight: 700; font-size: .95rem; line-height: 1.25; color: var(--ink); min-width: 0; }
.defense__msg small { display: block; font-weight: 600; color: var(--muted); font-size: .82rem; }
/* a tapped helper: its name on one line, a short note on up to two */
.defense__msg--helper span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.defense__msg--helper small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.defense__actions .btn { flex: none; white-space: nowrap; }
.def-opt {
  flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  background: #fff; border: 2px solid var(--ink); border-radius: 12px; cursor: pointer;
  font: 700 .82rem/1.15 var(--body); color: var(--ink); text-align: left;
}
.def-opt img { flex: none; width: 40px; height: 40px; object-fit: contain; }
.def-opt__text { min-width: 0; }
.def-opt:hover:not(:disabled) { background: var(--caption); }
.def-opt:disabled { opacity: .45; cursor: default; }
.def-opt__cost { display: block; color: var(--muted); font-weight: 800; }
.def-opt__cost::before { content: '🐚 '; }
.def-close {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: #fff;
  font: 800 1.2rem/1 var(--body); color: var(--ink); cursor: pointer;
}
.def-tool {
  flex: none; min-height: 44px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff;
  font: 800 .9rem/1 var(--body); color: var(--ink); cursor: pointer;
}
.def-tool--two { display: grid; justify-items: center; gap: 2px; padding: 4px 10px; font-size: .82rem; }
.def-tool--two small { font-weight: 700; color: var(--muted); }
.def-tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.def-tool:disabled { opacity: .45; cursor: default; }
@media (max-width: 420px) {
  .defense__hud { gap: 10px; }
  .defense__hud .game__stat strong { font-size: 1.15rem; }
  .defense__menu, .defense__actions { gap: 6px; padding: 6px; }
  .defense__actions .btn { padding: .6em .9em; font-size: .95rem; }
  .defense__status { font-size: .8rem; }
  .defense__msg { font-size: .8rem; }
  .defense__msg small { font-size: .74rem; }
  .def-opt { font-size: .74rem; padding: 4px 6px; gap: 4px; }
  .def-opt img { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .def__item.is-gone { transition: none; }
  .def__hint, .is-hinted { animation: none; }
}
