/* Doppelkopf – styles. Mobile-first, no external fonts/images. Same look as Schwimmen/Mühle. */
:root {
  --felt: #166534; --felt-dark: #14532d; --ink: #1f2937; --paper: #fafaf9;
  --accent: #f59e0b; --red: #c81e1e; --black: #111827; --muted: #6b7280;
  --gap: 10px; --radius: 8px;
  --hcols: 6;                                                     /* hand: cards per row on phones */
  --cw: calc((min(100vw, 980px) - 20px - 2 * var(--gap) - (var(--hcols) - 1) * 5px) / var(--hcols));
  --tw: clamp(42px, 12.5vw, 70px);                                /* card width in the trick */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: #f3f4f1; }
a { color: #166534; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.site-header { display: flex; align-items: baseline; gap: 10px; padding: 8px 14px; background: var(--felt-dark); color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.brand-sub { font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { max-width: 980px; margin: 0 auto; padding: 0 10px 24px; }
h1 { font-size: clamp(1.05rem, 4.2vw, 1.6rem); line-height: 1.25; margin: 10px 2px 8px; }

/* ---------------------------------------------------------------- table --- */
.game { position: relative; background: radial-gradient(ellipse at center, #1d7a42 0%, var(--felt) 55%, var(--felt-dark) 100%);
  color: #fff; border-radius: 16px; padding: 8px var(--gap) 10px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.toolbar { display: flex; flex-wrap: wrap; gap: 5px; }
.toolbar button, .actions button { font: inherit; font-size: .86rem; min-height: 36px; padding: 5px 9px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.18); color: #fff; cursor: pointer; }
.toolbar button[aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); }
.toolbar button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 420px) { .toolbar button { font-size: .78rem; padding: 4px 7px; } }
.info { display: flex; justify-content: space-between; gap: 8px; margin: 6px 2px 4px; font-size: .85rem; min-height: 1.4em; }
.info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#contract-info { font-weight: 700; }

.table { display: grid; grid-template-columns: 78px 1fr 78px; grid-template-rows: auto 1fr; gap: 6px; }
.p { background: rgba(0,0,0,.18); border: 2px solid transparent; border-radius: 10px; padding: 4px 6px; font-size: .8rem; line-height: 1.3; min-width: 0; }
.p.is-turn { border-color: var(--accent); }
.p-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-party { display: inline-block; min-width: 1.6em; padding: 0 5px; border-radius: 6px; font-weight: 700; font-size: .75rem; text-align: center; background: rgba(255,255,255,.18); }
.p-party.re { background: #fde047; color: #111; }
.p-party.kontra { background: #93c5fd; color: #111; }
.p-ann { font-weight: 700; color: #fde047; min-height: 1.3em; }
.p-info { opacity: .85; font-size: .74rem; }
#seat-2 { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; }
#seat-2 .p-ann { min-height: 0; }
#seat-1, #seat-3 { align-self: center; min-height: 92px; }
.trick { position: relative; height: calc(var(--tw) * 1.4 * 2 + 28px); min-height: 170px; border-radius: 12px; background: rgba(0,0,0,.12); cursor: default; }
.trick.pending { cursor: pointer; }
.slot { position: absolute; width: var(--tw); height: calc(var(--tw) * 1.4); }
.slot-0 { left: 50%; bottom: 4px; transform: translateX(-50%); }
.slot-2 { left: 50%; top: 4px; transform: translateX(-50%); }
.slot-1 { left: 6px; top: 50%; transform: translateY(-50%); }
.slot-3 { right: 6px; top: 50%; transform: translateY(-50%); }
.slot.winner .card { box-shadow: 0 0 0 4px var(--accent), 0 6px 14px rgba(0,0,0,.35); }
.me { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 44px; }
#seat-0 { flex: 1 1 auto; display: flex; gap: 8px; align-items: center; }
#seat-0 .p-ann { min-height: 0; }
.actions { display: flex; gap: 6px; flex: 0 0 auto; }
.actions button { font-weight: 700; background: var(--accent); color: #111; border-color: var(--accent); min-height: 44px; }
.actions button:disabled { opacity: .5; }
.invisible { visibility: hidden; }
.status { min-height: 2.9em; margin: 6px 0; text-align: center; font-size: .9rem; line-height: 1.4; background: rgba(0,0,0,.2); border-radius: 8px; padding: 4px 8px; }

/* ---------------------------------------------------------------- hand --- */
.hand { display: grid; grid-template-columns: repeat(var(--hcols), var(--cw)); gap: 6px 5px; justify-content: center;
  height: calc(var(--cw) * 1.4 * 2 + 14px); padding-top: 4px; align-content: start; }
.card { position: relative; display: inline-block; width: var(--cw); height: calc(var(--cw) * 1.4); flex: 0 0 auto;
  border-radius: var(--radius); background: var(--paper); color: var(--black); border: 1px solid #d6d3d1;
  box-shadow: 0 2px 6px rgba(0,0,0,.25); padding: 0; font: inherit; text-align: left; cursor: default;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s; }
.card.small { --cw: var(--tw); }
button.card { cursor: pointer; }
.card.red { color: var(--red); }
.c-corner { position: absolute; top: 4%; left: 8%; font-weight: 800; font-size: calc(var(--cw) * .27); line-height: .95; text-align: center; }
.c-pip { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(var(--cw) * .5); padding-top: 22%; line-height: 1; }
.c-pip b { font-size: .62em; margin-bottom: 2px; }
.card.trump::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: 5%; height: 5px; border-radius: 3px; background: #d97706; }
.card.legal { transform: translateY(-3px); box-shadow: 0 0 0 3px #86efac, 0 6px 12px rgba(0,0,0,.3); }
.card.illegal { opacity: .45; filter: grayscale(.35); }
.card.selected { transform: translateY(-6px); box-shadow: 0 0 0 4px var(--accent), 0 8px 14px rgba(0,0,0,.3); }
.card.flash { animation: flash .9s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 5px #fde047; } 100% { box-shadow: 0 0 0 3px #86efac; } }
button:focus-visible { outline: 3px solid #fde047; outline-offset: 2px; }

/* -------------------------------------------------------------- dialogs --- */
dialog { border: 0; border-radius: 14px; padding: 18px; max-width: min(520px, 94vw); width: 100%; color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
dialog label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0; }
dialog label.check { justify-content: flex-start; }
dialog select { font: inherit; padding: 4px 8px; min-height: 40px; max-width: 62%; }
dialog input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; }
dialog fieldset { border: 1px solid #e5e7eb; border-radius: 8px; margin: 10px 0; }
.act { font: inherit; font-weight: 700; min-height: 46px; border: 0; border-radius: 10px; background: var(--felt); color: #fff; cursor: pointer; padding: 8px 16px; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.dlg-actions button:not(.act), .reserve-btns button:not(.act) { font: inherit; min-height: 46px; padding: 8px 14px; border-radius: 10px; color: var(--ink); background: #f3f4f6; border: 1px solid #d1d5db; cursor: pointer; }
.reserve-btns { display: grid; gap: 8px; margin-top: 10px; }
.reserve-solo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reserve-solo select { flex: 1 1 160px; max-width: none; }
.muted { color: var(--muted); font-size: .9rem; }
.res-contract { font-weight: 700; margin: 0 0 6px; }
.res-items { list-style: none; padding: 0; margin: 8px 0; }
.res-items li { display: flex; justify-content: space-between; border-bottom: 1px solid #eee; padding: 3px 0; }
.res-points, .score, .stats-table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.res-points th, .res-points td, .score th, .score td, .stats-table th, .stats-table td { border-bottom: 1px solid #e5e7eb; padding: 4px 5px; text-align: right; }
.res-points td.pos, .score td.pos { color: #15803d; font-weight: 700; }
.res-points td.neg { color: #b91c1c; font-weight: 700; }
.score td small { display: block; color: var(--muted); font-size: .75rem; }
.score td.re { background: #fef9c3; }
.score .g-type, .score th:nth-child(2) { text-align: left; }
.score-wrap { max-height: 60vh; overflow: auto; }
.stats-table th:first-child { text-align: left; }
.last-row { display: flex; gap: 10px; flex-wrap: wrap; }
.last-card { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .85rem; --tw: 56px; }
.last-card.winner .card { box-shadow: 0 0 0 4px var(--accent); }

/* ------------------------------------------------------------- ad slots --- */
.ad-slot { display: block; width: 100%; margin: 16px auto; background: #ebebe6; border-radius: 8px; contain: strict; }
.ad-slot--game { height: 280px; max-width: 728px; }
.ad-slot--content { height: 280px; max-width: 336px; }
@media (min-width: 768px) { .ad-slot--game { height: 90px; } }

/* -------------------------------------------------------------- content --- */
.content { background: #fff; border-radius: 14px; padding: 14px 18px; margin-top: 4px; }
.content h2 { font-size: 1.3rem; margin: 22px 0 8px; color: var(--felt-dark); }
.content h3 { font-size: 1.05rem; margin: 16px 0 4px; }
.content li { margin: 6px 0; }
.content table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: 8px 0; }
.content th, .content td { border: 1px solid #e5e7eb; padding: 5px 8px; text-align: left; vertical-align: top; }
.content thead th { background: #f0fdf4; }
.table-wrap { overflow-x: auto; }
.lead { font-size: 1.02rem; }
.site-footer { text-align: center; font-size: .85rem; color: var(--muted); padding: 10px 10px 30px; }

/* --------------------------------------------------------------- desktop --- */
@media (min-width: 900px) {
  :root { --hcols: 12; --cw: 72px; --tw: 72px; }
  .table { grid-template-columns: 150px 1fr 150px; }
  #seat-1, #seat-3 { min-height: 110px; font-size: .9rem; }
  .trick { height: 250px; }
  .hand { height: calc(72px * 1.4 + 12px); }
  .status { font-size: 1rem; }
}

/* ------------------------------------------------- senior / large cards --- */
body.senior { font-size: 19px; --tw: clamp(48px, 14vw, 80px); }
/* phones: cards already fill the width (6 per row), so senior mode enlarges the indices instead of adding a third row below the fold */
body.senior .c-corner { font-size: calc(var(--cw) * .4); left: 7%; }
body.senior .c-pip { font-size: calc(var(--cw) * .6); padding-top: 40%; }
body.senior .c-pip b { display: none; }
body.senior .card { border: 2px solid #000; }
body.senior .card.red { color: #b00000; }
body.senior .game { background: #0b3d1f; }
body.senior .status { font-size: 1.05rem; background: #000; }
body.senior .p { font-size: .9rem; }
@media (min-width: 900px) { body.senior { --hcols: 6; --cw: 96px; --tw: 84px; } body.senior .hand { height: calc(96px * 1.4 * 2 + 14px); } body.senior .trick { height: 250px; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
/* Vorbehalt/Armut: dialog sits at the top so the hand stays visible below it */
#dlg-reserve, #dlg-poverty { position: absolute; z-index: 5; top: 104px; left: 8px; right: 8px; width: auto; margin: 0 auto; max-width: 480px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#dlg-reserve h2, #dlg-poverty h2 { font-size: 1.1rem; }
#dlg-reserve p { margin: 4px 0; }
@media (min-width: 900px) { #dlg-reserve, #dlg-poverty { top: 120px; } }
.p.is-dealer .p-name::after { content: " · " attr(data-d); font-weight: 400; font-size: .85em; opacity: .85; }
#seat-1 .p-name, #seat-3 .p-name { white-space: normal; }
#seat-0 .p-name { flex: 0 0 auto; overflow: visible; }
#seat-0 .p-info { white-space: nowrap; font-size: .8rem; }
.hand.many { height: auto; min-height: calc(var(--cw) * 1.4 * 2 + 14px); }
.actions .invisible { display: none; }
#seat-0 { overflow: hidden; }
#seat-0 .p-info { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------------------------------------------------------- language switch --- */
.site-header { display: flex; align-items: center; }
.site-header .brand-sub { flex: 1 1 auto; min-width: 0; }
.site-header .lang-switch { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.site-header .lang-switch a,
.site-header .lang-switch a:link,
.site-header .lang-switch a:visited {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  min-width: 52px; min-height: 44px; padding: 0 14px; border: 2px solid #ffffff; border-radius: 999px;
  background: transparent; color: #ffffff; font: 700 17px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: .04em; text-decoration: none;
}
.site-header .lang-switch a:hover { background: rgba(255,255,255,.18); color: #ffffff; text-decoration: none; }
.site-header .lang-switch a[aria-current="page"],
.site-header .lang-switch a[aria-current="page"]:link,
.site-header .lang-switch a[aria-current="page"]:visited,
.site-header .lang-switch a[aria-current="page"]:hover { background: #ffffff; color: #14532d; border-color: #ffffff; }
.site-header .lang-switch a:focus-visible { outline: 3px solid #fde047; outline-offset: 3px; }
@media (max-width: 400px) { .site-header .brand-sub { display: none; } }
