/* Design: monochromes "clinical blueprint on frosted paper" — nur zwei Radien
   (18px interaktiv, 24px Container), eine einzige Akzentfarbe (Ember-Rot). */

:root {
  --canvas: #f5f5f5;
  --paper: #ffffff;
  --surface-alt: #fafafa;
  --ink: #0a0a0a;
  --ink-soft: #171717;
  --mid: #737373;
  --hairline: #e5e5e5;
  /* --mid erreicht auf dem Canvas-Grau nur 4,34:1 — fuer Text darauf diese Stufe. */
  --mid-strong: #5c5c5c;
  --ember: #e7000b;

  --r-interactive: 18px;
  --r-container: 24px;

  --shadow-card: 0 0 0 1px rgba(10, 10, 10, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1),
    0 1px 2px -1px rgba(0, 0, 0, 0.1);

  --font: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.43;
  font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; }

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 245, 245, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
}

.wordmark {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.wordmark span { color: var(--mid-strong); font-weight: 400; }

.topbar .spacer { flex: 1; }

/* ---------- Bausteine ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-interactive);
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge.solid { background: var(--ink-soft); border-color: var(--ink-soft); color: #fff; }
.badge.ember { background: var(--ember); border-color: var(--ember); color: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-interactive);
  border: 1px solid transparent;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn:hover { background: var(--ink-soft); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn.ghost { background: var(--canvas); color: var(--ink); }
.btn.ghost:hover { background: var(--hairline); }

.btn.outline { background: transparent; border-color: var(--hairline); color: var(--ink); }
.btn.outline:hover { background: var(--surface-alt); }

.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--ink); }
.btn.ghost[disabled]:hover, .btn.outline[disabled]:hover { background: var(--canvas); }

.btn kbd {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.55;
}

.card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mid);
  margin-bottom: 12px;
}

/* ---------- Layout ---------- */

main { padding: 32px 0 64px; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

/* Schmale Geraete: die Kopfzeile traegt nur noch Wortmarke und die zwei Knoepfe.
   Der Trainer-Badge wiederholt nur, was die Seite ohnehin zeigt. */
.kurz { display: none; }

@media (max-width: 640px) {
  .topbar .badge { display: none; }
  .topbar-inner { gap: 8px; }
  .topbar-inner .btn { padding: 0 12px; }
  /* Kurzformen, sonst schiebt die Kopfzeile die Seite auf schmalen Displays breit. */
  .topbar-inner .lang { display: none; }
  .topbar-inner .kurz { display: inline; }
}

@media (max-width: 360px) {
  .topbar-inner .btn { padding: 0 10px; font-size: 13px; }
  .wordmark { font-size: 15px; }
}

/* ---------- Tisch ---------- */

.table { padding: 24px; }

.seat + .seat { margin-top: 24px; }

.seat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 22px;
}

.seat-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mid);
}

.hands { display: flex; flex-wrap: wrap; gap: 12px; }

.hand {
  border: 1px solid transparent;
  border-radius: var(--r-container);
  padding: 12px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.hand.active { border-color: var(--ink); background: var(--surface-alt); }
.hand.settled { background: var(--surface-alt); border-color: var(--hairline); }

.hand-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--mid);
}

.cards { display: flex; gap: 8px; min-height: 104px; }

.playing-card {
  width: 72px;
  height: 104px;
  flex: none;
  border-radius: var(--r-interactive);
  border: 1px solid var(--hairline);
  background: var(--paper);
  box-shadow: var(--shadow-card);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  animation: deal 0.18s ease-out;
}

.playing-card .suit { font-size: 20px; line-height: 1; align-self: flex-end; font-weight: 400; }
.playing-card.red { color: var(--ember); }

.playing-card.hole {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-alt),
    var(--surface-alt) 4px,
    var(--canvas) 4px,
    var(--canvas) 8px
  );
  color: transparent;
}

@keyframes deal {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.total {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- Aktionen ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

.bet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--mid);
}

.chip {
  height: 28px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: var(--r-interactive);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}

.chip[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Feedback ---------- */

.feedback {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  min-height: 76px;
}

.feedback .mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-interactive);
  display: grid;
  place-items: center;
  background: var(--canvas);
  font-size: 16px;
  font-weight: 600;
}

.feedback.ok .mark { background: var(--ink); color: #fff; }
.feedback.bad .mark { background: var(--ember); color: #fff; }
.feedback.bad { border-color: var(--ember); }

.feedback .headline { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.feedback .detail { color: var(--mid); margin-top: 4px; }

/* ---------- Statistik ---------- */

.stat-big {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.stat-sub { color: var(--mid); margin-top: 4px; }

.stat-list { margin-top: 20px; display: grid; gap: 8px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

.stat-row span:last-child { font-family: var(--mono); font-weight: 500; }

/* ---------- Schalter ---------- */

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
}

.switch + .switch { border-top: 1px solid var(--hairline); }

.switch .label { font-weight: 500; }
.switch .hint { color: var(--mid); font-size: 12px; margin-top: 2px; }

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.track {
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: var(--r-interactive);
  background: var(--hairline);
  position: relative;
  transition: background 0.12s ease;
}

.track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease;
}

.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Strategietabellen ---------- */

.charts { margin-top: 16px; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chart-scroll { overflow-x: auto; }

table.chart {
  border-collapse: separate;
  border-spacing: 2px;
  font-family: var(--mono);
  font-size: 11px;
}

table.chart th {
  color: var(--mid);
  font-weight: 500;
  padding: 2px 4px;
  text-align: center;
}

table.chart th[scope='row'] { text-align: right; padding-right: 6px; }

table.chart td {
  width: 22px;
  height: 22px;
  text-align: center;
  border-radius: 6px;
  background: var(--canvas);
  color: var(--mid);
  font-weight: 500;
}

table.chart td.a-S { background: var(--ink); color: #fff; }
table.chart td.a-H { background: var(--canvas); color: var(--ink-soft); }
table.chart td.a-D, table.chart td.a-V { background: var(--hairline); color: var(--ink); }
table.chart td.a-P { background: var(--surface-alt); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
table.chart td.here { outline: 2px solid var(--ember); outline-offset: 1px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  color: var(--mid);
  font-size: 12px;
}

footer {
  border-top: 1px solid var(--hairline);
  color: var(--mid-strong);
  font-size: 12px;
  padding: 20px 0 40px;
}

.rules { color: var(--mid); }
.rules li { margin-bottom: 4px; }
.rules ul { margin: 0; padding-left: 18px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.btn.suggested { outline: 2px dashed var(--mid); outline-offset: 3px; }
.chip[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ---------- Kartenzaehlen ---------- */

.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg .chip { flex: 1; height: 32px; font-family: var(--font); }

.quiz-row { display: flex; gap: 8px; margin-bottom: 8px; }

.quiz-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-interactive);
  border: 1px solid transparent;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
}

.quiz-row input:focus { outline: none; border-color: var(--ink); background: var(--paper); }
.quiz-row input[disabled] { opacity: 0.4; }

.hint.ok { color: var(--ink); font-weight: 500; }
.hint.bad { color: var(--ember); font-weight: 500; }

/* ---------- Handy ---------- */

.btn, .chip { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

@media (max-width: 640px) {
  /* Startwert fuer den Platz unter der festen Aktionsleiste; app.js misst die
     tatsaechliche Hoehe nach und setzt sie als padding-bottom. */
  body { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }

  .wrap { padding: 0 14px; }
  main { padding: 20px 0 32px; }
  .card { padding: 16px; }
  .table { padding: 16px; }
  .feedback { min-height: 0; }

  /* Kleinere Karten, damit auch fuenf nebeneinander passen. */
  .playing-card { width: 60px; height: 88px; font-size: 16px; padding: 6px; }
  .playing-card .suit { font-size: 16px; }
  .cards { min-height: 88px; gap: 6px; }

  /* Splits laufen seitlich weiter statt umzubrechen; app.js haelt die
     aktive Hand im Bild. */
  .hands { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .hand { padding: 8px; }
  .hand-meta { flex-wrap: wrap; row-gap: 4px; }

  /* Aktionen wandern in Daumenreichweite. */
  .actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--hairline);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .actions .btn { height: 46px; }
  .actions .btn[data-action='deal'] { grid-column: 1 / -1; }
  /* Waehrend der Runde ist "Geben" gesperrt — auf dem Handy nimmt es dann nur
     Daumenflaeche weg. Die vier Spielzuege bleiben immer stehen, damit die
     Leiste zwischen den Runden nicht springt. */
  .actions .btn[data-action='deal'][disabled] { display: none; }
  .btn kbd { display: none; }

  .bet-row { margin-top: 16px; flex-wrap: wrap; row-gap: 8px; }
  .chip { height: 36px; min-width: 48px; }
  .seg .chip { height: 40px; }

  /* Unter 16px zoomt iOS beim Fokus in das Feld hinein. */
  .quiz-row input { font-size: 16px; height: 40px; }
  #count-check { height: 40px; }
}
