:root {
  --bg: #121417;
  --panel: #1b1f24;
  --panel-2: #23282e;
  --line: #2e343b;
  --text: #f1ede6;
  --muted: #9a9fa6;
  --accent: #e2b45c;
  --accent-ink: #2a1f08;
  --danger: #e2675c;
  --light: #ece2d0;
  --dark: #a67c58;
  --last: rgba(236, 196, 84, .55);
  --sel: rgba(120, 190, 160, .65);
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Startseite */
.home { width: 100%; max-width: 520px; padding: 28px 18px 40px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 34px; letter-spacing: -.5px; margin: 8px 0 2px; }
.brand span { color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 28px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
label.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type=text] { width: 100%; height: 48px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); outline: none; font-size: 16px; }
input[type=text]:focus { border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 18px; }
.seg button { height: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 500; }
.seg button img { width: 30px; height: 30px; }
.seg button.on { border-color: var(--accent); background: #2a2519; }
.btn { height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 18px;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; }
.btn.small { height: 40px; font-size: 14px; padding: 0 14px; font-weight: 500; }
.btn.danger { color: var(--danger); }
.btn:active { transform: scale(.98); }
.list { display: flex; flex-direction: column; gap: 8px; }
.gamerow { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--panel-2);
  border: 1px solid transparent; text-align: left; width: 100%; }
.gamerow:hover { border-color: var(--line); }
.gamerow img { width: 34px; height: 34px; }
.gamerow .t { flex: 1; min-width: 0; }
.gamerow .t b { display: block; font-weight: 600; }
.gamerow .t small { color: var(--muted); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: #2f3640; color: var(--muted); white-space: nowrap; }
.pill.go { background: var(--accent); color: var(--accent-ink); }
.empty { color: var(--muted); font-size: 14px; margin: 0; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* Spielansicht */
.game { width: 100%; max-width: 560px; display: flex; flex-direction: column; flex: 1; padding: 6px 10px 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 10px; }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; }
.iconbtn svg { width: 20px; height: 20px; }
.title { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.player { display: flex; align-items: center; gap: 10px; padding: 10px 6px; min-height: 58px; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; }
.avatar img { width: 28px; height: 28px; }
.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caps { display: flex; align-items: center; height: 20px; }
.caps img { width: 18px; height: 18px; margin-right: -5px; }
.caps .adv { margin-left: 10px; font-size: 12px; color: var(--muted); }
.turnflag { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  opacity: 0; transition: opacity .2s; }
.turnflag.on { opacity: 1; }

.boardwrap { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.7); touch-action: none; user-select: none; -webkit-user-select: none; }
.board { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.l { background: var(--light); }
.sq.d { background: var(--dark); }
.sq.last::before, .sq.sel::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--last); }
.sq.sel::before { background: var(--sel); }
.sq.check { background: radial-gradient(circle, #ff5a4a 0%, rgba(230,60,50,.65) 40%, transparent 72%), var(--light); }
.sq.d.check { background: radial-gradient(circle, #ff5a4a 0%, rgba(230,60,50,.65) 40%, transparent 72%), var(--dark); }
.sq img { position: relative; width: 88%; height: 88%; pointer-events: none; transition: transform .12s; }
.sq.dot::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 30, 25, .28); }
.sq.ring::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(20, 30, 25, .28); }
.sq.lifted img { opacity: .3; }
.coord { position: absolute; font-size: 10px; font-weight: 700; pointer-events: none; }
.coord.f { right: 3px; bottom: 1px; }
.coord.r { left: 3px; top: 2px; }
.sq.l .coord { color: var(--dark); }
.sq.d .coord { color: var(--light); }
.ghost { position: fixed; pointer-events: none; z-index: 50; transform: translate(-50%, -60%); }
.overlay { position: absolute; inset: 0; background: rgba(12, 14, 17, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 5; }
.overlay .box { max-width: 300px; }
.overlay h3 { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; }
.overlay p { color: var(--muted); margin: 0 0 16px; }

.status { min-height: 22px; text-align: center; font-size: 14px; color: var(--muted); margin: 4px 0 6px; }
.status b { color: var(--text); }
.moves { display: flex; gap: 4px; overflow-x: auto; padding: 8px 2px; scrollbar-width: none; }
.moves::-webkit-scrollbar { display: none; }
.mv { flex: none; display: flex; align-items: center; gap: 2px; font-size: 14px; }
.mv i { color: var(--muted); font-style: normal; margin: 0 2px 0 6px; }
.mv button { border: 0; background: none; padding: 5px 7px; border-radius: 7px; }
.mv button.cur { background: var(--panel-2); color: var(--accent); font-weight: 600; }
.nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.nav button { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
.nav button svg { width: 18px; height: 18px; }
.nav button:disabled { opacity: .35; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.banner .grow { flex: 1; }

/* Blätter */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--panel); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 22px; }
.sheet .stack { display: flex; flex-direction: column; gap: 8px; }
.sheet .stack .btn { width: 100%; justify-content: flex-start; }
.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo button { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--light); }
.promo img { width: 80%; }
.linkbox { display: flex; gap: 8px; margin: 10px 0; }
.linkbox input { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 500; z-index: 60;
  animation: up .18s ease-out; }
@media (min-height: 860px) { .game { justify-content: center; } }
