@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/lexend-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/lexend-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f3ede0;
  --card: #fbf7ee;
  --white: #fffdf8;
  --ink: #1f1b16;
  --ink-2: #645c50;
  --rule: #d5cab4;
  --red: #d8432f;
  --blue: #2c63c9;
  --mark: #ffe27a;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: 'Lexend', system-ui, sans-serif;
  font-weight: 400;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(31, 27, 22, .045) 1px, transparent 1.2px);
  background-size: 5px 5px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

input, select, textarea, button { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--red); }
a:hover { color: var(--red); }

h1, h2, h3 { line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; margin-top: 1.2em; }

code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--white); border: 1px solid var(--rule); padding: .05em .35em; border-radius: 3px; }
pre.code { padding: 1em; overflow: auto; white-space: pre; display: block; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-2); font-size: .9rem; }
.kicker { color: var(--ink-2); font-size: .85rem; font-weight: 500; margin: 0 0 .2em; }
.err-text { color: var(--red); font-weight: 600; }
.ok-text { color: #2f7a47; font-weight: 600; }
.empty { color: var(--ink-2); font-size: .9rem; list-style: none; padding: .3em 0; font-style: italic; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem clamp(1rem, 3vw, 2rem);
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.05rem; }
.brand:hover { color: var(--ink); }
.ball {
  width: 30px; height: 30px; border-radius: 50%; background: var(--red);
  display: grid; place-items: center; flex: none;
  box-shadow: inset -3px -4px 0 rgba(0, 0, 0, .18);
}
.ball span {
  width: 19px; height: 19px; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; font-size: .62rem; font-weight: 800; color: var(--ink);
}
.topnav { display: flex; align-items: center; gap: 1.3rem; }
.topnav a, .linklike { color: var(--ink); text-decoration: none; font-weight: 500; font-size: .93rem; background: none; border: 0; cursor: pointer; padding: 0; }
.topnav a:hover, .linklike:hover, .topnav a.active { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 4px; color: var(--ink); }
form.inline { display: inline; margin: 0; }

/* ---------- Mises en page ---------- */
main { padding: clamp(1rem, 3vw, 2rem); }
.narrow { max-width: 520px; margin: 1rem auto 0; }
.wide { max-width: 1180px; margin: 0 auto; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 2px solid var(--ink); border-radius: 4px; padding: 1.3rem; margin-bottom: 1.3rem; }
.small-card summary { cursor: pointer; font-weight: 600; }

.flash { max-width: 1180px; margin: 1rem auto 0; padding: .7rem 1rem; border: 2px solid var(--ink); border-radius: 4px; font-weight: 500; }
main .flash { margin: 0 0 1rem; }
.flash-ok { background: #e3efd9; }
.flash-err { background: #f7d9d2; }

/* ---------- Formulaires ---------- */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form.compact { gap: .6rem; }
.form label, .dialog label { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  background: var(--white); border: 1.5px solid var(--ink); border-radius: 3px;
  padding: .55rem .7rem; color: var(--ink); width: 100%; outline: none; font-weight: 400;
}
input::placeholder, textarea::placeholder { color: #a79d8c; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px var(--mark); }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
@media (max-width: 600px) { .row3 { grid-template-columns: 1fr 1fr; } }
.checks { display: flex; flex-direction: column; gap: .45rem; }
label.check { flex-direction: row !important; align-items: center; gap: .5rem !important; font-weight: 400 !important; font-size: .92rem !important; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--ink); width: 1.05rem; height: 1.05rem; }

.filters summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: .3rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: .25rem .6rem; border-radius: 3px; border: 1.5px solid var(--ink); font-size: .82rem; background: var(--white); }
.chip span small { color: var(--ink-2); }
.chip input:checked + span { background: var(--ink); color: var(--card); }
.chip input:checked + span small { color: #cfc6b5; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--mark); }

.colors { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.colors legend { font-size: .86rem; font-weight: 600; margin-bottom: .5rem; padding: 0; }
.swatch { cursor: pointer; position: relative; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 38px; height: 38px; border-radius: 50% 46% 52% 48% / 48% 52% 47% 53%; background: var(--c); opacity: .85; }
.swatch input:checked + span { opacity: 1; box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--mark); }
.swatch.taken { cursor: not-allowed; }
.swatch.taken span { opacity: .15; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 4px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: .92rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.btn:hover { background: var(--white); color: var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #c33a27; color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red); box-shadow: 0 2px 0 var(--red); }
.btn-danger:hover { color: var(--red); background: #fbe9e4; }
.btn-ghost { box-shadow: none; border-color: transparent; background: transparent; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.btn-ghost:hover { background: transparent; text-decoration-color: var(--ink); }
.btn-ghost:active { transform: none; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; border-width: 1.5px; }
.btn-lg { padding: .75rem 1.3rem; font-size: 1.02rem; }
.icon-btn {
  background: var(--white); border: 1.5px solid var(--ink); border-radius: 3px; color: var(--ink);
  font-size: .74rem; font-weight: 500; padding: .12rem .45rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.icon-btn:hover { background: var(--mark); color: var(--ink); }
.icon-btn.danger { border-color: var(--red); color: var(--red); }
.icon-btn.danger:hover { background: #fbe9e4; }

/* ---------- Accueil ---------- */
.home-main { max-width: 1120px; margin: 0 auto; }
.home-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: center; padding: clamp(1.5rem, 5vw, 3.5rem) 0 2rem; }
@media (max-width: 860px) { .home-top { grid-template-columns: 1fr; } }
.home-intro h1 { font-size: clamp(2.4rem, 5.5vw, 3.8rem); font-weight: 800; letter-spacing: -.035em; margin-bottom: .4em; }
.lead { font-size: 1.15rem; font-weight: 400; }
.home-intro p { max-width: 34em; }

.ticket {
  margin-top: 1.8rem; max-width: 380px; position: relative;
  background: var(--mark); border: 2px solid var(--ink); border-radius: 4px;
  padding: .9rem 1rem 1rem 1.6rem;
}
.ticket::before {
  content: ''; position: absolute; left: .55rem; top: 8px; bottom: 8px;
  border-left: 2px dashed rgba(31, 27, 22, .45);
}
.ticket label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .4rem; }
.ticket-row { display: flex; gap: .5rem; }
.ticket input {
  text-transform: uppercase; letter-spacing: .25em; font-weight: 700; font-size: 1.3rem !important;
  padding: .45rem .7rem !important; background: var(--white) !important;
}
.ticket .err-text { margin: .6rem 0 0; font-size: .88rem; }

.sample { margin: 0; transform: rotate(1.8deg); }
.sample-board { max-width: 470px; box-shadow: 6px 8px 0 rgba(31, 27, 22, .14); }
.sample-board .cell { cursor: default; }
.sample figcaption { font-size: .85rem; color: var(--ink-2); margin-top: .9rem; transform: rotate(-1.8deg); text-align: center; }

.home-rules { border-top: 2px solid var(--ink); padding-top: 1.5rem; margin-bottom: 3rem; max-width: 720px; }
.home-rules ol { padding-left: 1.3rem; margin: 0 0 1.2rem; }
.home-rules li { margin-bottom: .55rem; padding-left: .3rem; }
.home-rules li::marker { font-weight: 800; color: var(--red); }

/* ---------- Admin ---------- */
.game-list { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.game-item { display: flex; align-items: center; gap: .8rem; padding: .65rem .2rem; border-bottom: 1px solid var(--rule); }
.game-item:hover { background: rgba(255, 226, 122, .35); }
.game-item form { margin: 0; }
.game-item-main { flex: 1; display: grid; grid-template-columns: auto 1fr; column-gap: .8rem; align-items: center; text-decoration: none; color: var(--ink); min-width: 0; }
.game-item-main:hover { color: var(--ink); }
.game-item-main .muted { grid-column: 2; font-size: .8rem; }
.game-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-tag { grid-row: span 2; font-weight: 700; letter-spacing: .12em; background: var(--mark); border: 1.5px solid var(--ink); padding: .25rem .5rem; border-radius: 3px; font-size: .85rem; }
.status { font-size: .8rem; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
.status-running::before { background: #2f9455; }
.status-paused::before { background: #e09b12; }
.status-finished::before { background: var(--ink); }
.status-lobby::before { background: transparent; border: 1.5px solid var(--ink-2); }

.toolbar { display: flex; gap: .5rem; margin-bottom: .8rem; }
.toolbar select { max-width: 240px; }
.ch-list { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.ch-row { display: flex; gap: .3rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--rule); }
.ch-row form { margin: 0; }
.ch-edit { flex: 1; display: grid; grid-template-columns: 1fr 130px 100px auto; gap: .35rem; }
.ch-edit input, .ch-edit select { padding: .32rem .5rem !important; font-size: .88rem; border-width: 1px !important; border-color: var(--rule) !important; }
.ch-edit input:focus, .ch-edit select:focus { border-color: var(--ink) !important; }
.ch-row.off .ch-label { color: #a79d8c; text-decoration: line-through; }
@media (max-width: 700px) { .ch-edit { grid-template-columns: 1fr 1fr; } .ch-label { grid-column: span 2; } }

/* ---------- Partie (commun) ---------- */
.play-main, .host-main { max-width: 1360px; margin: 0 auto; }
.play-head, .host-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.play-head h1, .host-head h1 { margin-bottom: .15rem; }
.rules { color: var(--ink-2); font-size: .86rem; margin: 0; }
.head-right { display: flex; align-items: center; gap: 1.2rem; }
.me-tag { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; }
.me-tag i { width: 16px; height: 16px; border-radius: 50% 46% 52% 48%; background: var(--c); }

.play-layout, .host-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 2rem; align-items: start; }
.host-layout { grid-template-columns: minmax(0, 1fr) 370px; }
@media (max-width: 1000px) { .play-layout, .host-layout { grid-template-columns: 1fr; } }
.side { display: flex; flex-direction: column; gap: 1.6rem; min-width: 0; }
.panel { border-top: 2px solid var(--ink); padding-top: .7rem; }
.panel h2 { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.count { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.panel-queue .count:not(:empty) { background: var(--red); color: #fff; border-radius: 3px; padding: 0 .4rem; }
.hint { color: var(--ink-2); font-size: .86rem; text-align: center; margin: .9rem 0 0; }

.timer { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.timer-main { font-weight: 700; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.timer-sub { font-size: .75rem; color: var(--ink-2); margin-top: .25rem; }
.timer[data-status=paused] .timer-main { color: #b67c06; }
.timer.urgent .timer-main { color: var(--red); }

.banner { margin-bottom: 1.2rem; padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: 4px; font-size: 1.02rem; }
.banner b { font-weight: 800; margin-right: .3rem; }
.banner-end { background: var(--mark); }
.banner-end b { color: var(--c); }
.banner-pause { background: repeating-linear-gradient(-45deg, var(--card) 0 10px, #efe6d3 10px 20px); }

/* ---------- Le carton ---------- */
.board-wrap { min-width: 0; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 6px;
  container-type: inline-size;
  max-width: min(100%, 76vh);
  margin: 0 auto;
}
.board-letter {
  background: var(--red); color: #fff; text-align: center;
  font-weight: 800; font-size: calc(100cqw / var(--n, 5) * .3); line-height: 1.25;
}
.board-letter:first-child { border-top-left-radius: 3px; }
.board-letter:nth-child(5) { border-top-right-radius: 3px; }
.cell {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  padding: 7%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: calc(100cqw / var(--n, 5) * .112);
  font-weight: 500;
  line-height: 1.18;
  overflow: hidden;
  cursor: default;
  overflow-wrap: break-word;
}
.cell.t-sm { font-size: calc(100cqw / var(--n, 5) * .098); }
.cell.t-xs { font-size: calc(100cqw / var(--n, 5) * .084); }
.cell-label { position: relative; z-index: 2; display: block; }
.board.interactive .cell { cursor: pointer; }
.board.interactive .cell:not(.owned):not(.locked):hover { background: #fff3c2; }
.board.interactive .cell.locked { cursor: not-allowed; }

/* Le coup de tampon. Chaque case a sa petite rotation pour que ça ne fasse pas trop propre. */
.cell.owned::before {
  content: '';
  position: absolute; inset: 8%;
  border-radius: 50% 45% 53% 47% / 47% 53% 46% 54%;
  background: radial-gradient(circle at 45% 42%, color-mix(in srgb, var(--owner) 58%, transparent) 0 48%, var(--owner) 78%);
  mix-blend-mode: multiply;
  opacity: .82;
  z-index: 1;
  transform: rotate(var(--rot, 0deg)) translate(var(--dx, 0), var(--dy, 0));
}
.rot-0 { --rot: -9deg; --dx: 2%; --dy: -1%; }
.rot-1 { --rot: 6deg; --dx: -2%; --dy: 2%; }
.rot-2 { --rot: -3deg; --dx: 1%; --dy: 3%; }
.rot-3 { --rot: 12deg; --dx: -3%; --dy: -2%; }
.rot-4 { --rot: -14deg; --dx: 3%; --dy: 1%; }
.cell.owned { font-weight: 700; }
.cell-owner {
  position: absolute; left: 0; right: 0; bottom: 4%; z-index: 2;
  font-size: .64em; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6%;
}
.cell.owned .cell-label { margin-bottom: .45em; }
.cell-dots { position: absolute; top: 5%; right: 5%; z-index: 3; display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 70%; }
.dot { width: .6em; height: .6em; min-width: 7px; min-height: 7px; border-radius: 50%; background: var(--c); }
.dot-pending { background: transparent; border: 1.5px dashed var(--c); }
.cell.has-pending:not(.owned)::after {
  content: ''; position: absolute; inset: 10%; border-radius: 50%;
  border: 1.5px dashed rgba(31, 27, 22, .35);
}
.cell.mine-pending { background: repeating-linear-gradient(-45deg, var(--card) 0 7px, #f1e8d2 7px 14px); }
.cell.selected { box-shadow: inset 0 0 0 4px var(--blue); }
.board.swapping .cell { cursor: copy; }
.cell.pop::before { animation: stamp .32s cubic-bezier(.3, 1.4, .5, 1); }
.cell.win { background: var(--mark); }
@keyframes stamp { from { transform: rotate(var(--rot)) scale(1.5); opacity: 0; } }

.board.is-hidden .cell {
  font-size: calc(100cqw / var(--n, 5) * .3);
  font-weight: 800; color: #c9bea8;
  background: repeating-linear-gradient(45deg, #efe7d6 0 6px, var(--card) 6px 12px);
}

/* ---------- Classement ---------- */
.scores { list-style: none; margin: 0; padding: 0; }
.score {
  display: grid; grid-template-columns: 1.3em minmax(0, 1fr) auto 1.8ch; align-items: center; gap: .5rem;
  padding: .45rem .2rem; border-bottom: 1px solid var(--rule);
}
.score-rank { font-weight: 700; color: var(--ink-2); font-size: .85rem; }
.score-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .45rem; }
.score-name::before { content: ''; flex: none; width: 13px; height: 13px; border-radius: 50% 45% 53% 47%; background: var(--c); }
.score.me .score-name { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.score-num { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.score-lines { grid-column: 2 / -1; font-size: .78rem; font-weight: 600; color: var(--red); margin-top: -.2rem; }
.score-lines:empty { display: none; }
.score.winner { background: var(--mark); }

.tally { display: inline-flex; gap: .45em; align-items: center; height: 1em; }
.tally-group { position: relative; display: inline-flex; gap: 3px; }
.tally-group i { display: block; width: 2px; height: 1em; background: var(--ink); border-radius: 1px; }
.tally-group i:nth-child(2) { transform: rotate(3deg); }
.tally-group i:nth-child(3) { transform: rotate(-2deg); height: .95em; }
.tally-group.full::after {
  content: ''; position: absolute; left: -3px; right: -3px; top: 50%;
  height: 2px; background: var(--ink); transform: rotate(-24deg);
}

/* ---------- Journal ---------- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.ev { display: grid; grid-template-columns: 8px 1fr auto; gap: .55rem; align-items: baseline; font-size: .86rem; padding: .32rem 0; border-bottom: 1px dotted var(--rule); }
.ev::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); transform: translateY(-1px); }
.ev-time { color: var(--ink-2); font-size: .75rem; white-space: nowrap; }
.ev-valid .ev-msg { font-weight: 600; }
.ev-refused .ev-msg, .ev-cancel .ev-msg, .ev-withdraw .ev-msg { color: var(--ink-2); }
.ev-end { background: var(--mark); padding-left: .3rem; padding-right: .3rem; }
.ev-end .ev-msg { font-weight: 700; }

/* ---------- Mes demandes ---------- */
.claims-mini { list-style: none; margin: 0; padding: 0; }
.cm { display: grid; grid-template-columns: 1fr auto; gap: 0 .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--rule); font-size: .88rem; }
.cm .btn { grid-row: span 2; }
.cm-label { font-weight: 600; }
.cm-game { color: var(--ink-2); font-size: .8rem; }
.cm.pending .cm-label::after { content: ' (en attente)'; font-weight: 400; color: #b67c06; font-size: .8rem; }
.cm.valid .cm-label::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); margin-right: .4rem; }

/* ---------- Régie ---------- */
.share { display: flex; align-items: center; gap: 1rem; }
.big-code {
  font-size: 2rem; font-weight: 800; letter-spacing: .16em;
  background: var(--mark); border: 2px solid var(--ink); border-radius: 4px;
  padding: .1rem .5rem .1rem 1.3rem; position: relative;
}
.big-code::before { content: ''; position: absolute; left: .5rem; top: 6px; bottom: 6px; border-left: 2px dashed rgba(31, 27, 22, .45); }
.share-links { display: flex; flex-direction: column; gap: .45rem; }
.controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.2rem; padding: .7rem 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.controls .timer { margin-left: auto; }
.board-tools { display: flex; justify-content: flex-end; min-height: 1.6rem; margin-bottom: .5rem; font-size: .88rem; }

.queue { display: flex; flex-direction: column; gap: .7rem; max-height: 62vh; overflow: auto; padding-right: 2px; }
.queue .empty { margin: 0; }
.qcard { background: var(--card); border: 1.5px solid var(--ink); border-left: 7px solid var(--c); border-radius: 3px; padding: .65rem .75rem; display: flex; flex-direction: column; gap: .25rem; }
.qcard-head { display: flex; justify-content: space-between; align-items: baseline; }
.qcard-player { font-weight: 700; }
.qcard-time { font-size: .75rem; color: var(--ink-2); }
.qcard-cell { font-weight: 700; font-size: 1.02rem; line-height: 1.25; }
.qcard-game { font-size: .88rem; }
.qcard-note { font-size: .84rem; color: var(--ink-2); font-style: italic; }
.qcard-img { width: 100%; max-height: 180px; object-fit: cover; border: 1px solid var(--ink); border-radius: 2px; cursor: zoom-in; margin-top: .2rem; }
.qcard-link { font-size: .86rem; font-weight: 600; }
.qcard-actions { display: flex; gap: .3rem; margin-top: .35rem; }

.players { list-style: none; margin: 0; padding: 0; }
.pl { display: grid; grid-template-columns: 13px 1fr auto; column-gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.pl-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50% 45% 53% 47%; background: var(--c); }
.pl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pl-score { font-size: .8rem; color: var(--ink-2); }
.pl-actions { grid-column: 2 / span 2; display: flex; gap: .3rem; margin-top: .3rem; }

.claim-row { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px solid var(--rule); font-size: .9rem; }
.award { display: grid; grid-template-columns: 1fr 1fr auto; gap: .4rem; }
@media (max-width: 500px) { .award { grid-template-columns: 1fr; } }

/* ---------- Boîtes de dialogue ---------- */
.dialog {
  background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 5px;
  padding: 1.3rem 1.4rem; width: min(470px, calc(100vw - 2rem));
  box-shadow: 8px 10px 0 rgba(31, 27, 22, .2);
}
.dialog::backdrop { background: rgba(31, 27, 22, .4); }
.dialog form, #cell-dialog-body { display: flex; flex-direction: column; gap: .8rem; }
.dialog h2 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.dialog h3 { margin: .5rem 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.dialog-actions.left { justify-content: flex-start; }
.dialog-image { width: min(1100px, calc(100vw - 2rem)); }
.dialog-image img { width: 100%; display: block; border: 1px solid var(--ink); }

.file-drop { border: 1.5px dashed var(--ink); border-radius: 3px; padding: .9rem; text-align: center; cursor: pointer; background: var(--white); }
.file-drop:hover { background: #fff3c2; }
.file-drop.has-file { background: var(--mark); border-style: solid; }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-drop span { font-weight: 600; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--card); padding: .6rem 1rem; border-radius: 4px; font-weight: 500; font-size: .92rem; border-left: 6px solid var(--card); transition: opacity .4s; }
.toast-ok { border-left-color: #6cc48a; }
.toast-err { border-left-color: var(--red); }
.toast-info { border-left-color: var(--mark); }
.toast.out { opacity: 0; }

body.offline::after {
  content: 'Connexion perdue, je réessaie';
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: var(--red); color: #fff; text-align: center; font-weight: 600; font-size: .85rem; padding: .35rem;
}

/* ---------- Ecran spectateur ---------- */
body.screen { overflow: hidden; }
body.screen.transparent { background: transparent; }
.screen-main { height: 100vh; display: flex; flex-direction: column; padding: 2.5vh 2.5vw; max-width: none; }
.screen-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2.5vh; padding-bottom: 1.5vh; border-bottom: 2px solid var(--ink); }
.screen-head h1 { font-size: clamp(1.6rem, 3vw, 3.2rem); margin: 0; }
.screen-head .kicker { font-size: clamp(.8rem, 1vw, 1.1rem); }
.screen-head .rules { font-size: clamp(.8rem, .95vw, 1.05rem); }
.screen-head-right { display: flex; align-items: flex-end; gap: 1.5rem; }
.timer-xl .timer-main { font-size: clamp(2rem, 4vw, 4.2rem); }
.join-hint { font-size: clamp(.9rem, 1.2vw, 1.3rem); text-align: right; }
.join-hint b { display: inline-block; background: var(--mark); border: 2px solid var(--ink); border-radius: 3px; padding: 0 .4em; letter-spacing: .14em; margin-left: .2em; }
.screen-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 26vw, 460px); grid-template-rows: minmax(0, 1fr); gap: 3vw; }
.screen-layout .side { min-height: 0; overflow: hidden; }
.screen-layout .board-wrap { display: flex; align-items: center; justify-content: center; min-height: 0; }
.board-xl { width: min(100%, calc((100vh - 13rem) * .89)); max-width: none; }
.scores-xl .score { font-size: clamp(1rem, 1.25vw, 1.4rem); padding: .55rem .2rem; }
.feed-xl { max-height: none; overflow: hidden; }
.feed-xl .ev { font-size: clamp(.82rem, .95vw, 1.05rem); }
.spotlight { border-top: 2px solid var(--ink); padding-top: .8rem; }
.spotlight img { width: 100%; max-height: 22vh; object-fit: cover; border: 2px solid var(--ink); margin-bottom: .6rem; transform: rotate(-1deg); }
.spot-kicker { margin: 0 0 .2rem; font-size: .85rem; color: var(--ink-2); }
.spot-cell { margin: 0; font-weight: 800; font-size: clamp(1.1rem, 1.6vw, 1.7rem); line-height: 1.15; }
.spot-who { margin: .3rem 0 0; }
.spot-who b { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.spotlight.flash .spot-cell { animation: hl 1.6s ease-out; }
@keyframes hl { from { background: var(--mark); } to { background: transparent; } }

.celebrate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(243, 237, 224, .88); cursor: pointer; }
.celebrate[hidden] { display: none; }
.celebrate-inner { text-align: center; }
.celebrate-word {
  display: inline-block; margin: 0;
  font-size: clamp(4.5rem, 15vw, 13rem); font-weight: 900; line-height: 1; letter-spacing: .02em;
  color: var(--c); border: .07em solid var(--c); border-radius: .1em; padding: .02em .25em .06em;
  transform: rotate(-8deg); mix-blend-mode: multiply; opacity: .92;
}
.celebrate-name { font-size: clamp(1.4rem, 3.5vw, 3rem); font-weight: 700; margin: 3rem 0 0; }
.celebrate.show .celebrate-word { animation: slam .35s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes slam { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } }

@media (max-width: 900px) {
  body.screen { overflow: auto; }
  .screen-main { height: auto; }
  .screen-layout { grid-template-columns: 1fr; grid-template-rows: auto; }
  .board-xl { width: 100%; }
}

@media (max-width: 600px) {
  .topbar { padding: .7rem 1rem; }
  .big-code { font-size: 1.5rem; }
  .cell { padding: 4%; }
  .sample { transform: none; }
  .sample figcaption { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
