* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1b2b;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
}
canvas { display: block; }
#ui { 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); pointer-events: none; }

#screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#screen:empty { display: none; }

.panel {
  pointer-events: auto;
  background: rgba(8, 20, 36, 0.9);
  border: 2px solid rgba(47, 227, 138, 0.45);
  border-radius: 18px;
  padding: 18px 22px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.center { text-align: center; }
h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 46px); letter-spacing: 1px; color: #2fe38a; text-shadow: 0 3px 0 #0a3d27; }
h2 { margin: 0 0 10px; font-size: 22px; }
p { margin: 6px 0 12px; opacity: 0.85; }

button {
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: #1fb872;
  border: 0;
  border-bottom: 4px solid #0d7a4a;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(2px); border-bottom-width: 2px; }
button.alt { background: #3b4a63; border-bottom-color: #25314a; }

.grid4 { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.card {
  background: #14304d;
  border-bottom-color: #0c1f33;
  border-left: 8px solid var(--c, #2fe38a);
  text-align: left;
  padding: 16px;
}
.card small { display: block; opacity: 0.75; font-weight: 400; }
.card span.big { font-size: 20px; }

.clubs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 12px 0; }
.club { display: flex; align-items: center; gap: 10px; background: #14304d; border-bottom-color: #0c1f33; text-align: left; padding: 10px 12px; }
.club .meta { flex: 1; min-width: 0; }
.club .nm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { display: block; height: 6px; margin-top: 5px; background: #0b1b2b; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #f5c400, #2fe38a); }

.chip {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  flex: none;
  vertical-align: middle;
}

.hub { display: grid; grid-template-columns: minmax(260px, 340px) minmax(300px, 520px); gap: 16px; align-items: start; }
@media (max-width: 760px) { .hub { grid-template-columns: 1fr; } }
.next { text-align: center; }
.vs { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 22px; font-weight: 800; margin: 12px 0; flex-wrap: wrap; }
.vs em { opacity: 0.6; font-style: normal; font-size: 16px; }
.btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.last { text-align: left; font-size: 13px; opacity: 0.9; margin-top: 14px; }
.last div { padding: 2px 0; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 4px 6px; text-align: center; }
th { opacity: 0.6; font-weight: 600; font-size: 12px; }
td.nm { text-align: left; white-space: nowrap; }
tr.me { background: rgba(47, 227, 138, 0.22); font-weight: 800; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
tr.me:nth-child(even) { background: rgba(47, 227, 138, 0.22); }
.tablebox { max-height: 72vh; overflow: auto; }

.result-score { font-size: clamp(40px, 9vw, 80px); font-weight: 900; margin: 6px 0; }
.result-score .chip { width: 36px; height: 36px; }

#hud { position: absolute; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hud .score {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(8, 20, 36, 0.82);
  border-radius: 14px;
  padding: 6px 16px;
  font-size: 20px;
  font-weight: 800;
}
#hud .score b { font-size: 30px; min-width: 24px; text-align: center; }
#hud .score em { opacity: 0.5; font-style: normal; }
#clock { background: rgba(8, 20, 36, 0.82); border-radius: 10px; padding: 2px 12px; font-weight: 700; }

#banner {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(36px, 8vw, 90px);
  font-weight: 900;
  color: #ffe44d;
  text-shadow: 0 5px 0 #7a5b00, 0 0 30px rgba(0, 0, 0, 0.6);
  animation: pop 0.35s ease-out;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#power { position: absolute; bottom: 60px; left: 50%; width: 220px; height: 16px; margin-left: -110px; background: rgba(0, 0, 0, 0.55); border-radius: 8px; overflow: hidden; border: 2px solid #fff; }
#power i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2fe38a, #ffe44d, #ef4444); }
#help { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 14px; text-shadow: 0 2px 4px #000; }

.crest { width: 32px; height: 38px; vertical-align: middle; flex: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.club .crest { width: 36px; height: 43px; }
td.nm .crest { width: 19px; height: 23px; }
.vs .crest { width: 44px; height: 53px; }
.result-score .crest { width: 64px; height: 77px; }
#hud .crest { width: 34px; height: 41px; }

.card.wide { grid-column: 1 / -1; text-align: center; border-left-width: 0; border-bottom: 4px solid #f5c400; }
.pairs { display: grid; gap: 6px; min-width: 260px; }
.pair { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 10px; background: rgba(255, 255, 255, 0.06); border-radius: 10px; font-weight: 700; }
.pair em { opacity: 0.6; font-style: normal; font-size: 13px; }
.pair.me { background: rgba(47, 227, 138, 0.25); }
.pair .crest { width: 26px; height: 31px; }

/* commandes tactiles */
html, body { touch-action: manipulation; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#touch { position: absolute; left: 0; right: 0; bottom: 0; height: 190px; pointer-events: none; }
#stick {
  pointer-events: auto;
  touch-action: none;
  position: absolute;
  left: 28px;
  bottom: 28px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 3px solid rgba(255, 255, 255, 0.5);
}
#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  pointer-events: none;
}
#tbtns { position: absolute; right: 24px; bottom: 28px; display: flex; align-items: flex-end; gap: 12px; }
#tbtns button {
  pointer-events: auto;
  touch-action: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  padding: 0;
  font-size: 15px;
  background: rgba(31, 184, 114, 0.8);
  border: 3px solid #fff;
}
#tbtns #bShoot { width: 108px; height: 108px; font-size: 20px; background: rgba(239, 68, 68, 0.85); }
#tbtns #bJump { background: rgba(34, 197, 94, 0.85); }
#tbtns #bTackle { background: rgba(249, 115, 22, 0.85); }
#tbtns #bSprint { background: rgba(59, 130, 246, 0.8); }
#tbtns button.on { transform: scale(0.92); filter: brightness(1.3); }
#power { bottom: 150px; }
.panel, .tablebox { touch-action: pan-y; }

/* petits écrans en mode paysage (téléphone) */
@media (max-height: 480px) {
  #touch { height: 150px; }
  #stick { width: 110px; height: 110px; left: 20px; bottom: 16px; }
  #knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  #tbtns { right: 16px; bottom: 16px; gap: 8px; }
  #tbtns button { width: 66px; height: 66px; font-size: 12px; }
  #tbtns #bShoot { width: 84px; height: 84px; font-size: 16px; }
  #power { bottom: 110px; }
  #hud .score { font-size: 16px; padding: 3px 12px; }
  #hud .score b { font-size: 22px; }
  .tablebox { max-height: 60vh; }
}

.crest { filter: drop-shadow(0 0 3px rgba(255, 215, 90, 0.75)); }
