/* Dinodingo – styles. Pensé pour le doigt : gros boutons, pas de zoom, portrait et paysage. */
:root {
  --ink: #24361f;
  --sky1: #bfeaff;
  --sky2: #e9f9ff;
  --grass1: #b7e89a;
  --grass2: #8fd46f;
  --white: #ffffff;
  --shadow: rgba(0, 0, 0, 0.16);
  --font: "Baloo 2", "Chalkboard SE", "Comic Sans MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  --btn: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 40% at 15% 104%, var(--grass2) 60%, transparent 61%),
    radial-gradient(ellipse 80% 45% at 90% 108%, var(--grass1) 60%, transparent 61%),
    linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 60%, #f3fbe9 100%);
  background-attachment: fixed;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  overflow: hidden;
}
button, a { font: inherit; color: inherit; }
svg { display: block; }
#app { height: 100vh; height: 100dvh; }

.screen {
  height: 100%;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 14px 4px; flex: none; }
.topbar .extras { display: flex; gap: 12px; }
.spacer { flex: 1; }

.btn-round {
  width: var(--btn); height: var(--btn); flex: none;
  border: none; border-radius: 50%;
  background: var(--white);
  box-shadow: 0 5px 0 var(--shadow);
  display: grid; place-items: center;
  cursor: pointer; text-decoration: none;
  transition: transform .08s;
}
.btn-round svg { width: 58%; height: 58%; }
.btn-round:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }
.btn-round.big { --btn: 96px; }
:focus-visible { outline: 4px solid #1e88e5; outline-offset: 3px; }

/* ---------- Accueil ---------- */
.home { overflow-y: auto; }
.home .topbar { padding-bottom: 0; }
.logo {
  margin: 0 0 8px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: clamp(44px, 11vw, 92px); font-weight: 800; line-height: 1;
  color: #2e7d32; letter-spacing: .5px;
  text-shadow: 0 4px 0 #fff, 0 7px 0 var(--shadow);
}
.logo b { color: #ef6c00; font-weight: 800; }
.logo-dino { width: 1.15em; height: 1.15em; animation: bob 2.2s ease-in-out infinite; }
.logo-dino.flip { animation-delay: -1.1s; }
.tiles {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 3.5vw, 28px);
  width: min(100% - 32px, 640px, (100dvh - 240px) / 3 * 2 + 30px); margin: 12px auto 32px;
}
.tile {
  aspect-ratio: 1; border-radius: 30px; text-decoration: none;
  background: var(--c); color: #fff;
  box-shadow: 0 8px 0 var(--shadow), inset 0 -10px 0 rgba(0, 0, 0, .08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 6%; font-weight: 800; white-space: nowrap; line-height: 1.1; container-type: inline-size;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  animation: popin .45s both; animation-delay: var(--d);
  transition: transform .08s;
}
.tile:active { transform: translateY(6px) scale(.98); box-shadow: 0 2px 0 var(--shadow); }
.tile-ico { width: 68%; aspect-ratio: 1; }
.tile-name { font-size: 13cqw; }
.tile-ico svg { width: 100%; height: 100%; }
@media (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100% - 32px, 1000px, (100dvh - 310px) / 2 * 3 + 56px); }
}
@media (orientation: landscape) and (min-aspect-ratio: 4/3) and (max-height: 520px) {
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; width: min(100% - 32px, (100dvh - 170px) * 5 + 56px); }
}
@media (max-height: 520px) {
  :root { --btn: 52px; }
  .logo { margin: 8px 0 4px; font-size: 44px; }
  .topbar { padding: 8px 12px 2px; }
}

/* ---------- Zone de jeu ---------- */
.stage {
  flex: 1; min-height: 0; position: relative;
  padding: 8px 14px 16px;
  display: flex; align-items: center; justify-content: center;
  container-type: size;
}
.duel {
  --tp: clamp(64px, 22cqmin, 130px);
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.turn { display: flex; gap: 22px; flex: none; }
.turn-p { position: relative; width: var(--tp); height: var(--tp); opacity: .35; transform: scale(.8); transition: transform .25s, opacity .25s; }
.turn-p.on { opacity: 1; transform: scale(1.05); animation: bob 1s ease-in-out infinite; }
.turn-p > svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 0 var(--shadow)); }
.turn-tag { position: absolute; right: -14%; bottom: -10%; width: 48%; height: 48%; }
.turn-tag svg { width: 100%; height: 100%; }
.board {
  --ar: 1;
  width: min(100cqw, (100cqh - var(--tp) - 14px) * var(--ar));
  aspect-ratio: var(--ar);
  flex: none;
}
@container (orientation: landscape) {
  .duel { flex-direction: row; gap: 28px; }
  .turn { flex-direction: column; }
  .board { width: min(100cqw - var(--tp) - 28px, 100cqh * var(--ar)); }
}

/* Choix des joueurs */
.choices { display: flex; flex-wrap: wrap; gap: clamp(16px, 5cqmin, 40px); justify-content: center; align-items: center; }
.choice {
  width: min(42cqmin, 300px); aspect-ratio: 1;
  border: none; border-radius: 32px; background: #fff;
  box-shadow: 0 8px 0 var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; padding: 12px;
  animation: popin .4s both;
}
.choice:nth-child(2) { animation-delay: .08s; }
.choice:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--shadow); }
.choice-art { width: 72%; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.choice-art svg { width: 100%; height: 100%; }
.choice-art.duo svg { width: 58%; }
.choice-art.duo svg + svg { margin-left: -14%; }
.choice-cap { font-weight: 800; font-size: clamp(16px, 4.5cqmin, 28px); }
@container (orientation: portrait) { .choice { width: min(42cqh, 80cqw, 300px); } }

/* ---------- Morpion ---------- */
.ttt {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 3%; padding: 3%;
  background: #7cb342; border-radius: 9%;
  box-shadow: 0 8px 0 #558b2f;
}
.cell {
  border: none; border-radius: 18%; background: #f1f8e9; padding: 8%;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .07);
  cursor: pointer; display: grid; place-items: center; min-width: 0; min-height: 0;
}
.cell:not(.full):active { background: #dcedc8; }
.piece { width: 100%; height: 100%; animation: stamp .35s cubic-bezier(.3, 1.6, .5, 1) both; }
.piece svg { width: 100%; height: 100%; }
.cell.win { background: #fff59d; animation: pulse .6s ease-in-out infinite alternate; }
.cell.draw { opacity: .7; }
.nope { animation: nope .3s; }

/* ---------- Bravo ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
  animation: fadein .3s both;
}
.heroes { display: flex; gap: 2vmin; }
.hero { width: min(42vmin, 260px); aspect-ratio: 1; animation: jump .55s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.27s); }
.heroes .hero:nth-child(n+2) { width: min(30vmin, 200px); }
.hero svg { width: 100%; height: 100%; filter: drop-shadow(0 8px 0 var(--shadow)); }
.stars { display: flex; gap: 8px; }
.stars svg { width: min(12vmin, 64px); animation: popin .4s both; }
.actions { display: flex; gap: 24px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall 2.5s linear both; }

/* ---------- Animations ---------- */
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6%; } }
@keyframes popin { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes stamp { from { transform: scale(1.8) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes nope { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
@keyframes fadein { from { opacity: 0; } }
@keyframes jump { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-8%) rotate(4deg); } }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(110vh) rotate(var(--r)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Puissance 4 ---------- */
.p4 {
  display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr);
  gap: 1.6%; padding: 2.2%;
  background: #8d6e63; border-radius: 6%;
  box-shadow: 0 8px 0 #5d4037, inset 0 -8px 0 rgba(0, 0, 0, .12);
  cursor: pointer; touch-action: none;
}
.hole { position: relative; border-radius: 50%; background: #d7ccc8; box-shadow: inset 0 4px 0 rgba(0, 0, 0, .18); min-width: 0; min-height: 0; }
.disc {
  position: absolute; inset: 0; z-index: 2;
  animation: drop calc(.12s + var(--fall) * .045s) cubic-bezier(.5, 0, 1, 1) both, settle .2s calc(.12s + var(--fall) * .045s) ease-out;
}
.disc svg { width: 100%; height: 100%; }
.hole.win .disc { animation: pulse .5s ease-in-out infinite alternate; }
.hole.win { background: #fff59d; }
@keyframes drop { from { transform: translateY(calc(var(--fall) * -118%)); } to { transform: translateY(0); } }
@keyframes settle { 40% { transform: translateY(-10%); } }

/* ---------- Débloque-moi ---------- */
.levels {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 3cqmin, 22px);
  width: min(100cqw, 100cqh * .95, 560px);
}
@container (orientation: landscape) { .levels { grid-template-columns: repeat(8, 1fr); width: min(100cqw, 100cqh * 3.6, 1000px); } }
.lvl {
  position: relative; aspect-ratio: 1; border: none; border-radius: 26%;
  background: #fff; box-shadow: 0 6px 0 var(--shadow); cursor: pointer;
  font-weight: 800; font-size: clamp(26px, 7cqmin, 48px); color: #7b1fa2;
  display: grid; place-items: center;
}
.lvl.ok { background: #f3e5f5; }
.lvl:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--shadow); }
.lvl i { position: absolute; right: -8%; top: -8%; width: 42%; }
.lvl i svg { width: 100%; height: 100%; }
.rh-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; height: 100%; justify-content: center; }
.rh-num {
  flex: none; width: 54px; height: 54px; border-radius: 50%; background: #ab47bc; color: #fff;
  font-weight: 800; font-size: 32px; display: grid; place-items: center; box-shadow: 0 4px 0 #7b1fa2;
}
.rh {
  position: relative; flex: none;
  width: min(100cqw - 13%, (100cqh - 64px) * .97);
  aspect-ratio: 1; margin-right: 10%;
  background: #795548; border-radius: 6%; padding: 3.5%;
  box-shadow: 0 8px 0 #4e342e;
}
.rh-grid {
  position: relative; width: 100%; height: 100%;
  display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr);
  background: #aed581; border-radius: 3%;
}
.rh-cell { border: 1px solid rgba(85, 139, 47, .25); }
.rh-exit {
  position: absolute; left: calc(100% - 3.6%); top: calc(3.5% + var(--row) * 93% / 6);
  width: 18%; height: calc(93% / 6);
  background: linear-gradient(90deg, #aed581 0 22%, transparent 22%);
  display: flex; align-items: center; justify-content: flex-end;
}
.rh-exit svg { width: 85%; height: 190%; margin-right: -14%; }
.pc { position: absolute; padding: .7%; touch-action: none; cursor: grab; z-index: 2; transition: left .18s ease-out, top .18s ease-out; }
.pc.drag { transition: none; z-index: 3; cursor: grabbing; }
.pc.drag .pc-body { transform: scale(1.04); box-shadow: 0 8px 0 rgba(0, 0, 0, .2); }
.pc.exit { transition: left .9s ease-in; z-index: 4; }
.pc-body {
  width: 100%; height: 100%; border-radius: 22px; display: flex; overflow: hidden;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .2), inset 0 -6px 0 rgba(0, 0, 0, .1);
  transition: transform .1s;
}
.pc.v .pc-body { flex-direction: column; }
.pc-head { flex: none; aspect-ratio: 1; padding: 1%; }
.pc.h .pc-head { height: 100%; }
.pc.v .pc-head { width: 100%; }
.pc-head svg { width: 100%; height: 100%; }
.pc-fill { flex: 1; }
.pc.rex .pc-body { background: #66bb6a radial-gradient(circle at 30% 40%, #43a047 0 9%, transparent 10%) 0 0 / 40px 40px; }
.pc.rex.big .pc-body { background: #388e3c radial-gradient(circle at 30% 40%, #2e7d32 0 9%, transparent 10%) 0 0 / 40px 40px; }
.pc.tri .pc-body { background: #ffb74d radial-gradient(circle at 30% 40%, #ff9800 0 9%, transparent 10%) 0 0 / 40px 40px; }

/* ---------- Memory ---------- */
.mem-lvl { width: min(30cqmin, 240px); }
@container (orientation: portrait) { .mem-lvl { width: min(28cqh, 60cqw, 240px); } }
.mem-lvl .choice-art svg { width: 80%; }
.mem-grid { display: grid; gap: 12px; justify-content: center; align-content: center; }
.mcard { aspect-ratio: 1 / 1.25; border: none; padding: 0; background: none; perspective: 800px; cursor: pointer; }
.mcard-in { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.mcard.up .mcard-in { transform: rotateY(180deg); }
.mface {
  position: absolute; inset: 0; border-radius: 16%/ 13%; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 var(--shadow);
}
.mface.back { background: #1e88e5 repeating-linear-gradient(45deg, transparent 0 10px, rgba(255, 255, 255, .08) 10px 20px); border: 4px solid #fff; }
.mface.back svg { width: 62%; }
.mface.front { transform: rotateY(180deg); border: 4px solid #fff; }
.mface.front svg { width: 84%; }
.mface.front span { font-weight: 800; font-size: clamp(9px, 2.2cqmin, 16px); line-height: 1; margin-top: 2%; max-width: 94%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard.found .mface.front { border-color: #ffca28; }

/* ---------- Range les dinos ---------- */
.range-levels { grid-template-columns: repeat(4, 1fr); }
@container (orientation: landscape) { .range-levels { grid-template-columns: repeat(8, 1fr); } }
.range-levels .lvl { color: #e65100; }
.range-levels .lvl.ok { background: #fff3e0; }
.sort-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: 100%; height: 100%; }
.sort { --s: 80px; display: grid; gap: 18px 14px; justify-content: center; align-items: end; }
.pen {
  position: relative; width: var(--s); height: calc(var(--s) * (var(--cap) * .92 + .25));
  border: none; padding: 0; cursor: pointer;
  background:
    repeating-linear-gradient(180deg, transparent 0 calc(var(--s) * .32), #a1887f calc(var(--s) * .32) calc(var(--s) * .36)),
    #e6f4d7;
  border-left: 7px solid #795548; border-right: 7px solid #795548; border-bottom: 9px solid #6d4c41;
  border-radius: 6px 6px 14px 14px;
  box-shadow: 0 6px 0 var(--shadow);
}
.pen.sel { box-shadow: 0 0 0 5px #ffca28, 0 6px 0 var(--shadow); }
.pen.full { background: #fff8d6; border-color: #f9a825; box-shadow: 0 0 0 4px #ffe082, 0 6px 0 var(--shadow); }
.pen-dino {
  position: absolute; left: 4%; width: 92%; aspect-ratio: 1;
  bottom: calc(var(--j) * var(--s) * .86 + 2px);
  pointer-events: none;
}
.pen-dino svg { width: 100%; height: 100%; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .15)); }
