/* Layout : table de jeu plein écran — barre de laque en haut, tapis de jade dessous, plateau centré et mis à l'échelle */
:root {
  --lacquer: #150e0c; --lacquer-2: #241815; --line: #4a3329; --felt: #0f3d33; --felt-deep: #082820;
  --cinnabar: #cc4330; --brass: #cfa85c; --ivory: #f4ebd3; --mist: #a7bfb4;
  --f-display: 'Zen Antique', 'Palatino Linotype', Georgia, serif;
  --f-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'DM Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--felt-deep); color: var(--ivory); font-family: var(--f-body); font-size: 15px; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); padding-top: env(safe-area-inset-top, 0px); }
header { background: var(--lacquer); border-bottom: 2px solid var(--cinnabar); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 10px 16px; }
.home { color: var(--mist); text-decoration: none; font-size: 26px; line-height: 1; margin-right: -10px; }
.home:hover { color: var(--brass); }
h1 { font-family: var(--f-display); font-weight: 400; font-size: 28px; margin: 0; letter-spacing: .04em; line-height: 1; }
h1 span { color: var(--cinnabar); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.st { display: flex; flex-direction: column; }
.st small { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--mist); }
.st b { font-family: var(--f-mono); font-weight: 500; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.btn { background: var(--lacquer-2); border: 1px solid var(--line); padding: 6px 11px; border-radius: 3px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: var(--brass); }
.btn:focus-visible, .tile:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.red { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; font-weight: 700; }
kbd { font-family: var(--f-mono); font-size: 11px; color: var(--mist); border: 1px solid var(--line); border-radius: 2px; padding: 0 4px; }
#table { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, var(--felt) 0%, #0c3329 55%, var(--felt-deep) 100%); display: grid; place-items: center; padding-inline: 16px; }
#board { position: relative; }
.tile { position: absolute; padding: 0; border: 0; border-radius: var(--r); background: linear-gradient(150deg, #fffaf0 0%, var(--ivory) 45%, #e6dab9 100%); box-shadow: var(--edge); }
.tile .face { position: absolute; inset: 0; border-radius: var(--r); background-size: 100% 100%; background-repeat: no-repeat; pointer-events: none; }
.tile.blocked .face { opacity: .62; }
.tile.blocked { background: linear-gradient(150deg, #d9d1bb 0%, #cfc5aa 100%); }
.tile.sel { background: linear-gradient(150deg, #ffe9a8 0%, #f2c766 100%); }
.tile.hint { animation: hint .9s ease-in-out 3; }
@keyframes hint { 50% { background: #9fe0c3; } }
.tile.nope { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tile.leaving { animation: leave .24s ease-in forwards; pointer-events: none; }
@keyframes leave { to { opacity: 0; transform: translateY(-14px) scale(.9); } }
#toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--lacquer); border: 1px solid var(--brass); padding: 8px 14px; z-index: 99999; max-width: calc(100% - 32px); }
#msg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4, 16, 12, .62); z-index: 100000; padding: 16px; overflow-y: auto; }
.card { background: var(--lacquer); border: 1px solid var(--brass); border-top: 4px solid var(--cinnabar); padding: 24px 26px; max-width: 520px; width: 100%; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); position: relative; max-height: 100%; overflow-y: auto; }
.card h2 { font-family: var(--f-display); font-weight: 400; font-size: 30px; margin: 0 0 8px; color: var(--brass); text-wrap: balance; line-height: 1.15; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--mist); margin: 18px 0 8px; font-weight: 500; }
.card p { margin: 6px 0; line-height: 1.45; max-width: 60ch; }
.card .sub { color: var(--mist); font-size: 14px; }
.card .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0 0; }
.card dt { color: var(--mist); }
.card dd { margin: 0; font-family: var(--f-mono); }
.card input, .card select { background: var(--lacquer-2); border: 1px solid var(--line); padding: 6px 9px; }
.card input.num { font-family: var(--f-mono); width: 100px; }
.x { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 24px; color: var(--mist); }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; background: var(--lacquer-2); border: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 2px; border-radius: 3px; }
.choice:hover { border-color: var(--brass); }
.choice b { font-size: 16px; }
.choice span { color: var(--mist); font-size: 13px; }
.choice.daily { border-color: var(--cinnabar); }
.layouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.layouts label { border: 1px solid var(--line); padding: 8px; text-align: center; cursor: pointer; display: grid; gap: 6px; justify-items: center; background: var(--lacquer-2); font-size: 13px; }
.layouts label:has(input:checked) { border-color: var(--brass); color: var(--brass); }
.layouts input { position: absolute; opacity: 0; pointer-events: none; }
.layouts canvas { width: 100%; max-width: 110px; height: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 8px; color: var(--mist); }
.tab[aria-selected="true"] { color: var(--ivory); border-color: var(--cinnabar); }
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mist); font-weight: 500; }
td.n { font-family: var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { color: var(--brass); }
.err { color: #ff9b8a; }
@media (max-width: 720px) {
  h1 { font-size: 22px; }
  header { gap: 6px 14px; padding-block: 8px; }
  .tools { margin-left: 0; }
  .btn { padding: 5px 8px; font-size: 13px; }
  .btn kbd { display: none; }
  .card { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) { .tile.hint, .tile.nope, .tile.leaving { animation: none; } }
