/* Prototype DinoFarm : formes simples, en attendant les graphismes du fil design. */
:root {
  --grass: #5fb84f;
  --grass-dark: #3f8f3a;
  --fence: #8a5a2b;
  --card: #fffdf3;
  --ink: #2b2b2b;
  --accent: #ff8a1f;
  --accent-dark: #d96c00;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation; /* pas de zoom par double appui */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  background: var(--grass-dark);
  color: var(--ink);
  font-family: "Andika", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
}

button { font: inherit; touch-action: manipulation; cursor: pointer; }

.screen, .overlay {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[hidden] { display: none !important; }

/* Écrans de texte */
.text-screen { display: grid; place-items: center; }
.overlay { background: rgba(0, 0, 0, .45); z-index: 20; }

.card {
  position: relative;
  background: var(--card);
  border: 6px solid var(--fence);
  border-radius: 24px;
  padding: 32px 40px;
  max-width: min(640px, 92vw);
  text-align: center;
  font-size: clamp(22px, 3.4vw, 34px);
  line-height: 1.35;
  box-shadow: 0 10px 0 rgba(0, 0, 0, .2);
}
.card.wide { max-width: min(900px, 94vw); }
.card h1 { font-size: 1.3em; margin: 0 0 .5em; }
.card p { margin: .35em 0; }

.speak {
  position: absolute;
  top: -26px;
  right: -26px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid var(--fence);
  background: #fff;
  font-size: 30px;
}

.big-btn {
  margin-top: 1em;
  padding: .4em 1.4em;
  font-size: 1.1em;
  font-weight: bold;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--accent-dark);
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
.big-btn:disabled { opacity: .4; }

/* Choix de la famille */
.family-list { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.family {
  width: 220px;
  padding: 16px;
  border: 4px solid var(--fence);
  border-radius: 20px;
  background: #fff;
  font-size: 26px;
  font-weight: bold;
}
.family .pic { font-size: 110px; line-height: 1.1; display: block; }
.family:active { transform: scale(.96); }

/* Champ */
#screen-field { background: var(--grass-dark); }
.field {
  position: absolute;
  inset: 70px 24px 190px 24px;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.08) 0 40px, transparent 41px),
    radial-gradient(circle at 75% 70%, rgba(255,255,255,.08) 0 60px, transparent 61px),
    var(--grass);
  border: 14px solid var(--fence);
  border-radius: 18px;
  overflow: hidden;
}

.dino {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: left .6s, top .6s;
}
.dino .body { line-height: 1; transition: font-size .4s; }
.dino.female .body { filter: hue-rotate(60deg) saturate(1.3); }
.dino .body { position: relative; }
.dino.female .bow { position: absolute; top: 0; right: -4px; font-size: .3em; }
.dino .bar {
  width: 70px; height: 10px; margin-top: 4px;
  background: rgba(0, 0, 0, .25); border-radius: 5px; overflow: hidden;
}
.dino .bar i { display: block; height: 100%; background: #ffe14d; }
.dino .num { font-size: 13px; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; }
.dino.grow .body { animation: grow .7s; }
@keyframes grow { 30% { transform: scale(1.5) rotate(-8deg); } 60% { transform: scale(.9); } }
.dino.chomp .body { animation: chomp .18s; }
@keyframes chomp { 50% { transform: scale(1.08, .92); } }

.bubble {
  position: absolute;
  bottom: 100%;
  margin-bottom: 6px;
  white-space: nowrap;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 24px;
  font-weight: bold;
}

/* Bas de l'écran */
.controls {
  position: absolute;
  left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.feed {
  width: 150px; height: 150px;
  border-radius: 50%;
  border: 8px solid #fff;
  background: var(--accent);
  box-shadow: 0 8px 0 var(--accent-dark);
  font-size: 80px;
  line-height: 1;
}
.feed:active, .feed.pressed { transform: translateY(5px); box-shadow: 0 3px 0 var(--accent-dark); }
.total {
  min-width: 120px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, .3);
  color: #fff;
  font-size: 34px;
  font-weight: bold;
  text-align: center;
}
.total small { display: block; font-size: 16px; font-weight: normal; }
.arrow {
  position: absolute;
  left: calc(50% + 100px);
  top: -10px;
  font-size: 64px;
  animation: point .8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes point { 50% { transform: translate(-14px, 14px); } }

.herd {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 22px;
  border-radius: 999px;
  background: var(--card);
  border: 5px solid var(--fence);
  font-size: 36px;
  font-weight: bold;
  z-index: 5;
}
.herd.bump { animation: bump .4s; }
@keyframes bump { 50% { transform: translateX(-50%) scale(1.15); } }

.food {
  position: fixed;
  font-size: 44px;
  pointer-events: none;
  z-index: 10;
  will-change: transform;
}

/* Menu parent */
.gear {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 52px; height: 52px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .7);
  font-size: 28px;
  z-index: 30;
  opacity: .7;
}
.gear-ring { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.gear-ring circle {
  fill: none; stroke: var(--accent); stroke-width: 4;
  stroke-dasharray: 101; stroke-dashoffset: 101;
}
.gear.holding .gear-ring circle { transition: stroke-dashoffset var(--hold, 2s) linear; stroke-dashoffset: 0; }

.card.menu { font-size: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 320px; }
.card.menu h2 { margin: 0 0 6px; }
.menu-btn {
  padding: 12px; border-radius: 12px; border: 3px solid var(--fence);
  background: #fff; font-size: 22px; font-weight: bold;
}
.menu-btn.secondary { border-color: #aaa; font-weight: normal; }
.menu-btn.danger { background: #ffdddd; border-color: #c0392b; }
.menu-toggle { font-size: 18px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.confirm { font-size: 18px; color: #c0392b; margin: 0; }

@media (max-height: 600px) {
  .field { inset: 60px 12px 150px 12px; }
  .controls { height: 130px; }
  .feed { width: 120px; height: 120px; font-size: 64px; }
}
