/* ==========================================================================
   WMJ – Designsystem „Spieleabend“
   Filz-Verläufe, Karton & Papier. Gedeckte Druckfarben wie auf klassischen Spieleschachteln.
   ========================================================================== */
:root {
  /* Tisch & Materialien */
  --wood: #2a1e17;
  --wood-hi: #3a2a20;
  --paper: #f3ead8;
  --paper-2: #e8dcc4;
  --paper-3: #d9caae;
  --card: #fbf6ea;
  --ink: #2b231e;
  --ink-2: #5d5046;
  --ink-3: #8a7b6d;
  --line: rgba(43, 35, 30, .16);
  --line-2: rgba(43, 35, 30, .28);

  /* Auf dunklem Tisch */
  --on-wood: #f1e7d4;
  --on-wood-2: #e2d4bd;
  --on-wood-3: #c9b79d;
  --wood-line: rgba(241, 231, 212, .14);

  /* Druckfarben */
  --red: #c4472f;
  --red-d: #96331f;
  --mustard: #d9a23a;
  --turn-ring: #ffd447; /* Rahmen um den Spieler, der dran ist */
  --mustard-d: #a8781f;
  --teal: #2e7b77;
  --teal-d: #1f5a57;
  --navy: #2d3d63;
  --navy-d: #1e2a46;
  --plum: #6e3d5b;
  --olive: #6d7a3a;
  --rust: #b8693a;
  --slate: #5a6b7a;
  --felt: #24493a;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --text: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --hand: 'Caveat', 'Segoe Print', cursive;

  --r: 14px;
  --spring: cubic-bezier(.22, 1.4, .36, 1);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 2px 3px rgba(20, 12, 6, .25), 0 8px 18px -6px rgba(20, 12, 6, .45);
  --shadow-2: 0 2px 4px rgba(20, 12, 6, .3), 0 18px 40px -12px rgba(10, 6, 2, .6);

  /* Texturen (prozedurales SVG – keine externen Bilder) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .16 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --fibers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .6' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  --woodgrain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='640'%3E%3Cfilter id='w' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0025 .07' numOctaves='5' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 .36 .055 0 0 0 .24 .037 0 0 0 .16 .028 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E");
  --feltnoise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23t)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--wood); }
body {
  margin: 0; min-height: 100dvh; color: var(--on-wood);
  font-family: var(--text); font-size: 16px; line-height: 1.45; font-weight: 500;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  background: var(--wood);
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--mustard); color: var(--ink); }

/* ---------- Hintergrund: weicher Filz-Verlauf, je Spiel eigene Farbe ---------- */
body { --bg-hi: #5a3049; --bg-lo: #2c1724; }
body[data-bg="hitster"] { --bg-hi: #5a3049; --bg-lo: #2c1724; }
body[data-bg="skyjo"] { --bg-hi: #33465f; --bg-lo: #1a2536; }
body[data-bg="thegame"] { --bg-hi: #44342d; --bg-lo: #1c1715; }
body[data-bg="kniffel"] { --bg-hi: #2d5a48; --bg-lo: #13281f; }
body[data-bg="nochmal"] { --bg-hi: #31436b; --bg-lo: #151d33; }
body[data-bg="uno"] { --bg-hi: #612d2a; --bg-lo: #2a1211; }
body[data-bg="memory"] { --bg-hi: #2a4e62; --bg-lo: #11222d; }
body[data-bg="topten"] { --bg-hi: #5f3a2b; --bg-lo: #27160f; }
body[data-bg="minigolf"] { --bg-hi: #4a4f55; --bg-lo: #1b1d21; }
body[data-bg="race"] { --bg-hi: #4b525e; --bg-lo: #1a1d24; }
body[data-bg="poker"] { --bg-hi: #2b604a; --bg-lo: #0f271d; }
body[data-bg="roulette"] { --bg-hi: #5c2a33; --bg-lo: #240e13; }
body[data-bg="geo"] { --bg-hi: #2f4e63; --bg-lo: #132230; }
body[data-bg="safari"] { --bg-hi: #55482c; --bg-lo: #221c10; }
body[data-bg="skribbl"] { --bg-hi: #3d5560; --bg-lo: #172329; }
body[data-bg="codenames"] { --bg-hi: #3b4250; --bg-lo: #161a22; }
body[data-bg="gartic"] { --bg-hi: #5a3f5e; --bg-lo: #241826; }
body[data-bg="battleship"] { --bg-hi: #2e4560; --bg-lo: #0f1a29; }
.table-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: var(--bg-lo); }
.table-bg::before {
  content: ""; position: absolute; inset: 0;
  background: var(--feltnoise), radial-gradient(120% 90% at 50% 20%, var(--bg-hi), var(--bg-lo) 75%), var(--bg-lo);
  animation: bgIn .9s var(--ease);
}
.table-bg.swap::before { animation: bgIn2 .9s var(--ease); }
@keyframes bgIn { from { opacity: 0; } }
@keyframes bgIn2 { from { opacity: 0; } }
.table-bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(8, 4, 2, .5) 100%),
    linear-gradient(180deg, rgba(255, 230, 240, .04), transparent 30%);
}

/* ---------- Papier & Karton ---------- */
.paper {
  position: relative; color: var(--ink);
  background: var(--grain), var(--fibers), var(--paper);
  border-radius: var(--r); box-shadow: var(--shadow-1);
}
.paper.ruled::after {
  content: ""; position: absolute; inset: 6px; border: 1px solid var(--line); border-radius: calc(var(--r) - 5px); pointer-events: none;
}
.paper .muted, .muted-ink { color: var(--ink-2); }
.on-wood-muted { color: var(--on-wood-2); }

.eyebrow { font: 800 11px/1.2 var(--text); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.on-wood .eyebrow, .eyebrow.light { color: var(--on-wood-3); }
/* Text direkt auf dem Holztisch braucht etwas Halt */
.on-wood-text, .eyebrow.light, .back, #bTable, .home-note, .shelf-head, .box b, .box small, .pick b, .pick small, .lobby-foot, .start-zone .hint, .waiting.on-wood,
.sec-head.on-wood, .tl-game h2, .tl-game p, .tl-wait, .tl-p b, .gturn, .gtitle, .home-title, .nm-round, .nm-hint, .tt-note, .tt-round, .hs-msg, .lobby-head .eyebrow { text-shadow: var(--surface-shadow, 0 1px 2px rgba(10, 5, 2, .85), 0 0 12px rgba(10, 5, 2, .5)); }
.title { font-family: var(--display); font-weight: 700; font-variation-settings: "opsz" 72, "SOFT" 50; letter-spacing: -.01em; line-height: 1.05; }

/* ---------- Buttons: gedruckte Spielmarken ---------- */
.btn {
  --bg: var(--paper); --fg: var(--ink); --edge: var(--paper-3);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font: 700 16px/1.1 var(--text); letter-spacing: .01em; color: var(--fg);
  background: var(--grain), var(--bg); border: 0; border-radius: 12px; padding: 13px 18px;
  box-shadow: 0 3px 0 var(--edge), 0 6px 14px -4px rgba(10, 6, 2, .5), inset 0 1px 0 rgba(255, 255, 255, .35);
  cursor: pointer; text-decoration: none; user-select: none; transition: transform .12s var(--ease), box-shadow .12s, filter .2s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--edge), 0 2px 6px -2px rgba(10, 6, 2, .5), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.primary { --bg: var(--red); --fg: #fff6ea; --edge: var(--red-d); }
.btn.mustard { --bg: var(--mustard); --fg: #2b1d08; --edge: var(--mustard-d); }
.btn.teal { --bg: var(--teal); --fg: #f1fbf8; --edge: var(--teal-d); }
.btn.navy { --bg: var(--navy); --fg: #eef1fa; --edge: var(--navy-d); }
.btn.dark { --bg: #3b2d24; --fg: #f1e7d4; --edge: #1e1510; }
.btn.ghost { background: transparent; box-shadow: none; color: inherit; opacity: .8; padding: 10px 12px; }
.btn.ghost:hover { opacity: 1; filter: none; }
.btn.ghost:active { transform: none; }
.btn.small { font-size: 14px; padding: 9px 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; filter: grayscale(.4); }
.btn small { display: block; font: 600 11px var(--text); opacity: .8; }
.btn:has(small) { flex-direction: column; gap: 1px; }
.btn .ic { width: 18px; height: 18px; flex: none; }

.ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Holz-Buchstabensteine (Lobby-Code) ---------- */
.tiles { display: inline-flex; gap: 6px; }
.tile {
  position: relative; width: var(--t, 46px); height: calc(var(--t, 46px) * 1.08); display: grid; place-items: center;
  font: 800 calc(var(--t, 46px) * .58)/1 var(--display); font-variation-settings: "opsz" 40; color: #2c1d10;
  background: var(--grain), linear-gradient(160deg, #f1d9a8, #ddb97c 60%, #c99d5d);
  border-radius: calc(var(--t, 46px) * .14);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(120, 76, 30, .35), 0 3px 0 #8a5d2c, 0 8px 14px -4px rgba(0, 0, 0, .55);
  animation: tileIn .5s var(--spring) both;
}
.tile::after { content: attr(data-v); position: absolute; right: 12%; bottom: 7%; font: 800 calc(var(--t, 46px) * .17)/1 var(--text); color: rgba(44, 29, 16, .6); }
.tiles .tile:nth-child(2) { animation-delay: .06s; transform: rotate(1.5deg); }
.tiles .tile:nth-child(3) { animation-delay: .12s; transform: rotate(-1deg); }
.tiles .tile:nth-child(4) { animation-delay: .18s; transform: rotate(2deg); }
@keyframes tileIn { from { opacity: 0; transform: translateY(-18px) rotate(-8deg); } }

/* ---------- Spielfiguren / Avatare ---------- */
.av { position: relative; width: var(--s, 48px); height: var(--s, 48px); flex: none; }
.av .av-svg { width: 100%; height: 100%; overflow: visible; }
.av.token {
  border-radius: 50%; padding: calc(var(--s, 48px) * .08);
  background: var(--grain), radial-gradient(circle at 35% 30%, #fffaf0, #eadfc8 70%);
  box-shadow: 0 0 0 calc(var(--s, 48px) * .055) var(--c, var(--paper-3)), 0 2px 0 calc(var(--s, 48px) * .055) rgba(0, 0, 0, .25), 0 6px 12px -4px rgba(0, 0, 0, .5);
}
.av.bob .av-svg { animation: bob 3s ease-in-out infinite; }
.av.wiggle .av-svg { animation: wiggle .7s ease-in-out infinite; }
.av.off { filter: grayscale(.8) brightness(.85); opacity: .75; }
@keyframes bob { 50% { transform: translateY(-5%) rotate(-2deg); } }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

/* ---------- Stempel ---------- */
.stamp {
  display: inline-block; font: 800 12px/1 var(--text); letter-spacing: .14em; text-transform: uppercase; color: var(--red);
  border: 2px solid currentColor; border-radius: 6px; padding: 5px 8px 4px; transform: rotate(-6deg); opacity: .85;
  mask-image: var(--grain); -webkit-mask-image: none;
}

.pop-in { animation: popIn .4s var(--spring) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.85) translateY(10px); } }
.fade-up { animation: fadeUp .55s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
@keyframes fadeIn { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
