* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #62a94b;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

[hidden] { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ---------- Menus ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  overflow-y: auto;
  text-align: center;
  background: linear-gradient(#8fd3ff 0%, #bfe8ff 35%, #7cc15f 35%, #5a9e43 100%);
}

.screen h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 64px);
  text-shadow: 3px 3px 0 #2d5a1b, 0 0 12px rgba(0, 0, 0, 0.25);
}

.screen h2 {
  margin: 8px 0 14px;
  font-size: clamp(22px, 3.5vw, 36px);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 22px;
  background: #fff8e1;
  color: #3b2a14;
  font-size: 26px;
  font-weight: bold;
  box-shadow: 0 6px 0 #b08b4a, 0 10px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}

.card:hover { transform: translateY(-4px) scale(1.03); }
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 #b08b4a; }

.card canvas {
  border-radius: 14px;
  max-width: 40vw;
  height: auto;
}

.card.crop canvas { max-width: 28vw; }

.back {
  margin-top: 18px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 18px;
}

.howto {
  margin-top: 18px;
  font-size: clamp(16px, 2.2vw, 22px);
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 18px;
  border-radius: 999px;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#hud button { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.round {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 26px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

#btn-sound { margin-left: auto; }

.meter {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 6px 12px;
  min-width: 150px;
}

.meter .label {
  font-size: 15px;
  display: block;
  margin-bottom: 4px;
}

.bar {
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.bar > div {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: #ffd23f;
  transition: width 0.15s;
}

#field-bar { background: #7ee06a; }

#tank-bar.full {
  background: #ff5a4f;
  animation: pulse 0.6s infinite alternate;
}

@keyframes pulse { from { opacity: 1; } to { opacity: 0.45; } }

.pill {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 22px;
}

.horn {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 18px 26px;
  border-radius: 999px;
  font-size: 26px;
  background: #ffd23f;
  color: #3b2a14;
  box-shadow: 0 6px 0 #b8901c;
}

.horn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8901c; }

#toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 30px);
  max-width: 70vw;
  padding: 14px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  color: #3b2a14;
  font-size: clamp(18px, 3vw, 28px);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Win screen ---------- */

#win {
  background: rgba(40, 80, 20, 0.55);
}

#win-text {
  font-size: clamp(22px, 3.5vw, 36px);
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 26px;
  border-radius: 20px;
  margin: 10px 0 20px;
}

.win-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.big {
  padding: 18px 30px;
  border-radius: 999px;
  font-size: 24px;
  background: #ffd23f;
  color: #3b2a14;
  box-shadow: 0 6px 0 #b8901c;
}

.big.alt {
  background: #fff8e1;
  box-shadow: 0 6px 0 #b08b4a;
}

.big:active { transform: translateY(4px); }
