/* Grand format, fort contraste, gros boutons : pensé pour être confortable à tout âge. */
:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #5a5853;
  --line: #ddd7cb;
  --accent: #1f5fae;
  --accent-text: #ffffff;
  --felt: #1e6b45;
  --felt-dark: #17573a;
  --card: #ffffff;
  --red: #c4161c;
  --black: #1b1b1b;
  --good: #1d7a3e;
  --bad: #c4161c;
  --radius: 10px;
  --base: 19px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171816; --surface: #22231f; --text: #f1eee6; --muted: #b9b4a8; --line: #3a3b35;
    --accent: #5b9be6; --accent-text: #0e1a2a; --felt: #1a4d34; --felt-dark: #143d29;
  }
}
:root[data-theme="dark"] {
  --bg: #171816; --surface: #22231f; --text: #f1eee6; --muted: #b9b4a8; --line: #3a3b35;
  --accent: #5b9be6; --accent-text: #0e1a2a; --felt: #1a4d34; --felt-dark: #143d29;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--base)/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
img { max-width: 100%; }

.site-header {
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.site-header .in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.3rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.logo span { color: var(--accent); }
.site-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.site-nav a { text-decoration: none; color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 0.95rem; }
.site-nav a:hover, .site-nav a[aria-current] { background: var(--bg); }

main { max-width: 1180px; margin: 0 auto; padding: 12px 16px 40px; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 10px 0 4px; }
.lead { color: var(--muted); margin: 0 0 12px; }

/* Barre d'outils */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.btn {
  font: inherit; font-size: 1rem; font-weight: 600; min-height: 48px; padding: 8px 16px;
  border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.done { border-color: var(--good); color: var(--good); }
.btn .ico { font-size: 1.15em; line-height: 1; }
.tb-select { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1rem; }
.tb-select select {
  font: inherit; font-size: 1rem; min-height: 48px; padding: 6px 10px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
}
.game-status { color: var(--muted); font-size: 1rem; min-height: 1.6em; margin: 2px 0 6px; }

/* Table de cartes */
.card-board {
  position: relative; background: radial-gradient(ellipse at 50% 30%, var(--felt), var(--felt-dark));
  border-radius: 14px; touch-action: none; user-select: none; -webkit-user-select: none; min-height: 300px;
  overflow: hidden;
}
.slot {
  position: absolute; border: 2px dashed rgba(255,255,255,.35); border-radius: calc(var(--cw) * 0.08);
  display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.4);
  font-weight: 700; font-size: calc(var(--cw) * 0.4);
}
.slot-stock { border-style: solid; cursor: pointer; }
.slot-recycle::after { content: "↻"; color: rgba(255,255,255,.7); font-size: calc(var(--cw) * 0.6); }
.card {
  position: absolute; border-radius: calc(var(--cw) * 0.08); transition: left .18s ease, top .18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.35); cursor: pointer;
}
.card.up { background: var(--card); border: 1px solid #b9b4a8; }
.card.down {
  border: 1px solid #0d2c57;
  background: repeating-linear-gradient(45deg, #2a5ea8 0 6px, #2f68b8 6px 12px);
  box-shadow: inset 0 0 0 calc(var(--cw) * 0.05) #f5f1e6, 0 1px 2px rgba(0,0,0,.35);
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.c-rank { position: absolute; left: 6%; top: 1%; font-weight: 800; font-size: calc(var(--cw) * 0.36); line-height: 1; letter-spacing: -0.04em; }
.c-suit { position: absolute; right: 7%; top: 2%; font-size: calc(var(--cw) * 0.3); line-height: 1; }
.c-big { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: calc(var(--cw) * 0.62); line-height: 1; }
.card.dragging { transition: none; box-shadow: 0 8px 18px rgba(0,0,0,.45); }
.card.flash, .slot.flash { animation: flash 0.5s ease 3; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px #ffd54a, 0 0 18px #ffd54a; } }
.card.shake { animation: shake .3s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Fenêtres */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 16px; }
.modal { background: var(--surface); color: var(--text); border-radius: 16px; padding: 24px; max-width: 460px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 8px; font-size: 1.5rem; }
.modal-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s;
  background: #222; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 6000; font-size: 1rem; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Contenu éditorial */
.content { max-width: 760px; margin-top: 28px; }
.content h2 { font-size: 1.35rem; margin: 28px 0 8px; }
.content h3 { font-size: 1.1rem; margin: 20px 0 6px; }
.content li { margin: 4px 0; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.game-tile {
  display: block; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 16px;
  text-decoration: none; color: var(--text);
}
.game-tile:hover { border-color: var(--accent); }
.game-tile .t-ico { font-size: 2.2rem; line-height: 1; }
.game-tile strong { display: block; font-size: 1.15rem; margin: 8px 0 2px; }
.game-tile span { color: var(--muted); font-size: .95rem; }
.ad-slot { margin: 18px 0; min-height: 0; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .95rem; }
.site-footer .in { max-width: 1180px; margin: 0 auto; padding: 18px 16px; display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* Sudoku */
.sudoku-wrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.sudoku { display: grid; grid-template-columns: repeat(9, 1fr); width: min(100%, 560px); aspect-ratio: 1; border: 3px solid var(--text); background: var(--surface); user-select: none; touch-action: manipulation; }
.sudoku .cell {
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: clamp(20px, 5.4vw, 34px); font-weight: 600; cursor: pointer; position: relative; color: var(--accent);
}
.sudoku .cell.given { color: var(--text); font-weight: 800; }
.sudoku .cell.c3 { border-right: 2px solid var(--text); }
.sudoku .cell.r3 { border-bottom: 2px solid var(--text); }
.sudoku .cell.peer { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.sudoku .cell.same { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.sudoku .cell.sel { background: color-mix(in srgb, var(--accent) 35%, var(--surface)); }
.sudoku .cell.err { color: var(--bad); }
.sudoku .notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; font-size: clamp(9px, 1.8vw, 13px); color: var(--muted); font-weight: 500; }
.sudoku .notes span { display: flex; align-items: center; justify-content: center; }
.numpad { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; }
.numpad .btn { justify-content: center; font-size: 1.5rem; min-height: 60px; padding: 0; }
.numpad .btn.wide { grid-column: span 3; font-size: 1rem; }
.numpad .btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.numpad .btn .left { font-size: .7rem; color: var(--muted); margin-left: 2px; }
@media (max-width: 640px) { .numpad { grid-template-columns: repeat(5, 1fr); width: 100%; } .numpad .btn.wide { grid-column: span 5; } }

/* Mots mêlés */
.ws-wrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.ws-grid { display: grid; width: min(100%, 600px); aspect-ratio: 1; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 6px; touch-action: none; user-select: none; position: relative; }
.ws-grid .l { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: clamp(14px, 4vw, 28px); border-radius: 50%; cursor: pointer; text-transform: uppercase; position: relative; z-index: 1; }
.ws-grid .l.sel { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.ws-grid .l.start { outline: 3px solid var(--accent); }
.ws-grid svg { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); pointer-events: none; z-index: 0; }
.ws-words { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; font-size: 1.1rem; min-width: 260px; }
.ws-words li { padding: 3px 0; text-transform: uppercase; letter-spacing: .03em; }
.ws-words li.found { text-decoration: line-through; color: var(--muted); }

/* 2048 */
.g2048 {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 10px; width: min(100%, 480px); aspect-ratio: 1;
  background: #bbada0; padding: 10px; border-radius: 12px; touch-action: none; user-select: none;
}
.g2048 .tile {
  border-radius: 8px; background: rgba(238, 228, 218, .35); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: clamp(22px, 8vw, 44px); color: #776e65;
}
.g2048 .v2 { background: #eee4da; } .g2048 .v4 { background: #ede0c8; }
.g2048 .v8 { background: #f2b179; color: #fff; } .g2048 .v16 { background: #f59563; color: #fff; }
.g2048 .v32 { background: #f67c5f; color: #fff; } .g2048 .v64 { background: #f65e3b; color: #fff; }
.g2048 .v128, .g2048 .v256, .g2048 .v512 { background: #edcf72; color: #fff; font-size: clamp(20px, 7vw, 38px); }
.g2048 .v1024, .g2048 .v2048, .g2048 .v4096 { background: #edc22e; color: #fff; font-size: clamp(16px, 5.6vw, 32px); }
.g2048 .new { animation: appear .18s ease; } .g2048 .pop { animation: pop .18s ease; }
@keyframes appear { from { transform: scale(.4); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.12); } }

/* Démineur */
.mines { display: grid; gap: 2px; width: min(100%, calc(var(--cols) * 46px)); background: var(--line); padding: 2px; border-radius: 8px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.mines .m {
  aspect-ratio: 1; border: 0; border-radius: 3px; background: #9fb3c8; font: inherit; font-weight: 800;
  font-size: clamp(13px, 3.6vw, 22px); padding: 0; cursor: pointer; color: var(--text);
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.15), inset 2px 2px 0 rgba(255,255,255,.4);
}
.mines .m.open { background: var(--surface); box-shadow: none; cursor: default; }
.mines .m.flagged { color: var(--bad); }
.mines .m.mine { color: #111; } .mines .m.boom { background: var(--bad); color: #fff; }
.mines .n1 { color: #1f5fae; } .mines .n2 { color: #1d7a3e; } .mines .n3 { color: #c4161c; } .mines .n4 { color: #3a1f8f; }
.mines .n5 { color: #8a1c1c; } .mines .n6 { color: #0f7a7a; } .mines .n7 { color: #111; } .mines .n8 { color: #666; }

/* Mahjong */
.mj-board { position: relative; background: radial-gradient(ellipse at 50% 30%, var(--felt), var(--felt-dark)); border-radius: 14px; user-select: none; -webkit-user-select: none; }
.mj {
  position: absolute; background: linear-gradient(160deg, #fffdf6, #efe7d3); border: 1px solid #a89f88; border-radius: calc(var(--tw) * 0.12);
  box-shadow: 3px 3px 0 #c9bfa5, 4px 4px 0 #8f866e, 5px 6px 6px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; line-height: 1;
}
.mj b { font-size: calc(var(--tw) * 0.56); font-weight: 800; font-style: normal; }
.mj i { font-size: calc(var(--tw) * 0.24); font-style: normal; margin-top: 2px; }
.mj.t-c { color: #1f5fae; } .mj.t-b { color: #1d7a3e; } .mj.t-k { color: #b3121a; }
.mj.t-w { color: #222; } .mj.t-d { color: #b3121a; } .mj.t-f { color: #a0428a; } .mj.t-s { color: #b06a00; }
.mj.blocked { filter: brightness(.72) saturate(.7); cursor: default; }
.mj.sel { background: linear-gradient(160deg, #fff3b0, #ffe066); outline: 3px solid #e0a800; }

/* Reversi */
.rv-board { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; width: min(100%, 560px); background: #0b3d22; padding: 4px; border-radius: 10px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.rv-cell { aspect-ratio: 1; border: 0; padding: 0; border-radius: 3px; background: var(--felt, #1f7a45); cursor: default; display: flex; align-items: center; justify-content: center; position: relative; font: inherit; }
.rv-cell.legal { cursor: pointer; }
.rv-cell.legal::after { content: ''; width: 26%; height: 26%; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.rv-cell.legal:hover::after { background: rgba(255,255,255,.85); }
.rv-disc { width: 82%; height: 82%; border-radius: 50%; box-shadow: 0 3px 4px rgba(0,0,0,.45); animation: appear .2s ease; }
.rv-disc.black { background: radial-gradient(circle at 35% 30%, #555, #0a0a0a 70%); }
.rv-disc.white { background: radial-gradient(circle at 35% 30%, #fff, #d6d6d6 70%); }
.rv-disc.last { outline: 3px solid #ffd54a; outline-offset: 2px; }

/* Dames */
.dm-board { display: grid; grid-template-columns: repeat(10, 1fr); width: min(100%, 600px); border: 6px solid #5a3a1e; border-radius: 8px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.dm-sq { aspect-ratio: 1; border: 0; padding: 0; display: flex; align-items: center; justify-content: center; font: inherit; }
.dm-sq.light { background: #f0dcb4; }
.dm-sq.dark { background: #8b5a2b; cursor: default; }
.dm-sq.last { background: #a8743c; }
.dm-sq.movable { cursor: pointer; }
.dm-sq.movable .dm-pc { box-shadow: 0 0 0 3px #ffd54a, 0 3px 4px rgba(0,0,0,.45); }
.dm-sq.sel { background: #c9952e; }
.dm-sq.target { cursor: pointer; }
.dm-sq.target::after { content: ''; width: 32%; height: 32%; border-radius: 50%; background: rgba(255, 230, 120, .85); box-shadow: 0 0 0 2px rgba(0,0,0,.3); }
.dm-pc { width: 80%; height: 80%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: clamp(14px, 3.4vw, 30px); line-height: 1; box-shadow: 0 3px 4px rgba(0,0,0,.45); }
.dm-pc.w { background: radial-gradient(circle at 35% 30%, #fff, #e3d9c6 70%); color: #8b5a2b; border: 2px solid #cbbd9f; }
.dm-pc.b { background: radial-gradient(circle at 35% 30%, #555, #111 70%); color: #ffd54a; border: 2px solid #000; }
