/* UNO · interface tactile, responsive, PWA */
:root {
  --bg: #0f3d2e; --bg2: #071f17; --felt: radial-gradient(ellipse at 50% 35%, #15563f 0%, #0f3d2e 45%, #071f17 100%);
  --fg: #f4f6f5; --muted: #a9c4b9; --panel: #142a22; --line: rgba(255,255,255,.12);
  --rouge: #e53935; --vert: #43a047; --bleu: #1e88e5; --jaune: #fdd835;
  --card-w: clamp(58px, 18vw, 96px); --card-h: calc(var(--card-w) * 1.5);
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg);
  background: var(--bg2); min-height: 100dvh; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
.app {
  min-height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto auto;
  background: var(--felt); max-width: 1000px; margin: 0 auto;
  padding: calc(var(--safe-t) + 6px) 12px calc(var(--safe-b) + 8px);
}
button { font: inherit; cursor: pointer; border: 0; border-radius: var(--radius); color: #fff; background: rgba(255,255,255,.12); padding: 12px 18px; min-height: 48px; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* En-tête */
.top { display: flex; align-items: center; gap: 10px; padding: 4px 2px 8px; }
.top h1 { margin: 0; font-size: 22px; }
.logo { display: inline-block; background: var(--rouge); color: #fff; padding: 2px 10px; border-radius: 10px; letter-spacing: 2px; transform: rotate(-4deg); box-shadow: 0 2px 0 #8e1b1b; }
.scores { display: flex; gap: 6px; align-items: center; margin-left: auto; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.25); }
.chip .who { color: var(--muted); }
.chip strong { font-size: 15px; }
.chip.me { border: 1px solid rgba(255,255,255,.25); }
.goal { color: var(--muted); font-size: 12px; }
.icon-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; font-size: 20px; line-height: 1; }

/* Adversaire */
.opponent { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 0 6px; }
.fan { display: flex; justify-content: center; height: calc(var(--card-h) * .55); }
.fan span { width: calc(var(--card-w) * .55); height: calc(var(--card-h) * .55); margin: 0 calc(var(--card-w) * -.17); border-radius: 7px; border: 2px solid #fff;
  background: repeating-linear-gradient(45deg, #b71c1c 0 6px, #7f0000 6px 12px); box-shadow: 0 2px 4px rgba(0,0,0,.5); transform-origin: 50% 120%; }
.who-line { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--muted); }
.who-line .name { font-weight: 600; color: var(--fg); }
.count { background: rgba(0,0,0,.25); padding: 2px 8px; border-radius: 999px; }

/* Centre : pioche, défausse, couleur, message */
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; padding: 6px 0; }
.piles { display: flex; align-items: center; gap: clamp(16px, 6vw, 40px); }
.deck { position: relative; width: var(--card-w); height: var(--card-h); padding: 0; background: none; min-height: 0; border-radius: 10px; }
.deck .back { position: absolute; inset: 0; border-radius: 10px; border: 3px solid #fff;
  background: repeating-linear-gradient(45deg, #b71c1c 0 8px, #7f0000 8px 16px); box-shadow: 0 3px 8px rgba(0,0,0,.6); }
.deck .back:nth-child(1) { transform: translate(-4px, 4px); } .deck .back:nth-child(2) { transform: translate(-2px, 2px); }
.deck .badge { position: absolute; right: -8px; bottom: -8px; background: #111; color: #fff; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; border: 2px solid #fff; }
.deck.turn .back.top { box-shadow: 0 0 0 3px #fff, 0 0 18px 4px rgba(255,255,255,.55); }
.deck:disabled { opacity: 1; } .deck:disabled .back { filter: brightness(.75); }
.discard-wrap { position: relative; width: var(--card-w); height: var(--card-h); }
.discard-wrap .card { position: absolute; inset: 0; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; background: #777; box-shadow: 0 0 0 3px rgba(0,0,0,.25); transition: background .2s; }
.color-dot.rouge { background: var(--rouge); } .color-dot.vert { background: var(--vert); }
.color-dot.bleu { background: var(--bleu); } .color-dot.jaune { background: var(--jaune); }
.turn { font-size: 13px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.14); }
.turn.me { background: #fff; color: #0f3d2e; }
.msg { margin: 0; text-align: center; font-size: 15px; min-height: 1.4em; max-width: 36ch; padding: 0 8px; }

/* Cartes */
.card { width: var(--card-w); height: var(--card-h); border-radius: 10px; border: 3px solid #fff; position: relative; overflow: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,.55); background: #555; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--card-w) * .42); line-height: 1; }
.card::before { content: ""; position: absolute; inset: 10% 14%; border-radius: 50%; background: rgba(255,255,255,.94); transform: rotate(-28deg); }
.card .v { position: relative; z-index: 1; color: var(--c, #333); text-shadow: 0 1px 0 #fff; }
.card .v.small { font-size: calc(var(--card-w) * .30); }
.card .corner { position: absolute; z-index: 1; font-size: calc(var(--card-w) * .17); color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.card .corner.tl { top: 4px; left: 6px; } .card .corner.br { bottom: 4px; right: 6px; transform: rotate(180deg); }
.card.rouge { background: var(--rouge); --c: #c62828; }
.card.vert  { background: var(--vert);  --c: #2e7d32; }
.card.bleu  { background: var(--bleu);  --c: #1565c0; }
.card.jaune { background: var(--jaune); --c: #a46b00; }
.card.joker { background: conic-gradient(var(--rouge) 0 25%, var(--bleu) 0 50%, var(--jaune) 0 75%, var(--vert) 0); --c: #222; }
.card.joker::before { background: rgba(255,255,255,.96); }
.card.pop { animation: pop .25s ease-out; }
@keyframes pop { 0% { transform: scale(1.25) rotate(-6deg); } 100% { transform: none; } }

/* Ma main */
section.me { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 4px; }
.hand { display: flex; flex-wrap: wrap; gap: 8px 6px; justify-content: center; min-height: var(--card-h); max-height: calc(var(--card-h) * 2.3 + 24px); overflow-y: auto; padding: 10px 4px 6px; }
.hand button.card { padding: 0; min-height: 0; transition: transform .15s, box-shadow .15s, opacity .15s; }
.hand button.card.ok { transform: translateY(-8px); box-shadow: 0 0 0 3px #fff, 0 8px 16px rgba(0,0,0,.6); cursor: pointer; }
.hand button.card.ok:active { transform: translateY(-2px) scale(.97); }
.hand button.card:not(.ok) { opacity: .55; filter: saturate(.7); }
.hand button.card.drawn { outline: 3px dashed #fff; outline-offset: 3px; }
.hand button.card.enter { animation: enter .35s ease-out; }
@keyframes enter { 0% { transform: translateY(-50px) scale(.6); opacity: 0; } 100% { opacity: 1; } }

/* Barre d'actions */
.actions { display: flex; gap: 10px; justify-content: center; padding-top: 6px; }
.act { flex: 1; max-width: 220px; font-weight: 700; font-size: 17px; min-height: 52px; }
.act.draw { background: #fff; color: #0f3d2e; }
.act.draw:disabled { background: rgba(255,255,255,.25); color: #fff; opacity: 1; }
.ghost { background: rgba(255,255,255,.14); }
.primary { background: var(--bleu); }
.uno { background: var(--rouge); font-size: 20px; animation: pulse 1s infinite; }
.catch { background: var(--jaune); color: #222; animation: pulse .6s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* Fenêtres */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); display: flex; align-items: flex-end; justify-content: center; padding: 12px; z-index: 10; }
.modal[hidden] { display: none; }
.box { background: var(--panel); border-radius: 20px; padding: 20px; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px; margin-bottom: var(--safe-b); box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.box h2 { margin: 0; font-size: 20px; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick { padding: 26px 0; font-weight: 800; font-size: 18px; min-height: 72px; }
.pick.rouge { background: var(--rouge); } .pick.vert { background: var(--vert); }
.pick.bleu { background: var(--bleu); } .pick.jaune { background: var(--jaune); color: #222; }
.rules ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.rules li { margin-bottom: 6px; }
.sheet .hint, .sheet .version { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); background: #fff; color: #111; padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: toast 2.4s forwards; max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* Grands écrans : fenêtres centrées, cartes plus grandes */
@media (min-width: 700px) {
  :root { --card-w: 92px; }
  .modal { align-items: center; }
  .msg { font-size: 17px; }
}
/* Téléphone en paysage : tout doit tenir sans défiler */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --card-w: clamp(44px, 8.5vh, 60px); }
  .app { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; padding-bottom: 6px; }
  .top { grid-column: 1 / -1; }
  .opponent { grid-column: 1; grid-row: 2; }
  .center { grid-column: 2; grid-row: 2 / 4; }
  .me { grid-column: 1; grid-row: 3; }
  .actions { grid-column: 1 / -1; grid-row: 4; }
  .hand { max-height: calc(var(--card-h) * 1.3 + 16px); }
}
@media (prefers-reduced-motion: reduce) { .uno, .catch, .card.pop, .hand button.card.enter, .toast { animation: none; } }
