/* Solitaire : salon de jeu, tapis bordeaux, cartes ivoire, filets laiton. */
:root {
  --felt: #4a1a20; --felt-deep: #33100f;
  --ink: #f4ecdc; --ink-dim: #d9c8ad;
  --brass: #d4ad5a; --brass-deep: #9c7a2f;
  --card: #fbf7ee; --card-edge: #d8cfbd; --red: #b0242c; --black: #1d1c22;
  --back-a: #6e1f28; --back-b: #8f2f37;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ui: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --cw: 60px; --ch: 84px; --r: 6px;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
body[data-felt="1"] { --felt: #2c3a42; --felt-deep: #1b252b; }
body[data-felt="2"] { --felt: #1f3b2c; --felt-deep: #132519; }
body[data-felt="3"] { --felt: #1d2033; --felt-deep: #111320; }
body[data-felt="4"] { --felt: #5e3420; --felt-deep: #3d2013; }
body[data-back="1"] { --back-a: #1f3354; --back-b: #2d4a75; }
body[data-back="2"] { --back-a: #4a5326; --back-b: #626d34; }
body[data-back="3"] { --back-a: #14161f; --back-b: #2a2e44; }
body[data-back="4"] { --back-a: #8b6a24; --back-b: #b58f3c; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--felt-deep);
  background-image: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt) 45%, var(--felt-deep) 100%);
  color: var(--ink); font-family: var(--ui); font-size: 17px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Barres */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; position: relative; z-index: 5; }
.bar.top { padding: calc(var(--st) + 4px) calc(var(--sr) + 10px) 4px calc(var(--sl) + 10px); height: calc(var(--st) + 52px); }
.bar.bottom { padding: 6px calc(var(--sr) + 10px) calc(var(--sb) + 6px) calc(var(--sl) + 10px); border-top: 1px solid rgba(212,173,90,.28); background: rgba(0,0,0,.18); }
.ib { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.ib svg, .tb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ib:hover, .tb:hover { color: var(--brass); }
#btnSound .mute { display: none; }
#btnSound[aria-pressed="true"] .wave { display: none; }
#btnSound[aria-pressed="true"] .mute { display: inline; }
.readout { display: flex; gap: clamp(14px, 5vw, 40px); margin: 0; }
.readout div { text-align: center; min-width: 52px; }
.readout dt { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }
.readout dd { margin: 0; font-family: var(--serif); font-size: 21px; font-variant-numeric: tabular-nums; font-weight: 600; }
.tb { flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--ink-dim); border-radius: 8px; }
.tb:disabled { opacity: .35; cursor: default; }
.tb[hidden] { display: none; }
.tb span { white-space: nowrap; }
.tb:not(:disabled):active { color: var(--brass); }
#btnFinish { color: var(--brass); }

/* Table */
#board { position: relative; z-index: 1; isolation: isolate; flex: 1; touch-action: none; overflow: hidden; }
.slot {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: var(--r);
  border: 1.5px solid rgba(212,173,90,.38); display: grid; place-items: center; padding: 0;
}
.slot svg { width: 42%; height: 42%; fill: rgba(212,173,90,.28); }
.slot .k { font-family: var(--serif); font-size: calc(var(--cw) * .42); color: rgba(212,173,90,.32); font-weight: 600; }
.slot.stock .loop { fill: none; stroke: rgba(212,173,90,.5); stroke-width: 6; }
.slot.target { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass) inset; }

.card { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); will-change: transform; transition: transform .2s cubic-bezier(.2,.7,.3,1); }
.card.drag { transition: none; }
.card.drag .flip { box-shadow: 0 10px 22px rgba(0,0,0,.45); }
.flip { position: absolute; inset: 0; border-radius: var(--r); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.card.down .face, .card:not(.down) .back { visibility: hidden; }
.face, .back { position: absolute; inset: 0; border-radius: var(--r); overflow: hidden; }
.face { background: var(--card); border: 1px solid var(--card-edge); color: var(--black); }
.card.red .face { color: var(--red); }
.back {
  border: 2px solid var(--card);
  background-color: var(--back-a);
  background-image:
    repeating-linear-gradient(45deg, transparent 0 5px, var(--back-b) 5px 6px),
    repeating-linear-gradient(-45deg, transparent 0 5px, var(--back-b) 5px 6px);
  box-shadow: inset 0 0 0 3px var(--back-a), inset 0 0 0 4px rgba(212,173,90,.7);
}
body[data-back="1"] .back { background-image: radial-gradient(var(--back-b) 22%, transparent 24%); background-size: 8px 8px; }
body[data-back="2"] .back { background-image: repeating-linear-gradient(90deg, transparent 0 4px, var(--back-b) 4px 6px); }
body[data-back="3"] .back { background-image: radial-gradient(circle at 50% 50%, var(--back-b) 0 30%, transparent 31%), radial-gradient(circle at 0 0, rgba(212,173,90,.5) 0 1px, transparent 2px); background-size: 100% 100%, 9px 9px; }
body[data-back="4"] .back { background-image: repeating-conic-gradient(var(--back-a) 0 25%, var(--back-b) 0 50%); background-size: 10px 10px; }

.idx { position: absolute; left: 6%; top: 3%; display: flex; flex-direction: column; align-items: center; line-height: 1; width: 34%; }
.idx b { font-family: var(--serif); font-weight: 700; font-size: calc(var(--cw) * .36); letter-spacing: -.04em; }
.idx svg { width: calc(var(--cw) * .24); height: calc(var(--cw) * .24); fill: currentColor; margin-top: 1px; }
.idx.br { left: auto; top: auto; right: 6%; bottom: 3%; transform: rotate(180deg); }
.pip { position: absolute; right: 8%; bottom: 8%; width: 52%; height: 52%; fill: currentColor; }
.court { position: absolute; right: 4%; bottom: 3%; width: 62%; height: 70%; }
.card.small .idx.br { display: none; }

.card.hint .flip, .slot.hint { box-shadow: 0 0 0 3px var(--brass), 0 0 14px rgba(212,173,90,.6); }
.card.shake { animation: shake .3s; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

/* Feuilles (menu, réglages, stats) */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(10,4,4,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-in {
  width: min(560px, 100%); max-height: calc(100% - var(--st) - 20px); overflow: auto;
  background: #f6f0e3; color: #2a1d1a; border-radius: 14px 14px 0 0; border-top: 3px solid var(--brass);
  padding: 8px calc(var(--sr) + 22px) calc(var(--sb) + 22px) calc(var(--sl) + 22px);
}
@media (min-width: 700px) and (min-height: 600px) { .sheet { align-items: center; } .sheet-in { border-radius: 14px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: #f6f0e3; padding-top: 8px; }
.sheet h2 { font-family: var(--serif); font-size: 28px; margin: 6px 0; font-weight: 600; }
.sheet h3 { font-family: var(--serif); font-size: 19px; margin: 22px 0 8px; font-weight: 600; }
.sheet p { line-height: 1.55; margin: 6px 0 12px; max-width: 60ch; }
.sheet .muted { color: #6b5a50; font-size: 15px; }
.menu-list { list-style: none; padding: 0; margin: 6px 0 0; }
.menu-list button { width: 100%; text-align: left; min-height: 52px; padding: 10px 2px; border-bottom: 1px solid #e0d4bd; font-size: 19px; font-family: var(--serif); display: flex; justify-content: space-between; align-items: center; }
.menu-list button:hover { color: #7a2028; }
.menu-list small { font-family: var(--ui); font-size: 14px; color: #7a6a5e; }
.menu-list .primary { color: #7a2028; font-weight: 600; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid #e0d4bd; }
.row > span { font-size: 16px; }
.seg { display: inline-flex; border: 1px solid #b9a88b; border-radius: 8px; overflow: hidden; flex: none; }
.seg button { min-height: 40px; min-width: 44px; padding: 0 12px; font-size: 15px; }
.seg button[aria-pressed="true"] { background: #7a2028; color: #fff8ec; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: #c9bba3; position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch[aria-checked="true"] { background: #7a2028; }
.switch[aria-checked="true"]::after { left: 23px; }
select { font: inherit; font-size: 16px; min-height: 44px; padding: 0 10px; border: 1px solid #b9a88b; border-radius: 8px; background: #fffaf0; color: inherit; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0 4px; }
.sw { width: 54px; height: 72px; border-radius: 6px; position: relative; border: 2px solid transparent; }
.sw[aria-pressed="true"] { border-color: #7a2028; box-shadow: 0 0 0 2px #f6f0e3 inset; }
.sw:disabled { opacity: .45; cursor: not-allowed; }
.sw:disabled::after { content: ""; position: absolute; inset: 0; background: center / 18px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2'%3E%3Crect x='5' y='11' width='14' height='10' rx='1'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }
.sw.felt { height: 54px; border-radius: 50%; }
.stats { display: grid; grid-template-columns: 1fr auto; margin: 4px 0; }
.stats dt, .stats dd { padding: 11px 0; border-bottom: 1px solid #e0d4bd; margin: 0; }
.stats dd { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.ach { list-style: none; padding: 0; margin: 0; }
.ach li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #e0d4bd; }
.ach .mark { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 1.5px solid #b9a88b; display: grid; place-items: center; }
.ach li.done .mark { background: #7a2028; border-color: #7a2028; }
.ach .mark svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.4; }
.ach b { font-family: var(--serif); font-size: 17px; display: block; }
.ach span { font-size: 14px; color: #6b5a50; }
.ach li:not(.done) b { color: #7a6a5e; }
.bar-prog { height: 6px; background: #e0d4bd; border-radius: 3px; overflow: hidden; margin: 4px 0 14px; }
.bar-prog i { display: block; height: 100%; background: #7a2028; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; min-height: 50px; border-radius: 8px; font-size: 17px; font-weight: 600; border: 1.5px solid #7a2028; color: #7a2028; }
.btn.main { background: #7a2028; color: #fff8ec; }
.tut-step { font-size: 13px; letter-spacing: .06em; color: #7a6a5e; }
.more-games { text-align: center; margin: 14px 0 0; }
.more-games button { min-height: 44px; padding: 8px 6px; font-size: 15px; color: #7a6a5e; text-decoration: underline; text-underline-offset: 3px; }
.win-score { font-family: var(--serif); font-size: 46px; font-weight: 600; margin: 4px 0; font-variant-numeric: tabular-nums; color: #7a2028; }

.toast { position: fixed; left: 50%; bottom: calc(var(--sb) + 84px); transform: translateX(-50%); z-index: 40; background: #f6f0e3; color: #2a1d1a; padding: 12px 18px; border-radius: 8px; border-left: 3px solid var(--brass); font-size: 15px; max-width: calc(100% - 32px); box-shadow: 0 6px 18px rgba(0,0,0,.35); }

/* Message de victoire posé sur la table */
.gold-line { position: absolute; left: 10%; right: 10%; height: 2px; background: var(--brass); transform-origin: left; animation: line 1.1s ease forwards; z-index: 900; }
@keyframes line { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .card, .flip { transition: none !important; }
  .gold-line { animation: none; }
}
@media (max-height: 460px) {
  .bar.top { height: calc(var(--st) + 44px); }
  .readout dd { font-size: 18px; }
  .tb span { display: none; }
  .tb { min-height: 44px; }
}

/* ---------- Jeux : FreeCell, Spider, Pyramide ---------- */
.bar.top { position: relative; }
.vgame { position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%); margin: 0; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); white-space: nowrap; pointer-events: none; }
.readout { margin-bottom: 8px; }
.slot.cell { border-style: dashed; background: rgba(0,0,0,.12); }
.slot.done { border-color: rgba(212,173,90,.22); }
.slot.done .k { font-size: calc(var(--cw) * .3); }
.card.sel .flip { box-shadow: 0 0 0 3px var(--brass), 0 6px 16px rgba(0,0,0,.45); transform: translateY(-4px); }
.flip { transition: transform .12s; }
.small-cards .idx { left: 4%; top: 2%; width: 40%; }
.small-cards .idx b { font-size: calc(var(--cw) * .4); }
.small-cards .idx svg { width: calc(var(--cw) * .28); height: calc(var(--cw) * .28); }
.small-cards .court { width: 70%; height: 62%; right: 2%; bottom: 2%; }
.small-cards .back { box-shadow: inset 0 0 0 2px var(--back-a), inset 0 0 0 3px rgba(212,173,90,.7); }
.tb { min-width: 0; }
.tb span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 400px) { .tb { font-size: 11px; } .bar.bottom { gap: 2px; padding-left: calc(var(--sl) + 4px); padding-right: calc(var(--sr) + 4px); } }

/* Choix du jeu */
.games { list-style: none; padding: 0; margin: 4px 0 0; }
.games button { width: 100%; display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px 4px; border-bottom: 1px solid #e0d4bd; }
.games button[aria-pressed="true"] { background: #efe4cf; border-radius: 8px; }
.games svg { width: 56px; height: 56px; flex: none; background: #4a1a20; border-radius: 10px; padding: 6px; fill: #fbf7ee; stroke: #d4ad5a; stroke-width: .6; }
.games svg .o { fill: none; stroke: #d4ad5a; stroke-dasharray: 2 1.5; }
.games b { font-family: var(--serif); font-size: 21px; display: block; color: #7a2028; }
.games span span { font-size: 15px; color: #4d3d35; display: block; line-height: 1.4; }
.games small { font-size: 13px; color: #7a6a5e; }
.seg.wide { display: flex; width: 100%; margin: 6px 0 10px; }
.seg.wide button { flex: 1; padding: 0 4px; font-size: 14px; }
.sheet h3.first { margin-top: 6px; }
.sheet .center { text-align: center; max-width: none; }
.sheet .small { font-size: 13px; }

/* En ligne */
.o-card { border: 1px solid #e0d4bd; border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: #fbf6ea; }
.o-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.o-card header b { font-family: var(--serif); font-size: 18px; }
.o-card header small { color: #7a6a5e; font-size: 13px; }
.o-card .btn { width: 100%; min-height: 44px; margin: 4px 0; }
.o-card p { margin: 4px 0; }
.mine { font-weight: 600; color: #7a2028; }
.lb { list-style: none; padding: 0; margin: 6px 0 0; counter-reset: none; }
.lb li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid #ece2cf; font-size: 15px; }
.lb li.me { font-weight: 700; color: #7a2028; }
.lb .n { width: 22px; text-align: right; color: #7a6a5e; font-variant-numeric: tabular-nums; }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .v { font-variant-numeric: tabular-nums; }
.av { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; vertical-align: middle; box-shadow: inset 0 0 0 1.5px rgba(212,173,90,.8); }
.av svg { width: 55%; height: 55%; fill: #fbf7ee; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { display: grid; place-items: center; min-height: 48px; border-radius: 10px; border: 2px solid transparent; }
.avatars button[aria-checked="true"] { border-color: #7a2028; background: #efe4cf; }
.avatars .av { width: 38px; height: 38px; }
.reacts, .o-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reacts button { border: 1px solid #b9a88b; border-radius: 16px; min-height: 36px; padding: 0 12px; font-size: 14px; }
.o-tools { justify-content: flex-end; }
.o-tools button { font-size: 13px; color: #7a6a5e; text-decoration: underline; text-underline-offset: 3px; min-height: 36px; padding: 0 6px; }
.verdict { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 2px 0; }
.verdict.me { color: #2f6b3a; } .verdict.opp { color: #7a2028; }
.react-in { font-style: italic; }
.o-err { color: #9b1c24; font-weight: 600; }
.o-code { background: #efe4cf; border-radius: 8px; padding: 10px 12px; }
.o-code b { font-size: 22px; letter-spacing: .12em; font-family: var(--serif); }
.week { font-weight: 600; }
.o-deals { list-style: none; padding: 0; margin: 0; }
.o-deals li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #e0d4bd; font-size: 15px; }
.o-deals .btn { flex: none; min-height: 40px; padding: 0 16px; }
.o-deals .mine { text-align: right; font-size: 14px; }
.join { display: flex; gap: 8px; }
.join .btn { flex: none; min-height: 44px; padding: 0 14px; }
.sheet input { font: inherit; font-size: 17px; min-height: 44px; padding: 0 10px; border: 1px solid #b9a88b; border-radius: 8px; background: #fffaf0; color: inherit; width: 9.5em; -webkit-user-select: text; user-select: text; }
#duelCode { text-transform: uppercase; letter-spacing: .1em; width: 7em; }
.blk { list-style: none; padding: 0; }
.blk li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.blk .btn { flex: none; min-height: 40px; padding: 0 14px; }
