:root { padding-top: env(safe-area-inset-top, 0px); }
/* Mise en page : plateau plein écran, barre de scores en haut, dock de la tuile en bas.
   Palette : ardoise verte (table), laiton (accent), pierre claire (texte). Thème sombre unique, voulu. */
:root {
  --table: #1b2427;
  --table-2: #26343a;
  --panel: #2c3b41;
  --panel-2: #354a51;
  --line: #44595f;
  --ink: #edf1e8;
  --muted: #a3b4b0;
  --brass: #e0b24a;
  --brass-ink: #2b2108;
  --danger: #d9705c;
  --display: 'IM Fell English SC', Georgia, 'Times New Roman', serif;
  --body: 'Alegreya Sans', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--table); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.35; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

#app { height: 100%; display: flex; flex-direction: column; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--table-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand h1 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; letter-spacing: .06em; margin: 0; color: var(--brass); }
.bar__meta { color: var(--muted); font-size: .9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar__meta b { color: var(--ink); font-weight: 700; }
.bar__btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; min-height: 40px; color: var(--ink); font-weight: 600; font-size: .92rem;
}
.ghost:hover { background: var(--panel); }

.scores {
  display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; background: var(--table);
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
.chip {
  flex: 1 0 128px; max-width: 220px; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  padding: 7px 12px; border-radius: 10px; background: var(--panel); border: 2px solid transparent;
}
.chip--cur { border-color: var(--brass); background: var(--panel-2); }
.chip__pawn { grid-row: span 2; width: 26px; height: 30px; }
.chip__name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__ai { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-left: 6px; font-weight: 600; }
.chip__score { grid-row: span 2; font-family: var(--display); font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.chip__dots { display: flex; gap: 3px; }
.chip__dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.chip__dots i.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }

.stage { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #2d3f45 0%, var(--table) 75%); }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; display: block; }
#board:active { cursor: grabbing; }
.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 8px); max-width: min(92%, 520px);
  background: rgba(20,28,30,.94); border: 1px solid var(--brass); border-radius: 10px; padding: 8px 14px;
  text-align: center; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast--on { opacity: 1; transform: translate(-50%, 0); }

.dock {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--table-2); border-top: 1px solid var(--line); flex-wrap: wrap;
}
.dock__tile { padding: 0; border: 2px solid var(--brass); border-radius: 8px; background: var(--panel); width: 68px; height: 68px; flex: none; overflow: hidden; }
.dock__tile canvas { width: 100%; height: 100%; display: block; }
.dock__tile:disabled { opacity: .45; border-color: var(--line); }
.dock__info { flex: 1 1 160px; min-width: 0; }
.dock__title { margin: 0; font-weight: 700; font-size: 1.05rem; }
.dock__hint { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.dock__actions { display: flex; gap: 8px; flex: 0 1 auto; }
.btn {
  min-height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 700;
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--gold { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.btn--gold:hover:not(:disabled) { background: #edc15f; }

.sheet {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10,16,18,.78); overflow-y: auto;
}
.sheet__panel {
  width: min(100%, 520px); max-height: 100%; overflow-y: auto; background: var(--table-2);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px 20px;
}
.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; letter-spacing: .05em; margin: 0 0 4px; color: var(--brass); }
.sheet p.lede { margin: 0 0 16px; color: var(--muted); }
.seats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.seat { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.seat svg { width: 26px; height: 30px; }
.seat input {
  min-width: 0; min-height: 44px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--table); color: var(--ink); padding: 0 12px; font: inherit; font-weight: 600;
}
.seat .toggle { min-height: 44px; min-width: 112px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.seat .toggle[data-ai="1"] { border-color: var(--brass); color: var(--brass); }
.sheet__row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.sheet__row .count { color: var(--muted); font-size: .92rem; }
.rules-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.rules-list b { color: var(--brass); }
.rank { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--panel); }
.rank li:first-child { border: 2px solid var(--brass); }
.rank .pos { font-family: var(--display); font-size: 1.3rem; color: var(--brass); }
.rank .pts { font-family: var(--display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.sheet__actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 520px) {
  .brand h1 { font-size: 1.25rem; }
  .bar__meta { display: none; }
  .dock { gap: 10px; }
  .dock__actions { width: 100%; }
  .dock__actions .btn { flex: 1; }
  .dock__hint { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
[hidden] { display: none !important; }
@media (max-width: 520px) { .bar { gap: 8px; } .bar__btns { flex-wrap: nowrap; } .ghost { padding: 0 9px; font-size: .86rem; } }
.tips {
  position: absolute; top: 10px; left: 12px; right: 12px; max-width: 440px; z-index: 3;
  background: rgba(28,40,44,.95); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px;
  font-size: .92rem; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.tips p { margin: 4px 0 0; }
.tips__head { display: flex; align-items: center; justify-content: space-between; }
.tips__head b { font-family: var(--display); font-weight: 400; letter-spacing: .06em; color: var(--brass); font-size: 1.05rem; }
.tips__x { width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.tips__move { color: #bfe6c2; font-weight: 600; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: .9rem; margin-top: 8px; }
#btnTips[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
@media (max-width: 520px) { .dock__actions { flex-wrap: wrap; } .dock__actions .btn { padding: 0 10px; } }

.foot { margin: 16px 0 0; color: var(--muted); font-size: .8rem; text-align: center; }
.screen { position: fixed; inset: 0; z-index: 12; background: var(--table); overflow-y: auto; padding: 0 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.screen__in { max-width: 560px; margin: 0 auto; padding-top: 14px; }
.screen__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.screen__head h2 { font-family: var(--display); font-weight: 400; letter-spacing: .05em; font-size: 1.6rem; margin: 0; color: var(--brass); }
.ct-muted { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.ct-intro { margin: 8px 0 14px; }
.ct-players { display: flex; flex-direction: column; gap: 8px; }
.ct-player { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 6px; background: var(--panel); border: 2px solid transparent; border-radius: 12px; padding: 4px 14px 4px 4px; }
.ct-player.is-sel { border-color: var(--brass); background: var(--panel-2); }
.ct-pick { width: 48px; height: 48px; border: 0; background: transparent; border-radius: 10px; display: grid; place-items: center; }
.ct-name { min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 700; font-size: 1.05rem; }
.ct-score { font-family: var(--display); font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ct-player.is-lead .ct-score { color: var(--brass); }
.ct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 14px; }
.ct-card { background: var(--table-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 16px; margin-bottom: 14px; }
.ct-card h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 400; letter-spacing: .05em; font-size: 1.2rem; color: var(--brass); }
.ct-row h3 { margin: 0; }
.ct-seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.ct-tab { flex: 1 1 auto; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; padding: 0 12px; }
.ct-tab.on { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.ct-step { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.ct-step__l { font-weight: 600; }
.ct-step__c { display: flex; align-items: center; gap: 12px; }
.ct-step output { min-width: 2.4ch; text-align: center; font-family: var(--display); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.ct-b { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 1.5rem; line-height: 1; }
.ct-b:active { background: var(--panel-2); }
.ct-sum { display: flex; align-items: baseline; justify-content: space-between; margin: 10px 0 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.ct-sum b { font-family: var(--display); font-size: 2.2rem; font-weight: 400; color: var(--brass); font-variant-numeric: tabular-nums; }
.ct-add { width: 100%; }
.ct-log { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ct-log li { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) auto auto; align-items: center; gap: 8px; background: var(--panel); border-radius: 10px; padding: 6px 6px 6px 10px; font-size: .92rem; }
.ct-log__p { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 700; }
.ct-log__n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-log__d { color: var(--muted); min-width: 0; }
.ct-log__pts { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.ct-x { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; border-radius: 8px; }
.ct-foot { display: flex; justify-content: center; padding: 6px 0 10px; }
@media (max-width: 420px) { .ct-log li { grid-template-columns: minmax(0, 5.5rem) minmax(0, 1fr) auto auto; font-size: .86rem; } }
.ct-row > span:last-child { flex: none; white-space: nowrap; }
.ct-seg .ct-tab { flex: 1 1 0; min-width: 0; padding: 0 6px; }
.ct-seg--2 .ct-tab { flex: 1 1 40%; }
