/* La Tablée — styles communs. Ambiance « boîte de jeu » : couleurs franches, contours épais, ombres décalées,
   formes arrondies. Les composants (boutons, panneaux, champs) sont des pièces blanches cernées d’encre : ils restent
   lisibles sur le fond de n’importe quel jeu. */
:root {
  color-scheme: light;
  --ink: #1d1b33;          /* encre : texte et contours */
  --ink-2: #4a4766;
  --ink-3: #75728f;
  --paper: #fffdf6;        /* pièces (cartes, panneaux) */
  --paper-2: #f3f0e6;
  --sky: #7cc7ff;          /* fond de l’accueil */
  --sun: #ffd23f;          /* action principale */
  --pink: #ff7aa8;
  --mint: #4fd1a5;
  --grape: #8b6cff;
  --ok: #1f9d6b;
  --bad: #e2453c;
  --line: var(--ink);
  --stroke: 2.5px;
  --radius: 16px;
  --pop: 4px 4px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* compatibilité avec les feuilles des jeux */
  --lamp: var(--sun); --lamp-ink: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); font: 17px/1.5 var(--font-ui); font-weight: 600;
  background: var(--sky);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.1; margin: 0; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--grape); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 46px; padding: .55em 1.15em;
  border-radius: 14px; border: var(--stroke) solid var(--ink); background: var(--paper); color: var(--ink);
  font: 600 1rem/1.1 var(--font-display); cursor: pointer; text-decoration: none; box-shadow: var(--pop-sm);
  transition: transform .08s, box-shadow .08s, background .15s; -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn svg { width: 1.15em; height: 1.15em; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--pop-sm); }
.btn-primary { background: var(--sun); }
.btn-ghost { background: var(--paper-2); box-shadow: none; }
.btn-ghost:hover { box-shadow: var(--pop-sm); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-big { min-height: 56px; font-size: 1.15rem; padding: .7em 1.6em; }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; border: var(--stroke) solid var(--ink); background: var(--paper); cursor: pointer; color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.icon-btn:hover { background: var(--sun); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: .35rem; }
.field > span { font-size: .85rem; font-weight: 800; color: var(--ink); letter-spacing: .02em; }
input[type=text], input:not([type]), input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: .55em .85em; border-radius: 14px; border: var(--stroke) solid var(--ink);
  background: var(--paper); color: var(--ink); font-weight: 700; outline: none; transition: box-shadow .12s;
}
input::placeholder { color: var(--ink-3); font-weight: 600; }
input:focus, select:focus, textarea:focus { box-shadow: var(--pop-sm); }

.tag { display: inline-block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: .15em .6em; border-radius: 99px; background: var(--sun); color: var(--ink); border: 2px solid var(--ink); }
.tag-dim { background: var(--paper); }
.hint { color: var(--ink-2); font-size: .92rem; margin: .4rem 0 0; }
.code { font-family: var(--font-display); letter-spacing: .14em; }

.avatar { --c: #888; display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--c); color: var(--ink); font-weight: 800; font-size: .95rem; border: 2px solid var(--ink); }
.avatar.sm { width: 26px; height: 26px; font-size: .72rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1.2rem; }

.loading { min-height: 60dvh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--ink); font-family: var(--font-display); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(29,27,51,.2); border-top-color: var(--ink); animation: spin .8s linear infinite; display: inline-block; vertical-align: -5px; margin-right: .5em; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--paper); color: var(--ink); padding: .75em 1.1em; border-radius: 14px; border: var(--stroke) solid var(--ink); font-weight: 800; box-shadow: var(--pop);
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #ffd9d4; }
#netstatus { position: fixed; top: 0; left: 0; right: 0; z-index: 60; text-align: center; padding: .45em; background: var(--bad); color: #fff; font-weight: 800; border-bottom: var(--stroke) solid var(--ink); transform: translateY(-110%); transition: transform .2s; }
#netstatus.show { transform: none; }

/* ---------- Accueil ---------- */
.home { max-width: 1120px; margin: 0 auto; padding: 24px 16px calc(40px + var(--safe-b)); }
.home-head { padding: 20px 0 12px; }
.brand-row { display: flex; align-items: center; gap: .7rem; }
.brand-mark { width: 52px; height: 52px; display: inline-grid; place-items: center; color: var(--ink); background: var(--sun); border: var(--stroke) solid var(--ink); border-radius: 14px; box-shadow: var(--pop-sm); transform: rotate(-4deg); }
.brand-mark svg { width: 34px; height: 34px; fill: currentColor; stroke: none; }
.topbar-home svg { fill: currentColor; stroke: none; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.5rem, 7vw, 3.8rem); letter-spacing: -.02em; }
.home-lede { max-width: 42ch; color: var(--ink); font-size: 1.15rem; margin: .7rem 0 1.4rem; }
.home-forms { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: end; padding: 16px; border-radius: 20px; background: var(--paper); border: var(--stroke) solid var(--ink); box-shadow: var(--pop); width: fit-content; max-width: 100%; }
.home-forms .name-field { flex: 0 1 240px; min-width: 0; }
.join-form { display: flex; gap: .6rem; align-items: end; }
.join-form .field { width: auto; }
.join-form input { width: 130px; text-transform: uppercase; letter-spacing: .2em; font-family: var(--font-display); }
.section-title { font-size: 1.6rem; margin: 2.4rem 0 1rem; display: flex; align-items: center; gap: .7rem; }
.section-lede { color: var(--ink); margin: -.4rem 0 1rem; }

.boxes { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.box-inner {
  position: relative; width: 100%; height: 100%; text-align: left; cursor: pointer; display: flex; flex-direction: column;
  border-radius: 20px; overflow: hidden; padding: 0; background: var(--t-bg, var(--paper)); color: var(--t-ink, var(--ink));
  border: var(--stroke) solid var(--ink); box-shadow: var(--pop); transition: transform .12s, box-shadow .12s;
}
.box-inner:hover { transform: translate(-2px, -2px) rotate(-.6deg); box-shadow: 6px 6px 0 var(--ink); }
.box-inner:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.box-art { display: block; aspect-ratio: 1; overflow: hidden; background: #fff; border-bottom: var(--stroke) solid var(--ink); }
.box-art img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
[data-theme="so-clover"] .box-art img { object-position: 50% 38%; }
.box-inner:hover .box-art img { transform: scale(1.04); }
.box-text { display: grid; gap: .3rem; padding: 10px 14px 12px; flex: 1; align-content: start; }
.box-name { font-family: var(--t-font, var(--font-display)); font-size: 1.35rem; line-height: 1.05; font-weight: 700; }
.box-meta { display: flex; gap: .9rem; font-size: .85rem; font-weight: 800; }
.box-meta span { display: inline-flex; align-items: center; gap: .3em; }
.box-meta svg { width: 15px; height: 15px; }
.box-kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; opacity: .85; }
@media (max-width: 600px) {
  .boxes { grid-template-columns: 1fr 1fr; gap: 14px; }
  .box-inner { border-radius: 16px; box-shadow: var(--pop-sm); }
  .box-text { padding: 8px 10px 10px; }
  .box-name { font-size: 1.05rem; }
  .box-meta { font-size: .75rem; gap: .6rem; }
  .box-meta svg { width: 13px; height: 13px; }
}
.box.soon .box-inner { filter: grayscale(.8); opacity: .7; cursor: default; }
.box.soon .box-inner:hover { transform: none; box-shadow: var(--pop); }
.soon-label { background: var(--paper-2) !important; }

.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.link-card { display: grid; gap: .25rem; padding: 8px 14px; border-radius: 14px; border: var(--stroke) solid var(--ink); background: var(--paper); color: var(--ink); text-decoration: none; height: 100%; box-shadow: var(--pop-sm); transition: transform .1s, box-shadow .1s; }
.link-card:hover { transform: translate(-1px, -1px); box-shadow: var(--pop); background: #fff8d9; }
.link-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .4em; }
.link-name svg { width: 16px; height: 16px; }
.home-foot { margin-top: 3rem; color: var(--ink); font-size: .9rem; text-align: center; font-weight: 700; }

/* ---------- Page « votre prénom » et mot de passe ---------- */
.gate, .ask-name { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: min(400px, 100%); display: grid; gap: 1rem; justify-items: start; padding: 26px; border-radius: 22px; background: var(--paper); border: var(--stroke) solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.gate-card input, .gate-card .btn { width: 100%; }
.gate-card p { margin: 0; color: var(--ink-2); }
.gate-error { color: var(--bad) !important; font-weight: 800; }

/* ---------- Barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; padding: 8px 16px; min-height: 58px;
  background: var(--paper); border-bottom: var(--stroke) solid var(--ink); color: var(--ink); }
.topbar-home { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 700; }
.topbar-home svg { width: 30px; height: 30px; padding: 3px; color: var(--ink); background: var(--sun); border: 2px solid var(--ink); border-radius: 9px; }
.topbar-game { font-family: var(--t-font, var(--font-display)); font-weight: 700; font-size: 1.15rem; color: var(--ink); padding-left: .8rem; border-left: var(--stroke) solid var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-code { font-family: var(--font-display); font-weight: 600; letter-spacing: .14em; font-size: .85rem; padding: .15em .55em; border-radius: 9px; background: var(--t-bg, var(--sun)); color: var(--t-ink, var(--ink)); border: 2px solid var(--ink); }
.topbar-players { margin-left: auto; display: flex; }
.topbar-players .dot { margin-left: -6px; }
.topbar-players .dot.away { opacity: .35; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: var(--stroke) solid var(--ink); background: var(--paper); box-shadow: 2px 2px 0 var(--ink); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--sun); }
.menu summary svg { width: 22px; height: 22px; }
.menu-list { position: absolute; right: 0; top: 50px; min-width: 250px; padding: 6px; border-radius: 16px; background: var(--paper); border: var(--stroke) solid var(--ink); box-shadow: var(--pop); display: grid; }
.menu-list button { text-align: left; padding: .7em .8em; border: 0; background: transparent; border-radius: 10px; cursor: pointer; font-weight: 700; color: var(--ink); }
.menu-list button:hover { background: var(--sun); }
@media (max-width: 560px) {
  .topbar-home span, .topbar-code { display: none; }
  .topbar-game { border: 0; padding-left: 0; }
}

/* ---------- Salon d’attente ---------- */
.lobby { min-height: 100dvh; background: var(--t-page, var(--sky)); }
.lobby-main { max-width: 760px; margin: 0 auto; padding: 20px 16px calc(40px + var(--safe-b)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.lobby-hero { display: flex; gap: 1.2rem; align-items: center; padding: 20px; border-radius: 22px; background: var(--t-bg); color: var(--t-ink); border: var(--stroke) solid var(--ink); box-shadow: var(--pop); }
.lobby-art { flex: none; width: 96px; height: 96px; object-fit: cover; border-radius: 16px; background: #fff; border: var(--stroke) solid var(--ink); }
.lobby-title { font-family: var(--t-font, var(--font-display)); font-size: clamp(1.9rem, 5vw, 2.7rem); }
.lobby-title small { font-size: .55em; opacity: .9; }
.panel { padding: 18px 20px; border-radius: 20px; background: var(--paper); color: var(--ink); border: var(--stroke) solid var(--ink); box-shadow: var(--pop); }
.panel h2 { font-size: 1.25rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .6rem; }
.panel p { margin: .3rem 0; }
.count { font-size: .8rem; font-family: var(--font-ui); font-weight: 800; padding: .1em .55em; border-radius: 99px; background: var(--paper-2); border: 2px solid var(--ink); }
.invite-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.invite-url { flex: 1 1 260px; min-width: 0; padding: .65em .9em; border-radius: 14px; background: var(--paper-2); border: 2px dashed var(--ink); overflow-x: auto; white-space: nowrap; font-size: .95rem; }
.seats { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 8px; counter-reset: seat; }
.seat { display: flex; align-items: center; gap: .7rem; padding: 8px 10px; border-radius: 14px; background: var(--paper-2); border: 2px solid var(--ink); }
.seat.away { opacity: .55; }
.seat-name { font-weight: 800; }
.seat-name em { color: var(--ink-2); font-weight: 600; }
.seat-tools { margin-left: auto; display: flex; gap: 6px; }
.players-panel .name-field { max-width: 300px; }
.rules summary { cursor: pointer; list-style: none; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary h2 { margin: 0; }
.rules summary h2::after { content: '+'; margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; border: 2px solid var(--ink); background: var(--sun); font-size: 1.1rem; }
.rules[open] summary h2::after { content: '–'; }
.rules-body { color: var(--ink); font-weight: 600; }
.rules-body h3 { font-size: 1.05rem; margin: 1rem 0 .3rem; }
.rules-body ul, .rules-body ol { padding-left: 1.2rem; margin: .3rem 0; }
.rules-body li { margin: .25rem 0; }
.rules-dialog { max-width: min(640px, calc(100vw - 32px)); max-height: 85dvh; border: var(--stroke) solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); padding: 22px; box-shadow: 6px 6px 0 var(--ink); }
.rules-dialog::backdrop { background: rgba(29,27,51,.55); }
.rules-dialog h2 { margin-bottom: .6rem; }
.rules-dialog .btn { margin-top: 1rem; }
.start-bar { display: grid; justify-items: center; text-align: center; padding: 10px 0; }
.waiting { color: var(--ink); font-weight: 800; padding: .5em 1em; border-radius: 14px; background: var(--paper); border: var(--stroke) solid var(--ink); }
.options-grid { display: grid; gap: .8rem; }
.option { display: flex; align-items: center; gap: .7rem; justify-content: space-between; flex-wrap: wrap; }
.option select { width: auto; min-width: 160px; }
.spectator-banner { margin: 0; text-align: center; padding: .5em; background: var(--sun); color: var(--ink); font-weight: 800; border-bottom: var(--stroke) solid var(--ink); }
.placeholder-note { margin: 0 auto; width: fit-content; max-width: 100%; text-align: center; font-size: .85rem; font-weight: 800; padding: .25em .9em; border-radius: 99px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); }

/* ---------- Jeu ---------- */
.game { min-height: 100dvh; overflow-x: clip; background: var(--t-page, var(--sky)); color: var(--t-ink-page, var(--ink)); display: flex; flex-direction: column; }
.game-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 18px 16px calc(32px + var(--safe-b)); }
.noscript { padding: 2rem; text-align: center; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.rulebook { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 1rem 0 0; }
.rulebook small { color: var(--ink-2); font-weight: 700; }
.rulebook svg { width: 16px; height: 16px; }
