/* Farmer Feud — mobile-first styles (T004). Zero build step.
 * Layout: single column, full-bleed canvas, translucent top HUD + bottom
 * action bar overlays, overlay cards for start/game-over/seed picker.
 * Touch-first: all interactive controls are real <button>s with >=44px tap
 * targets; nothing requires hover. Safe-area padding via env().
 */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1a2f16;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:focus-visible {
  outline: 3px solid #ffd23f;
  outline-offset: 2px;
  border-radius: 12px;
}
button:disabled { opacity: 0.35; cursor: default; }
button:not(:disabled):active { transform: scale(0.96); }

/* Emoji glyphs get a font stack that actually has them */
.act-emoji, .seed-emoji, .hud-item, .toast, .game-title {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* pinch-zoom/pan handled by JS (main.js) */
  background: #1a2f16;
}

/* ---------------------------------------------------------------- HUD */
#hud, .hud-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: rgba(20, 38, 16, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  padding: 0 2px;
}
.hud-item b { font-weight: 800; }

.hud-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.coverage {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}
.coverage-label {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.8;
}
.coverage-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.coverage-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #6fbf4e, #a6d84a);
  transition: width 0.25s ease;
}
.coverage-fill.near {
  background: linear-gradient(90deg, #ffd23f, #ff8c42); /* close to the 85% goal */
}
.coverage-pct {
  min-width: 38px;
  text-align: right;
  font-size: 11px;
  font-weight: 800;
  opacity: 0.9;
}

/* -------------------------------------------------------- action bar */
#action-bar, .action-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: rgba(20, 38, 16, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
}

.act-btn {
  flex: 1 1 0;
  min-height: 56px; /* >=44px tap target even on tiny screens */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
}
.act-emoji { font-size: 24px; line-height: 1; }
.act-label { font-size: 10px; font-weight: 800; letter-spacing: 0.02em; }

/* ----------------------------------------------------------- overlays */
#start-screen, #game-over-screen, .overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 16, 6, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 16px;
  overflow-y: auto;
}

.card {
  width: 100%;
  max-width: 380px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #2f5d27, #24491d);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
}

.game-title {
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}
.game-subtitle {
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  opacity: 0.85;
}

.opt-group { display: flex; flex-direction: column; gap: 6px; }
.opt-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1 1 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.10);
  font-size: 15px;
  font-weight: 800;
}
.seg-btn.active {
  background: #ffd23f;
  color: #2a3d1e;
  box-shadow: 0 2px 8px rgba(255, 210, 63, 0.4);
}

.mute-row { display: flex; justify-content: center; }
.small-btn {
  flex: 0 1 auto;
  min-width: 132px;
  min-height: 44px;
  padding: 0 16px;
}

.big-btn {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #ffd23f;
  color: #2a3d1e;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(255, 210, 63, 0.3);
}
.big-btn.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: none;
}

.start-hint {
  font-size: 11px;
  text-align: center;
  opacity: 0.6;
}

/* ------------------------------------------------------------- toasts */
#toasts {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px); /* clears action bar */
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(92%, 420px);
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(12, 22, 10, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.18s ease-out;
}
.toast.out { animation: toast-out 0.26s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* -------------------------------------------------------- seed picker */
.seed-title {
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}
.seed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seed-btn {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.10);
  padding: 6px 4px;
}
.seed-emoji { font-size: 30px; line-height: 1.1; }
.seed-name { font-size: 12px; font-weight: 800; }
.seed-cost { font-size: 11px; font-weight: 700; opacity: 0.8; }

/* --------------------------------------------------------- game over */
.result-title {
  font-size: 30px;
  font-weight: 900;
  text-align: center;
}
.result-winner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
}
.color-chip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.5);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.stat b { font-size: 14px; }
.result-time {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.8;
}

/* ------------------------------------------------------------ desktop */
@media (min-width: 768px) {
  .hud-panel {
    max-width: 760px;
    margin: 0 auto;
    left: 0; right: 0;
    border-radius: 0 0 16px 16px;
  }
  .action-bar {
    max-width: 640px;
    margin: 0 auto;
    left: 0; right: 0;
    border-radius: 16px 16px 0 0;
  }
  .act-btn { max-width: 116px; }
  .card { max-width: 420px; }

  /* hover niceties only — nothing depends on hover to work */
  .hud-btn:hover:not(:disabled),
  .act-btn:hover:not(:disabled),
  .seg-btn:hover:not(:disabled),
  .seed-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
  }
  .big-btn:hover { filter: brightness(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.out, .coverage-fill {
    animation: none !important;
    transition: none !important;
  }
}
