/* Rommé – styles. Mobile-first, no external fonts/images. Same look as the other games of the portal. */
:root {
  --felt: #166534; --felt-dark: #14532d; --ink: #1f2937; --paper: #fafaf9;
  --accent: #f59e0b; --red: #c81e1e; --black: #111827; --muted: #6b7280;
  --gap: 10px; --radius: 7px;
  --avail: calc(min(100vw, 980px) - 20px - 2 * var(--gap));
  --cmax: 72px;                                       /* max card width in the hand */
  --mw: 30px;                                         /* mini cards (melds) */
  --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 { 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); }
@media (max-width: 420px) { .toolbar button { font-size: .78rem; padding: 4px 7px; } }

.opps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; height: 54px; }
.p { background: rgba(0,0,0,.18); border: 2px solid transparent; border-radius: 10px; padding: 3px 7px; font-size: .8rem; line-height: 1.3; min-width: 0; overflow: hidden; }
.p.is-turn { border-color: var(--accent); }
.p[hidden] { display: block; visibility: hidden; }
.p-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-row { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: center; white-space: nowrap; line-height: 1.25; }
.p-info { opacity: .9; font-size: .76rem; }
.p-badge { font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 0 5px; }
.p-badge.on { background: #fde047; color: #111; }

.piles { display: flex; align-items: center; gap: 10px; margin-top: 6px; height: 74px; }
.pile { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--radius); --cw: 48px; flex: 0 0 auto; }
.pile:disabled { cursor: default; }
.pile:not(:disabled) .card { box-shadow: 0 0 0 3px #fde047, 0 4px 10px rgba(0,0,0,.35); }
.pile-count { position: absolute; right: -6px; bottom: -4px; background: #111; color: #fff; font-size: .7rem; font-weight: 700; border-radius: 8px; padding: 0 5px; }
.pile-label { font-size: .7rem; text-align: center; opacity: .85; }
#round-info { flex: 1 1 auto; font-size: .82rem; opacity: .9; line-height: 1.3; min-width: 0; }

.melds { height: 196px; overflow-y: auto; overscroll-behavior: contain; margin-top: 6px; padding: 6px; border-radius: 12px; background: rgba(0,0,0,.14);
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px 10px; }
.melds-empty { margin: auto; opacity: .7; font-size: .85rem; text-align: center; }
.meld { display: inline-flex; padding: 3px 4px 3px 4px; border-radius: 8px; background: rgba(255,255,255,.08); border: 2px solid transparent; cursor: pointer; font: inherit; color: inherit; }
.meld .card.mini { --cw: var(--mw); }
.meld .card.mini + .card.mini { margin-left: calc(var(--mw) * -.38); }
.meld.target { border-color: #fde047; background: rgba(253,224,71,.18); }
.meld.staged { border: 2px dashed #fde047; cursor: default; }

.me { display: flex; align-items: center; gap: 8px; margin-top: 6px; height: 30px; }
#seat-0 { flex: 1 1 auto; display: flex; gap: 8px; align-items: center; height: 30px; padding: 2px 8px; }
#seat-0 .p-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 6px; height: 46px; }
.actions button { font: inherit; font-size: .8rem; font-weight: 700; line-height: 1.1; min-height: 46px; padding: 2px 4px; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #111; border: 1px solid var(--accent); overflow: hidden; hyphens: auto; }
.actions button.sec { background: rgba(0,0,0,.25); color: #fff; border-color: rgba(255,255,255,.35); }
.actions button:disabled { opacity: .45; cursor: not-allowed; }
.invisible { visibility: hidden; }
.status { height: 3em; overflow: hidden; margin: 6px 0; text-align: center; font-size: .9rem; line-height: 1.4; background: rgba(0,0,0,.2); border-radius: 8px; padding: 3px 8px; }

/* ---------------------------------------------------------------- hand --- */
.hand { --hmin: 7; --hrows: 2; --hcols: 7;
  --cwb: min(var(--cmax), calc((var(--avail) - (var(--hmin) - 1) * 5px) / var(--hmin)));
  --cw: min(var(--cmax), calc((var(--avail) - (var(--hcols) - 1) * 5px) / var(--hcols)));
  display: grid; grid-template-columns: repeat(var(--hcols), var(--cw)); gap: 8px 5px; justify-content: center; align-content: start;
  height: calc(var(--cwb) * 1.4 * var(--hrows) + 8px * (var(--hrows) - 1) + 12px); padding-top: 10px; }
.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.back { background: repeating-linear-gradient(45deg, #1e3a8a 0 4px, #1d4ed8 4px 8px); border: 2px solid #fff; }
.card.empty { background: rgba(255,255,255,.08); border: 2px dashed rgba(255,255,255,.4); box-shadow: none; }
button.card { cursor: pointer; }
.card.red { color: var(--red); }
.card.joker { color: #7c3aed; }
.c-corner { position: absolute; top: 3%; left: 7%; font-weight: 800; font-size: calc(var(--cw) * .34); line-height: .95; text-align: center; display: flex; flex-direction: column; align-items: 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: 34%; line-height: 1; }
.c-pip small { font-size: .32em; font-weight: 700; margin-top: 2px; }
.card.mini .c-pip { display: none; }
.card.mini .c-corner { font-size: calc(var(--cw) * .42); left: 5%; }
.hand .card.sel { transform: translateY(-9px); box-shadow: 0 0 0 4px var(--accent), 0 8px 14px rgba(0,0,0,.3); }
.hand .card.new { box-shadow: 0 0 0 3px #86efac, 0 4px 10px rgba(0,0,0,.3); }
.hand .card.new.sel { box-shadow: 0 0 0 4px var(--accent), 0 8px 14px rgba(0,0,0,.3); }
.hand .card.idle { cursor: default; }
button:focus-visible { outline: 3px solid #fde047; outline-offset: 2px; }

/* -------------------------------------------------------------- dialogs --- */
dialog { border: 0; border-radius: 14px; padding: 18px; max-width: min(560px, 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; margin: 0; }
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: 12px; }
.dlg-actions 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; }
.muted { color: var(--muted); font-size: .9rem; }
.hr-note { font-weight: 700; color: #b45309; }
.res, .score, .stats-table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.res th, .res td, .score th, .score td, .stats-table th, .stats-table td { border-bottom: 1px solid #e5e7eb; padding: 4px 5px; text-align: right; vertical-align: top; }
.res th:first-child, .res td.left, .stats-table th:first-child, .score th:first-child, .score td:first-child { text-align: left; }
.res tr.win th, .res tr.win td, .score td.win { color: #15803d; font-weight: 700; }
.cs { white-space: nowrap; font-weight: 700; }
.cs.red { color: var(--red); }
.score-wrap { max-height: 60vh; overflow: auto; }

/* -------------------------------------------------------------- content --- */
.content { background: #fff; border-radius: 14px; padding: 14px 18px; margin-top: 16px; }
.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; }
.example { background: #f0fdf4; border-left: 4px solid var(--felt); padding: 8px 12px; border-radius: 6px; }
.site-footer { text-align: center; font-size: .85rem; color: var(--muted); padding: 10px 10px 30px; }
.game:not(.ready) .opps, .game:not(.ready) .piles, .game:not(.ready) .melds, .game:not(.ready) .hand, .game:not(.ready) .me, .game:not(.ready) .actions { visibility: hidden; }

/* --------------------------------------------------------------- desktop --- */
@media (min-width: 900px) {
  :root { --mw: 40px; --cmax: 64px; }
  .hand { --hmin: 14; --hrows: 1; }
  .opps { height: 58px; }
  .p { font-size: .9rem; }
  .pile { --cw: 56px; }
  .piles { height: 84px; }
  .melds { height: 236px; }
  .actions { grid-template-columns: repeat(5, minmax(0, 160px)); justify-content: center; }
  .actions button { font-size: .92rem; }
  .status { font-size: 1rem; }
}

/* ------------------------------------------------- senior / large cards --- */
body.senior { font-size: 19px; }
body.senior .c-corner { font-size: calc(var(--cw) * .44); left: 6%; }
body.senior .card.mini .c-corner { font-size: calc(var(--cw) * .5); }
body.senior .card { border: 2px solid #000; }
body.senior .card.back { border-color: #fff; }
body.senior .card.red { color: #b00000; }
body.senior .game { background: #0b3d1f; }
body.senior .status { font-size: 1.02rem; background: #000; }
body.senior { --mw: 36px; }
@media (min-width: 900px) {
  body.senior { --mw: 48px; }
  body.senior .hand { --hmin: 7; --hrows: 2; --cmax: 88px; }
  body.senior .melds { height: 150px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.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; } }
#seat-0 .p-name { flex: 0 0 auto; }
@media (max-width: 420px) { .actions button { font-size: .72rem; padding: 2px 2px; } }

/* ---------------------------------------------------------- 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; } }
