:root {
  --bg: #f3efe6;
  --ink: #1d1b19;
  --muted: #6d675e;
  --panel: #fffdf8;
  --line: #d9d2c3;
  --radius: 14px;
  --accent: #2f7fd1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --ink: #f1ece1;
    --muted: #a39c8f;
    --panel: #26241f;
    --line: #3b382f;
    color-scheme: dark;
  }
}
body[data-game="qwirkle"]      { --accent: #e2412f; }
body[data-game="sevenwonders"] { --accent: #b08d57; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 1.5rem; padding: 1rem 1.25rem .5rem;
}
h1 { margin: 0; font-size: 1.5rem; display: flex; align-items: center; gap: .6rem; }
.tiles { display: inline-flex; gap: 4px; }
.tiles i { width: 14px; height: 14px; border-radius: 3px; display: block; }
.tiles i:nth-child(1) { background: #e2412f; } .tiles i:nth-child(2) { background: #f08a1c; }
.tiles i:nth-child(3) { background: #f2c318; } .tiles i:nth-child(4) { background: #2f9e5b; }
.tiles i:nth-child(5) { background: #2f7fd1; } .tiles i:nth-child(6) { background: #7b4bb5; }

.tabs { display: flex; gap: .4rem; }
.tabs a {
  padding: .5rem 1.1rem; border-radius: 10px 10px 0 0; text-decoration: none; color: var(--muted);
  font-weight: 700; border-bottom: 4px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); background: var(--panel); }

main { padding: 1rem 1.25rem 2rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, input { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 0; border-radius: 10px; padding: .6rem 1rem;
  background: var(--ink); color: var(--bg); font-weight: 700;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
button.small { padding: .3rem .7rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, .tabs a:focus-visible { outline: 3px solid #2f7fd1; outline-offset: 2px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 0 0 1rem; }
.toolbar form { margin: 0; }
.toolbar .count { color: var(--muted); }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; font-size: .9rem; margin: .5rem 0 0; }
.error { background: #fde2dd; color: #8a1c0e; padding: .6rem 1rem; border-radius: 10px; margin: 0 0 1rem; }
@media (prefers-color-scheme: dark) { .error { background: #4a1d16; color: #ffd3cb; } }

/* ---------- Qwirkle ---------- */
.q-choose { max-width: 36rem; margin: 3rem auto; text-align: center; }
.q-choose h2 { font-size: 1.6rem; margin: 0 0 1.5rem; }
.q-choose form { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.q-choose button { width: 4.5rem; height: 4.5rem; font-size: 1.9rem; border-radius: 12px; color: #fff; }

.q-board {
  display: grid; gap: .9rem; overflow-x: auto; padding-bottom: .5rem;
  grid-template-columns: repeat(var(--n), minmax(150px, 1fr));
}
.q-col {
  background: var(--panel); border: 1px solid var(--line); border-top: 8px solid var(--c);
  border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .6rem; min-width: 0;
}
.q-name {
  width: 100%; border: 0; border-bottom: 1px dashed var(--line); background: transparent;
  font-weight: 700; font-size: 1.05rem; padding: .15rem 0; text-align: center;
}
.q-total { text-align: center; font-size: 3.2rem; font-weight: 800; line-height: 1; color: var(--c); }
.q-col.lead .q-total::after { content: " ★"; font-size: 1.4rem; vertical-align: super; }
.q-entry { display: flex; flex-direction: column; gap: .45rem; margin: 0; }
.q-entry input[type=number] {
  width: 100%; text-align: center; font-size: 1.6rem; font-weight: 700; padding: .45rem;
  border: 2px solid var(--line); border-radius: 10px; background: var(--bg); -moz-appearance: textfield;
}
.q-entry input[type=number]::-webkit-outer-spin-button,
.q-entry input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.q-entry button.add { background: var(--c); color: #fff; }
.q-col.yellow .q-entry button.add { color: #1d1b19; }

.q-history { list-style: none; margin: .3rem 0 0; padding: 0; }
.q-history li { display: flex; justify-content: space-between; padding: .3rem .2rem; border-top: 1px solid var(--line); color: var(--muted); }
.q-history li:first-child { color: var(--ink); font-weight: 800; font-size: 1.15rem; }
.q-history .beurt { font-weight: 400; font-size: .9rem; align-self: center; }

/* ---------- 7 Wonders ---------- */
.w-scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.w-table { border-collapse: collapse; width: 100%; min-width: 760px; }
.w-table th {
  padding: .6rem .4rem; text-align: center; font-weight: 700; border-top: 6px solid var(--c, var(--line));
  background: var(--panel);
}
.w-table th.w-first, .w-table th.w-totalhead { border-top-color: var(--ink); }
.w-table td { padding: .35rem .3rem; border-top: 1px solid var(--line); text-align: center; }
.w-table .w-first { position: sticky; left: 0; background: var(--panel); text-align: left; min-width: 8.5rem; padding-left: .7rem; }
.w-table input {
  width: 100%; min-width: 3.6rem; padding: .4rem .3rem; text-align: center; font-weight: 600;
  border: 2px solid var(--line); border-radius: 8px; background: var(--bg); -moz-appearance: textfield;
}
.w-table input[type=number]::-webkit-outer-spin-button,
.w-table input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.w-table input.w-name { text-align: left; font-weight: 700; }
.w-total { font-size: 1.5rem; font-weight: 800; min-width: 4.5rem; }
tr.lead .w-total output::after { content: " ★"; font-size: 1rem; vertical-align: super; color: #b08d57; }
