@font-face { font-family: 'Geist'; src: url('fonts/Geist-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #000;
  --surface: #0a0a0a;
  --raised: #111;
  --hover: #161616;
  --line: #1f1f1f;
  --line-strong: #2e2e2e;
  --text: #ededed;
  --muted: #8f8f8f;
  --faint: #5a5a5a;
  --red: #ef6461;
  --green: #45c98a;
  --p0: #e8a33d;
  --p1: #5b9cf6;
  --p2: #ef6461;
  --p3: #45c98a;
  --r: 12px;
  --r-sm: 8px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 14px; line-height: 1.5; letter-spacing: -0.006em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
::selection { background: #fff; color: #000; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono, .life, .pt, .cnt, #posInfo, .meta { font-variant-numeric: tabular-nums; }

/* Header */
.top { display: flex; align-items: center; gap: 28px; height: 56px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .82); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; color: var(--text); text-decoration: none; white-space: nowrap; }
nav { display: flex; gap: 2px; }
.nav { height: 32px; background: none; border: 0; padding: 0 10px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.nav.active { color: var(--text); }
.engine { margin-left: auto; color: var(--faint); font-size: 13px; }

.view { padding: 40px 24px; max-width: 1240px; margin: 0 auto; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -0.035em; font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 22px; letter-spacing: -0.025em; font-weight: 600; margin: 0 0 20px; }
.intro { margin-bottom: 32px; }
.intro p { color: var(--muted); max-width: 620px; margin: 0; font-size: 15px; }

/* Buttons */
button, .btn {
  height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  color: var(--text); font-size: 13.5px; font-weight: 500;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
button:active:not(:disabled), .btn:active { transform: scale(0.97); }
button:disabled { opacity: .4; cursor: default; }
.primary { background: var(--text); color: #000; border-color: var(--text); }
.ghost { background: transparent; }
button.icon { width: 34px; padding: 0; color: var(--muted); background: transparent; border-color: transparent; }
@media (hover: hover) and (pointer: fine) {
  .nav:hover { color: var(--text); }
  button:hover:not(:disabled), .btn:hover { border-color: #444; }
  .primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
  button.icon:hover { color: var(--text); background: var(--raised); border-color: transparent; }
  .tabs button:hover, .segmented button:hover { color: var(--text); }
}
input, select, textarea { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 12px; height: 36px; width: 100%; transition: border-color 150ms ease, box-shadow 150ms ease; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238f8f8f' fill='none' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
textarea { height: auto; min-height: 140px; padding: 10px 12px; resize: vertical; font-size: 12.5px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: #555; box-shadow: 0 0 0 3px rgba(255, 255, 255, .07); }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* Seats */
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.seat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.seat h3 { margin: 0 0 2px; font-size: 13px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.seat h3::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.tabs { display: flex; padding: 2px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); }
.tabs button { flex: 1; height: 28px; padding: 0 6px; border: 0; background: none; font-size: 13px; color: var(--muted); border-radius: 6px; }
.tabs button.active { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seat .row { display: flex; gap: 8px; }
.seat-body { display: flex; flex-direction: column; gap: 8px; }
.deck-summary { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 2px; font-size: 13px; line-height: 1.5; min-height: 70px; }
.deck-summary .dn { font-weight: 500; }
.deck-summary .cmd { color: var(--muted); }
.deck-summary .warn { color: var(--red); font-size: 12.5px; margin-top: 4px; }
.deck-summary .ok { color: var(--faint); font-size: 12.5px; margin-top: 4px; }
.deck-summary.empty { color: var(--faint); }
.deck-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.deck-actions .saved { color: var(--faint); font-size: 12.5px; }
button.mini { height: 28px; padding: 0 10px; font-size: 12.5px; }
.hint { color: var(--faint); font-size: 13px; line-height: 1.5; padding: 2px 0; }
.start-row { display: flex; gap: 12px; align-items: end; margin-top: 24px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12.5px; width: 150px; }
.start-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.start-actions .primary { padding: 0 18px; }
.job { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.job.error { border-color: rgba(239, 100, 97, .4); color: var(--red); }
.spinner { width: 14px; height: 14px; border: 1.5px solid var(--line-strong); border-top-color: var(--text); border-radius: 50%; animation: spin .6s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Replay list */
.replay-list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.replay-list > p { padding: 16px; margin: 0; }
.replay-item { padding: 14px 16px; display: flex; gap: 16px; align-items: center; cursor: pointer; border-top: 1px solid var(--line); transition: background-color 150ms ease; }
.replay-item:first-child { border-top: 0; }
.replay-item .players { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.replay-item .players span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted) !important; }
.replay-item .players span::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.replay-item .players span.win { color: var(--text) !important; font-weight: 500; }
.replay-item .players span.win::before { background: var(--text); }
.replay-item .meta { color: var(--faint); font-size: 12.5px; text-align: right; }
.replay-item .del { height: 28px; padding: 0 10px; font-size: 12.5px; color: var(--faint); border-color: transparent; background: transparent; }
@media (hover: hover) and (pointer: fine) {
  .replay-item:hover { background: var(--surface); }
  .replay-item .del:hover { color: var(--red); border-color: transparent; }
}

/* Replay controls */
#view-replay { max-width: none; padding: 16px 24px 24px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 10px; }
.controls .group { display: flex; gap: 2px; align-items: center; }
.controls .play { margin: 0 6px; min-width: 124px; }
.segmented { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.segmented button { height: 28px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-size: 12.5px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.segmented button.active { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.controls .info { gap: 12px; margin-left: auto; font-size: 13.5px; }
#turnInfo { font-weight: 500; }
#scrub { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; border: 0; padding: 0; margin: 0 0 14px; cursor: pointer; box-shadow: none; }
#scrub::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
#scrub::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -5px; border: 0; }
#scrub::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 0; }

/* Table layout */
.table { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.board.n2 { grid-template-columns: 1fr; }
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; max-height: calc(100vh - 88px); }
.panel { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface); }
.panel.grow { flex: 1; min-height: 200px; display: flex; flex-direction: column; padding-bottom: 6px; }
.panel h3 { margin: 0 0 10px; font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.panel .current + h3 { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.filter { display: flex; gap: 6px; align-items: center; font-size: 12.5px; cursor: pointer; color: var(--faint); font-weight: 400; }
.filter input { width: 13px; height: 13px; accent-color: #fff; }
.current { min-height: 64px; }
.current .phase { color: var(--faint); font-size: 12.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.current .desc { font-size: 15px; line-height: 1.45; letter-spacing: -0.012em; display: block; color: var(--muted); }
.stack { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); counter-reset: s; }
.stack:empty::before { content: 'Leer'; color: var(--faint); }
.stack li { padding: 3px 0; display: flex; gap: 8px; }
.stack li::before { counter-increment: s; content: counter(s); color: var(--faint); width: 12px; font-variant-numeric: tabular-nums; }
.stack li b { color: var(--text); font-weight: 500; }
.who { font-weight: 500; }
.current b, .history b { font-weight: 500; color: var(--text); }

/* Players: one lane per player (Spielfeld) */
.board.lanes { display: flex; flex-direction: column; gap: 8px; }
.lane { display: grid; grid-template-columns: 200px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; transition: border-color 200ms ease, opacity 300ms ease; }
.lane.active { border-color: #444; }
.lane.lost { opacity: .38; }
.lane .who { padding: 14px 16px 14px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; position: relative; min-width: 0; }
.lane .who::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 2px; border-radius: 0 2px 2px 0; background: var(--pc); }
.pname { font-weight: 500; font-size: 14px; letter-spacing: -0.015em; line-height: 1.3; }
.pcmd { color: var(--faint); font-size: 12px; line-height: 1.35; }
.lane .life { font-size: 40px; font-weight: 500; letter-spacing: -0.05em; line-height: 1; margin: 10px 0 8px; color: var(--text); }
.life.bump-down { animation: flash-red 700ms ease; }
.life.bump-up { animation: flash-green 700ms ease; }
@keyframes flash-red { 0%, 35% { color: var(--red); } }
@keyframes flash-green { 0%, 35% { color: var(--green); } }
.badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 0; }
.badge { font-size: 11.5px; height: 22px; padding: 0 8px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); display: inline-flex; align-items: center; white-space: nowrap; font-weight: 500; }
.badge.turn { color: var(--text); }
.badge.out { color: var(--red); border-color: rgba(239, 100, 97, .35); }
.badge.win { background: var(--text); color: #000; border-color: var(--text); }
.piles { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--faint); }
.piles span[title] { cursor: help; }
.piles b { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 2px; }

.lane-field { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.arts { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.art { width: 96px; border-radius: 8px; overflow: hidden; background: var(--raised); border: 1px solid var(--line); position: relative; cursor: default; transition: transform 200ms var(--ease-out), border-color 200ms ease, opacity 200ms ease; }
.art .img { height: 68px; background: #151515; display: grid; place-items: center; }
.art .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art .img span { font-size: 11px; color: var(--muted); padding: 0 6px; text-align: center; line-height: 1.25; }
.art .cap { font-size: 11px; padding: 4px 6px; display: flex; justify-content: space-between; gap: 4px; line-height: 1.35; }
.art .cap .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art .cap .st { color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.art .atk { font-size: 10.5px; color: var(--red); padding: 0 6px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art.tapped { transform: rotate(6deg) scale(0.94); opacity: .55; }
.art.attacking { border-color: var(--red); transform: translateY(-4px); }
.art.hl { border-color: #fff; opacity: 1; }
.art.token { border-style: dashed; border-color: var(--line-strong); }
.art.cmdr::after { content: 'C'; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 4px; background: var(--text); color: #000; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.art.inzone { opacity: .5; border-style: dashed; }
.art.inzone .cap { flex-direction: column; gap: 0; }
.art.inzone .cap .st::before { content: 'Kommandozone'; }
.empty { color: var(--faint); font-size: 12.5px; padding: 4px 2px; }

/* Land chips */
.cards { display: flex; flex-wrap: wrap; gap: 4px; }
.card {
  font-size: 12px; height: 24px; padding: 0 8px; border-radius: 99px; border: 1px solid var(--line);
  display: inline-flex; gap: 6px; align-items: center; cursor: default; max-width: 100%; color: var(--muted);
  transition: border-color 200ms ease, opacity 200ms ease;
}
.card .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.card .pt, .card .cnt { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.card.tapped { opacity: .45; }
.card.hl { border-color: #fff; color: var(--text); opacity: 1; }
.card.attacking { border-color: rgba(239, 100, 97, .45); }
.card .atk { color: var(--red); font-size: 11px; }

/* Event kind dots */
.k { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; display: inline-block; }
.k-cast, .k-activate { background: var(--p1); }
.k-attack, .k-damage, .k-lose, .k-poison { background: var(--red); }
.k-life { background: var(--green); }
.k-land { background: #6b6b6b; }
.k-turn { background: var(--text); }
.k-win { background: var(--p0); }

/* History */
.history { overflow-y: auto; flex: 1; font-size: 13px; margin: 0 -16px; padding: 0 8px 8px; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }
.history .th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 500; padding: 12px 8px 6px; display: flex; align-items: center; gap: 8px; }
.history .th::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.history .ev { padding: 5px 8px; border-radius: 6px; cursor: pointer; line-height: 1.45; display: flex; gap: 10px; align-items: baseline; color: var(--muted); transition: background-color 120ms ease, opacity 120ms ease; }
.history .ev .k { transform: translateY(-1px); }
.history .ev.cur { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 #fff; }
.history .ev.future { opacity: .35; }
@media (hover: hover) and (pointer: fine) { .history .ev:hover { background: var(--hover); } }

/* Chart */
.chart svg { width: 100%; height: 140px; display: block; cursor: pointer; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* Mana pips */
.pip { display: inline-block; width: 12px; height: 12px; border-radius: 50%; font-size: 8.5px; line-height: 12px; text-align: center; font-weight: 700; color: #000; background: #9a9a9a; margin-left: 1px; }
.pip.W { background: #efe8cf; } .pip.U { background: #9cc3e6; } .pip.B { background: #a89fa6; } .pip.R { background: #e59a83; } .pip.G { background: #94c3a0; }

/* Card preview */
.preview { position: fixed; z-index: 50; pointer-events: none; width: 244px; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-strong), 0 24px 48px rgba(0, 0, 0, .7); background: var(--raised); transition: opacity 125ms var(--ease-out), transform 125ms var(--ease-out); transform-origin: left center; }
.preview.hidden { display: block !important; opacity: 0; transform: scale(0.97); }
.preview img { width: 100%; display: block; aspect-ratio: 488 / 680; }

@media (max-width: 1100px) {
  .table { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .panel.grow { max-height: 440px; }
}
@media (max-width: 720px) {
  .lane { grid-template-columns: 1fr; }
  .lane .who { border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; }
  .lane .who .life { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  .lane .who .badges, .lane .who .piles { grid-column: 1 / -1; }
  .lane .who .badges:empty { display: none; }
  .piles { padding-top: 8px; }
  .art { width: 78px; }
  .art .img { height: 56px; }
  .view { padding: 24px 16px; }
  #view-replay { padding: 12px 16px 20px; }
  .top { padding: 0 16px; gap: 16px; }
  .engine { display: none; }
  .controls .info { margin-left: 0; width: 100%; order: -1; }
  .controls .play { min-width: 0; }
  .start-actions { margin-left: 0; width: 100%; }
  .start-actions .primary { flex: 1; }
  .field { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled), .btn:active { transform: none; }
  .preview, .preview.hidden { transform: none; }
  .art.tapped, .art.attacking { transform: none; }
}
