/* CataPoule */
:root {
  --f: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --glass: rgba(14, 22, 48, 0.62);
  --glass2: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.18);
  --or: #ff6a2b;
  --bleu: #2f8bff;
  --jaune: #ffd84a;
  --vert: #7ccc2b;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1f6fc5; }
body { font-family: var(--f); color: #fff; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
canvas#cv { position: fixed; inset: 0; display: block; touch-action: none; }
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.off { display: none !important; }

/* ---------- écrans ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  overflow-y: auto;
}
#s-title { background: radial-gradient(ellipse at 50% 40%, rgba(10, 20, 50, 0.15), rgba(10, 20, 50, 0.55)); }
.title-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: rise .7s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.95); } }

.logo { margin: 0; line-height: .9; font-size: clamp(54px, 13vmin, 128px); font-weight: 900; letter-spacing: -.02em; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, .25)) drop-shadow(0 18px 30px rgba(0, 0, 0, .35)); }
.logo span { display: inline-block; -webkit-text-stroke: .14em #4a1d08; paint-order: stroke fill; text-shadow: 0 .05em 0 #4a1d08; }
.logo .l1 { color: #ff7a2b; transform: rotate(-4deg); animation: wob 3s ease-in-out infinite; }
.logo .l2 { color: #ffd84a; transform: rotate(3deg); animation: wob 3s ease-in-out -1.5s infinite; }
@keyframes wob { 50% { transform: rotate(-1deg) translateY(-6px); } }
.tag { margin: 0 0 8px; font-size: clamp(15px, 2.6vmin, 22px); font-weight: 800; letter-spacing: .04em; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); background: rgba(10, 20, 50, .45); padding: 6px 16px; border-radius: 30px; }

.menu { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.big {
  min-width: min(340px, 80vw); padding: 14px 26px; border-radius: 18px;
  font-size: clamp(17px, 2.6vmin, 22px); font-weight: 900; letter-spacing: .01em;
  background: linear-gradient(#ffb04a, #ff6a2b); color: #fff;
  box-shadow: 0 6px 0 #b8400f, 0 12px 24px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 2px 0 rgba(120, 30, 0, .45);
  transition: transform .12s, box-shadow .12s, filter .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.big.alt { background: linear-gradient(#5fb0ff, #2f7de0); box-shadow: 0 6px 0 #1b4f9c, 0 12px 24px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .45); text-shadow: 0 2px 0 rgba(10, 40, 100, .45); }
.big:hover { filter: brightness(1.08); transform: translateY(-2px); }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8400f, 0 6px 12px rgba(0, 0, 0, .3); }
.big.alt:active { box-shadow: 0 2px 0 #1b4f9c, 0 6px 12px rgba(0, 0, 0, .3); }
.big .ic { font-size: 1.2em; }
.chip {
  padding: 8px 16px; border-radius: 30px; font-weight: 800; font-size: 15px;
  background: rgba(10, 20, 50, .5); border: 2px solid rgba(255, 255, 255, .25);
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.on { background: #fff; color: #1d3e78; border-color: #fff; }
.chip.opt::before { content: "✓ "; opacity: 0; }
.chip.opt.on::before { opacity: 1; }
.diff { display: flex; gap: 6px; margin: -2px 0 4px; }
.link { font-weight: 800; font-size: 16px; padding: 8px 14px; text-decoration: underline; text-underline-offset: 4px; opacity: .92; text-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.opts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.paysage { display: none; margin: 4px 0 0; font-weight: 700; font-size: 14px; opacity: .9; background: rgba(10, 20, 50, .45); padding: 6px 14px; border-radius: 20px; }
@media (orientation: portrait) and (max-width: 700px) { .paysage { display: block; } }

/* choix du tableau */
#s-levels { flex-direction: column; justify-content: flex-start; align-items: stretch; background: linear-gradient(rgba(10, 18, 45, .82), rgba(10, 18, 45, .92)); }
.sh { display: flex; align-items: center; gap: 14px; max-width: 1180px; width: 100%; margin: 0 auto 14px; }
.sh h2 { margin: 0; font-size: clamp(22px, 4vmin, 34px); font-weight: 900; }
.sh .sub { margin: 2px 0 0; opacity: .75; font-weight: 700; }
.back { width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, .14); font-size: 24px; font-weight: 900; flex: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; max-width: 1180px; width: 100%; margin: 0 auto; padding-bottom: 20px; }
.lv {
  position: relative; text-align: left; border-radius: 18px; overflow: hidden;
  background: #142048; border: 3px solid rgba(255, 255, 255, .12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  animation: rise .5s cubic-bezier(.2, 1.3, .4, 1) both;
}
.lv:hover, .lv:focus-visible { transform: translateY(-4px) scale(1.02); border-color: var(--jaune); box-shadow: 0 16px 32px rgba(0, 0, 0, .45); outline: none; }
.lv canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.lv .num { position: absolute; top: 8px; left: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(10, 20, 50, .75); display: grid; place-items: center; font-weight: 900; font-size: 17px; border: 2px solid rgba(255, 255, 255, .5); }
.lv .done { position: absolute; top: 8px; right: 8px; padding: 4px 10px; border-radius: 20px; background: var(--vert); color: #173400; font-weight: 900; font-size: 13px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.lv .meta { padding: 10px 12px 12px; }
.lv .meta b { display: block; font-size: 18px; font-weight: 900; }
.lv .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lv .tags span { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 10px; background: rgba(255, 255, 255, .12); }
.lv .tags span.th { background: rgba(255, 216, 74, .2); color: #ffe991; }

/* modales */
.modal { background: rgba(8, 14, 36, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 30; }
.card {
  background: linear-gradient(#22336b, #17234d); border: 3px solid rgba(255, 255, 255, .16);
  border-radius: 24px; padding: 22px 24px; max-width: 420px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5); animation: rise .45s cubic-bezier(.2, 1.4, .4, 1) both;
  margin: auto;
}
.card h2 { margin: 0 0 6px; font-size: 30px; font-weight: 900; }
.card h3 { margin: 12px 0 2px; align-self: flex-start; font-size: 18px; color: var(--jaune); }
.card.wide { max-width: 760px; align-items: stretch; }
.card.wide h2 { text-align: center; }
.card.wide .big { align-self: center; margin-top: 10px; }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.step { display: flex; gap: 10px; align-items: flex-start; background: rgba(255, 255, 255, .07); border-radius: 14px; padding: 10px 12px; }
.step b { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--or); display: grid; place-items: center; font-weight: 900; }
.step p { margin: 0; font-size: 15px; line-height: 1.35; font-weight: 600; }
.q { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: #f0a81a; font-weight: 900; color: #fff; }
.tip { margin: 4px 0 0; font-size: 14px; opacity: .8; text-align: center; font-weight: 600; }
.list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.item { display: flex; gap: 8px; align-items: center; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 6px 10px 6px 4px; }
.item canvas { width: 52px; height: 52px; flex: none; }
.item b { display: block; font-size: 15px; }
.item span { font-size: 13px; opacity: .85; line-height: 1.3; font-weight: 600; }

.end { max-width: 460px; }
#end-ico { width: 120px; height: 120px; margin-top: -10px; }
#end-title { font-size: 38px; margin: 0; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
#end-sub { margin: 0 0 6px; font-weight: 700; opacity: .9; text-align: center; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-bottom: 6px; }
.stats div { background: rgba(255, 255, 255, .08); border-radius: 12px; padding: 8px 10px; font-size: 14px; font-weight: 700; border-top: 4px solid; }
.stats b { display: block; font-size: 16px; margin-bottom: 2px; }

/* ---------- interface de partie ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud canvas#mini { pointer-events: auto; }
.team {
  position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l));
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  background: var(--glass); border: 2px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: box-shadow .3s, border-color .3s, transform .3s;
}
.team.right { left: auto; right: calc(10px + var(--safe-r)); flex-direction: row-reverse; padding: 6px 6px 6px 12px; text-align: right; }
.team.actif { border-color: var(--tc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 35%, transparent), 0 8px 20px rgba(0, 0, 0, .3); transform: scale(1.04); }
.team .ico { width: 46px; height: 46px; border-radius: 12px; background: rgba(255, 255, 255, .1); }
.team .nom { display: block; font-size: 16px; font-weight: 900; line-height: 1.1; }
.team .eq { display: block; font-size: 11px; font-weight: 800; opacity: .75; margin-bottom: 4px; color: var(--tc); filter: brightness(1.4); }
.bar { position: relative; width: clamp(90px, 16vw, 170px); height: 10px; border-radius: 6px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--tc), color-mix(in srgb, var(--tc) 50%, #fff)); border-radius: 6px; transition: width .6s cubic-bezier(.3, 1.4, .5, 1); }
.team.right .bar i { inset: 0 0 0 auto; }
.bar .seuil { position: absolute; top: 0; bottom: 0; left: 35%; width: 2px; background: rgba(255, 255, 255, .75); }
.team.right .bar .seuil { left: auto; right: 35%; }
.bar.danger i { background: linear-gradient(90deg, #ff3b3b, #ff8a5a); animation: blink .6s infinite alternate; }
@keyframes blink { to { opacity: .55; } }
.pct { font-size: 20px; font-weight: 900; min-width: 52px; text-align: center; }

#top { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#wind { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 20px; background: var(--glass); border: 2px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-weight: 900; font-size: 15px; white-space: nowrap; }
.w-lbl { opacity: .7; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.w-arrow { display: inline-flex; gap: 1px; color: #9fe1ff; font-size: 14px; letter-spacing: -3px; min-width: 18px; justify-content: center; }
.w-arrow.l { transform: scaleX(-1); }
#mini { width: 240px; height: 36px; border-radius: 10px; background: rgba(10, 18, 40, .55); border: 2px solid var(--line); cursor: pointer; }

#tools { position: absolute; top: calc(76px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 8px; }
.tool { width: 46px; height: 46px; border-radius: 14px; background: var(--glass); border: 2px solid var(--line); display: grid; place-items: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: transform .1s; }
.tool:active { transform: scale(.92); }
.tool svg { width: 24px; height: 24px; fill: #fff; }
.tool.on { background: rgba(255, 216, 74, .9); }
.tool.on svg { fill: #3a2a00; }

#arsenal {
  position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: up .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes up { from { transform: translate(-50%, 120%); } }
#sel-info { transition: opacity .4s; padding: 5px 14px; border-radius: 14px; background: var(--glass); font-size: 13px; font-weight: 700; max-width: min(640px, 92vw); text-align: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); line-height: 1.3; }
#sel-info b { color: var(--jaune); margin-right: 6px; }
#arsenal .row { display: flex; gap: 8px; padding: 6px; border-radius: 22px; background: var(--glass); border: 2px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.group { display: flex; gap: 4px; }
.group + .group { padding-left: 8px; border-left: 2px solid var(--line); }
.slot {
  --s: clamp(46px, 7.4vmin, 64px);
  position: relative; width: var(--s); height: calc(var(--s) + 14px); border-radius: 14px;
  background: var(--glass2); border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  transition: transform .12s, background .15s, border-color .15s;
}
.slot canvas { width: var(--s); height: var(--s); margin-top: -4px; }
.slot .lab { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 10px; font-weight: 800; text-align: center; opacity: .85; white-space: nowrap; overflow: hidden; }
.slot em { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #fff; color: #1d3e78; font-style: normal; font-size: 13px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.slot:hover { background: rgba(255, 255, 255, .2); }
.slot:active { transform: scale(.92); }
.slot.sel { background: rgba(255, 216, 74, .28); border-color: var(--jaune); transform: translateY(-4px); }
.slot.vide { opacity: .35; filter: grayscale(1); }
.slot.vide em { background: #888; color: #fff; }
.slot.renfort.sel { background: rgba(124, 204, 43, .3); border-color: var(--vert); }

#hint { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; transform: translate(-50%, -50%); }
#hint span { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); background: rgba(10, 20, 50, .82); padding: 8px 14px; border-radius: 14px; font-weight: 800; font-size: 14px; text-align: center; white-space: nowrap; }
#hint .hand { left: -22px; top: -22px; }
#hint .hand { position: absolute; top: 0; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .9); box-shadow: 0 0 0 8px rgba(255, 255, 255, .3); animation: drag 1.8s ease-in-out infinite; }
@keyframes drag { 0%, 15% { transform: translate(0, 0) scale(1); opacity: 0; } 25% { opacity: 1; } 70% { transform: translate(calc(var(--dx, -1) * 80px), 60px) scale(.9); opacity: 1; } 85%, 100% { transform: translate(calc(var(--dx, -1) * 80px), 60px) scale(.9); opacity: 0; } }

#power-hint { position: absolute; left: 50%; bottom: calc(18% + var(--safe-b)); transform: translateX(-50%); padding: 12px 26px; border-radius: 30px; background: linear-gradient(#ffe27a, #f0a81a); color: #4a2a00; font-weight: 900; font-size: 22px; box-shadow: 0 6px 0 #a8640a, 0 12px 30px rgba(0, 0, 0, .3); animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.08); } }
#think { position: absolute; top: 0; left: 0; display: flex; gap: 6px; padding: 10px 14px; border-radius: 20px; background: rgba(10, 20, 50, .75); transform: translate(-50%, -100%); }
#think span { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: dot 1s infinite; }
#think span:nth-child(2) { animation-delay: .15s; }
#think span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { transform: translateY(-6px); opacity: .5; } }

#banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(.6); opacity: 0; text-align: center; pointer-events: none; }
#banner small { display: block; font-size: 15px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .85; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
#banner strong { display: block; font-size: clamp(30px, 6.5vmin, 60px); font-weight: 900; -webkit-text-stroke: .08em rgba(10, 15, 40, .8); paint-order: stroke fill; text-shadow: 0 6px 18px rgba(0, 0, 0, .4); color: var(--bc, #fff); white-space: nowrap; }
#banner.go { animation: ban 1.6s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes ban { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%) scale(.95); } }

/* téléphone en portrait : on demande de le tourner pendant la partie */
#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: linear-gradient(#2d6fc4, #173a7a); flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; }
#rotate p { margin: 0; font-size: 24px; font-weight: 900; line-height: 1.3; }
#rotate .phone { width: 70px; height: 120px; border: 6px solid #fff; border-radius: 16px; position: relative; animation: turn 2s ease-in-out infinite; }
#rotate .phone::after { content: ""; position: absolute; bottom: 6px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; }
@keyframes turn { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 600px) { body.playing #rotate { display: flex; } }

/* petits écrans (téléphone en paysage) */
@media (max-height: 460px) {
  .team { padding: 4px 8px 4px 4px; border-radius: 14px; }
  .team.right { padding: 4px 4px 4px 8px; }
  .team .ico { width: 34px; height: 34px; }
  .team .nom { font-size: 13px; }
  .team .eq { display: none; }
  .pct { font-size: 15px; min-width: 40px; }
  #tools { top: calc(56px + var(--safe-t)); }
  .tool { width: 40px; height: 40px; }
  #wind { padding: 4px 10px; font-size: 13px; }
  #mini { width: 180px; height: 28px; }
  #sel-info { font-size: 11px; padding: 3px 10px; position: absolute; bottom: calc(100% + 4px); white-space: nowrap; }
  #sel-info.fade { opacity: 0; }
  #hint span { font-size: 12px; bottom: 54px; }
  .slot { --s: 44px; height: 52px; border-radius: 11px; }
  .slot .lab { display: none; }
  .logo { font-size: 54px; }
  .tag { margin-bottom: 0; padding: 3px 12px; font-size: 14px; }
  .title-wrap { gap: 6px; }
  .big { padding: 9px 20px; font-size: 16px; }
  .menu { gap: 6px; }
  .chip { padding: 5px 12px; font-size: 13px; }
  .opts { margin-top: 0; }
  .card { padding: 12px 16px; gap: 6px; }
  .card h2 { font-size: 24px; margin: 0; }
  .end { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 620px; }
  .end > * { flex: 0 0 auto; }
  .end #end-sub, .end .stats { flex-basis: 100%; }
  #end-ico { width: 64px; height: 64px; margin: 0; }
  #end-title { font-size: 28px; align-self: center; }
  .end .big { min-width: 0; }
  .card:not(.wide) .big { min-width: 240px; }
  .end .big { min-width: 0; }
}
@media (max-width: 620px) {
  .team .bar { width: 70px; }
  .group + .group { padding-left: 4px; }
  .slot { --s: 40px; height: 48px; }
  .slot .lab { display: none; }
  #arsenal .row { gap: 4px; padding: 4px; }
  #mini { width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}
