* { box-sizing: border-box; }
:root { --red: #d62a2a; --ink: #1d2733; --muted: #6b7684; --bg: #f4f6f9; --card: #fff; --line: #e3e7ec; --gold: #e2a72e; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
a { color: var(--red); }
#app { max-width: 640px; margin: 0 auto; padding: 14px 12px 40px; }
#app.loading { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

header.top { text-align: center; padding: 6px 0 4px; }
header.top h1 { margin: 0; font-size: 30px; }
header.top h1::after { content: ""; display: block; width: 110px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--red) 0 18px, #fff 18px 36px); box-shadow: 0 0 0 1px var(--line); }
header.top p { margin: 10px auto 6px; max-width: 460px; color: var(--muted); }
.who { font-size: 14px; margin: 6px 0 14px; }

section { background: var(--card); border-radius: 14px; padding: 14px; margin: 14px 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
section h2 { font-size: 18px; margin: 0 0 8px; }

button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.big { background: var(--red); color: #fff; border: 0; border-radius: 26px; padding: 12px 30px; font-size: 17px; font-weight: 700; box-shadow: 0 3px 0 #8f1717; }
button.big:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f1717; }
button.mid, button.sm { background: var(--red); color: #fff; border: 0; border-radius: 20px; padding: 9px 18px; font-weight: 600; }
button.sm { padding: 6px 13px; font-size: 13px; }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.danger { color: var(--red); }
button.link { background: none; border: 0; color: var(--red); padding: 4px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; }
.list li + li { border-top: 1px solid var(--line); }
.list li[data-open] { cursor: pointer; }
.list li[data-open]:hover { background: #f7f8fa; }
.list li.turn { background: #fff4e0; }
.list li.empty { color: var(--muted); justify-content: center; text-align: center; font-size: 14px; }
.nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nm small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm a { color: inherit; text-decoration: none; font-weight: 600; }
.nm em { font-style: normal; color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 12px; background: #eef1f4; white-space: nowrap; }
.turn .badge { background: var(--red); color: #fff; }
.badge.win { background: #dff3e4; color: #1d7a3a; }
.badge.loss { background: #fbe3e3; color: #a02020; }
.av { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #d9dfe6; color: #445; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }

.tabs { display: flex; gap: 4px; background: #eef1f4; padding: 4px; border-radius: 18px; margin-bottom: 8px; }
.tabs button { flex: 1; border: 0; background: none; padding: 6px 8px; border-radius: 14px; font-size: 14px; color: var(--ink); }
.tabs button.active { background: #fff; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.board li:nth-child(odd) { background: #f7f8fa; }
.board li.me { background: #fff1d0; }
.board li.empty { justify-content: center; color: var(--muted); background: none; text-align: center; font-size: 14px; }
.board .rk { width: 24px; text-align: right; font-weight: 800; }
.board li:nth-child(1) .rk { color: var(--gold); }
.board li:nth-child(2) .rk { color: #9aa3ad; }
.board li:nth-child(3) .rk { color: #c07a43; }
.board .sc { font-weight: 800; font-size: 16px; }
.info { color: var(--ink); font-weight: 600; font-size: 14px; margin: 8px 0 0; text-align: center; }

.gamegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.gamecard { background: #fff; border-radius: 14px; padding: 14px; text-decoration: none; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.gamecard b { display: block; font-size: 17px; color: var(--red); margin-bottom: 4px; }
.gamecard span { font-size: 13px; color: var(--muted); }

/* Partie */
.matchview { max-width: 600px !important; }
.mbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mbar b { flex: 1; text-align: center; font-size: 17px; }
.pl { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 8px 10px; margin: 6px 0; border: 2px solid transparent; }
.pl.active { border-color: var(--red); }
.dot { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.3); }
.dot.s0 { background: #fff; } .dot.s1 { background: #222; }
.dot.g-viererkette.s0 { background: var(--red); } .dot.g-viererkette.s1 { background: #f5c518; }
.dot.g-rolandwende.s0, .dot.g-deichfuenf.s0 { background: #222; } .dot.g-rolandwende.s1, .dot.g-deichfuenf.s1 { background: #fff; }
.status { text-align: center; font-weight: 600; min-height: 22px; margin: 10px 0 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 8px; }
.actions p { width: 100%; text-align: center; margin: 0; }
.offer { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; background: #fff4e0; border-radius: 10px; padding: 8px; margin: 6px 0; font-size: 14px; }

#boardWrap { width: 100%; max-width: min(560px, 100%); margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(var(--c), 1fr); width: 100%; border-radius: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.cell { aspect-ratio: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.myturn .cell.tg, .myturn .cell.sel { cursor: pointer; }
.cell.tg::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(214,42,42,.55); pointer-events: none; }
.cell.sel { box-shadow: inset 0 0 0 3px var(--red); }

/* Königsduell */
.chess { border: 6px solid #6b4a2f; }
.chess .lt { background: #f0dfc4; } .chess .dk { background: #b5835a; }
.chess .last { background-image: linear-gradient(rgba(255,214,70,.45), rgba(255,214,70,.45)); }
.chess .check { background-image: radial-gradient(circle, rgba(214,42,42,.9) 0, rgba(214,42,42,.25) 60%, transparent 75%); }
.cp { font-size: min(9.5vw, 54px); line-height: 1; font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif; }
.cp.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 0 2px #000, 0 1px 2px rgba(0,0,0,.6); }
.cp.b { color: #1b1b1b; text-shadow: 0 0 1px rgba(255,255,255,.5); }
.chess .cell.tg::after { width: 26%; height: 26%; background: rgba(30,30,30,.35); }
.chess .cell.tg:has(.cp)::after { width: 88%; height: 88%; background: none; border: 4px solid rgba(30,30,30,.35); }
.cr, .cc { position: absolute; font-style: normal; font-size: 10px; opacity: .7; pointer-events: none; }
.cr { top: 2px; left: 3px; } .cc { bottom: 1px; right: 3px; }

/* Weserdame */
.dame { border: 6px solid #3a4a5e; }
.dame .lt { background: #e9e4d8; } .dame .dk { background: #4f7a63; }
.dame .last { box-shadow: inset 0 0 0 3px rgba(255,214,70,.8); }
.disc { width: 78%; height: 78%; border-radius: 50%; display: block; position: relative; }
.dame .disc.w { background: radial-gradient(circle at 35% 30%, #fff, #d9d4c7); box-shadow: 0 2px 0 #9b9586, inset 0 0 0 4px rgba(0,0,0,.06); }
.dame .disc.b { background: radial-gradient(circle at 35% 30%, #c0392b, #7b1d14); box-shadow: 0 2px 0 #4a0f0a, inset 0 0 0 4px rgba(0,0,0,.12); }
.disc.king::after { content: "\265B\FE0E"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: min(5vw, 28px); color: var(--gold); text-shadow: 0 1px 1px rgba(0,0,0,.6); }

/* Viererkette */
.vier { background: #1f5fa8; padding: 1.5%; gap: 0; border-radius: 14px; }
.vier .hole { aspect-ratio: 1; }
.vier .hole::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: #e9eef5; box-shadow: inset 0 3px 4px rgba(0,0,0,.25); }
.vier .disc { width: 82%; height: 82%; z-index: 1; }
.vier .disc.red { background: radial-gradient(circle at 35% 30%, #f05c5c, #b51e1e); }
.vier .disc.yel { background: radial-gradient(circle at 35% 30%, #ffe680, #e0a800); }
.vier .last .disc { box-shadow: 0 0 0 3px #fff; }
.vier .line .disc { box-shadow: 0 0 0 4px #fff, 0 0 12px 4px #fff; }
.vier .cell.tg::after { z-index: 2; background: rgba(255,255,255,.7); }

/* Rolandwende */
.wende { background: #1e6b45; gap: 1px; padding: 1px; border: 6px solid #3c2a1c; }
.wende .felt { background: #2a8a59; aspect-ratio: 1; }
.wende .disc { width: 80%; height: 80%; }
.wende .disc.b { background: radial-gradient(circle at 35% 30%, #555, #111); }
.wende .disc.w { background: radial-gradient(circle at 35% 30%, #fff, #cfcfcf); }
.wende .last .disc { box-shadow: 0 0 0 3px #ffd34d; }
.wende .cell.tg::after { width: 22%; height: 22%; background: rgba(0,0,0,.35); }

/* Fünf am Deich */
.fuenf { background: #e3bf7a; border-radius: 6px; padding: 2px; border: 5px solid #9b7337; }
.fuenf .x { aspect-ratio: 1; }
.fuenf .x::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #7a5a2a; }
.fuenf .x::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: #7a5a2a; }
.stone { width: 86%; height: 86%; border-radius: 50%; z-index: 1; }
.stone.b { background: radial-gradient(circle at 35% 30%, #555, #0d0d0d); }
.stone.w { background: radial-gradient(circle at 35% 30%, #fff, #cfcfcf); box-shadow: 0 0 0 1px #9a9a9a; }
.fuenf .last .stone { box-shadow: 0 0 0 2px var(--red); }
.fuenf .line .stone { box-shadow: 0 0 0 3px var(--red), 0 0 8px 2px var(--red); }
.fuenf .cell.tg::after { display: none; }
.fuenf.myturn .cell.tg:hover::after { display: block; content: ""; width: 70%; height: 70%; border-radius: 50%; background: rgba(0,0,0,.25); left: auto; top: auto; z-index: 2; }

/* Mühle am Wall */
.muehlewrap { width: 100%; }
svg.muehle { width: 100%; height: auto; display: block; user-select: none; touch-action: manipulation; }
svg.muehle .mb { fill: #d8b27a; stroke: #8d6332; stroke-width: 4; }
svg.muehle line { stroke: #4a3218; stroke-width: 4; stroke-linecap: round; }
svg.muehle .spot { fill: #4a3218; }
svg.muehle .hit { fill: transparent; }
svg.muehle .st.s0 { fill: #f7f3ea; stroke: #6f6655; stroke-width: 2.5; }
svg.muehle .st.s1 { fill: #222; stroke: #000; stroke-width: 2.5; }
svg.muehle .tg .hit { fill: rgba(214,42,42,.25); cursor: pointer; }
svg.muehle .tg .st { stroke: var(--red); stroke-width: 4; }
svg.muehle .sel .st { stroke: var(--red); stroke-width: 5; }
svg.muehle .last .st { stroke: #f0b400; stroke-width: 4; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.mbox { background: #fff; border-radius: 14px; padding: 18px; text-align: center; }
.promo { display: flex; gap: 8px; }
.promo button { background: #f0dfc4; border: 0; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; align-items: center; }
.promo .cp { font-size: 42px; }
.promo small { font-size: 12px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); background: #1d2733; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; z-index: 60; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.dot.g-weserdame.s1 { background: #a8291d; }
