:root {
  color-scheme: light;
  --paper: #f8f5ec;
  --sheet: #fffdf6;
  --ink: #253e33;
  --green: #2f5842;
  --muted: #526456;
  --line: #d6d8c9;
  --serif: Georgia, "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
  font: 100%/1.45 "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button, select, summary, input[type=checkbox] { cursor: pointer; }
a { color: var(--green); }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #985116; outline-offset: 3px; }
h1, h2, p, dl, dd { margin: 0; }
h2 { font-family: var(--serif); font-weight: 500; line-height: 1.1; font-size: clamp(1.5rem, 2.5vw, 2rem); letter-spacing: -.035em; }
.table-heading, .progress-head, .result { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.primary { min-height: 45px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; border-radius: 9px; font-weight: 650; }
.primary { background: var(--green); border: 1px solid var(--green); color: white; }
.primary:hover { background: #214830; }
.primary span { font-size: 1.18em; }
.layout { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.paper { border: 1px solid var(--line); background: var(--sheet); border-radius: 17px; padding: clamp(16px, 2vw, 23px); }
.table { background: #f1f1e6; border-color: #ced4c3; }
.table-size { color: var(--muted); font-size: 1rem; white-space: nowrap; }
.deck { --gap: 8px; --card-limit: clamp(62px, calc((100vh - 292px) / var(--rows)), 147px); display: grid; grid-template-columns: repeat(var(--cols), minmax(0, var(--card-limit))); justify-content: center; gap: var(--gap); margin: 15px auto 0; }
.card { min-width: 0; position: relative; aspect-ratio: 1; background: #f8f5e6; border: 2px solid #f8f5e6; border-radius: 9px; padding: 0; box-shadow: 0 1px 3px #34463347; touch-action: manipulation; overflow: hidden; }
.card .back, .card .front { position: absolute; inset: 0; display: grid; border-radius: 6px; }
.back { background: #315b48 url(rub.svg) center / 100% 100% no-repeat; opacity: 1; }
.front { background: #fcf6e9; grid-template-rows: minmax(0, 1fr); opacity: 0; }
.card.open .front, .card.matched .front { opacity: 1; }
.card.open .back, .card.matched .back { opacity: 0; }
.card.matched { border-color: var(--pair-border); box-shadow: 0 0 0 1px var(--pair-border); }
.card.matched .front { grid-template-rows: minmax(0, 1fr) auto; }
.card[aria-disabled=true] { cursor: default; }
.table-button { display: inline-block; min-height: 44px; padding: 6px 13px; font-size: 1rem; font-weight: 650; color: var(--green); border: 1px solid #b9c7aa; border-radius: 8px; background: #edf1e2; }
.table-button:disabled { opacity: .6; cursor: default; }
.current-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#pair-hint { flex: 1 1 11rem; }
.clock-toggle { min-height: 44px; padding: 6px 12px; font-size: .95rem; font-weight: 600; color: var(--green); border: 1px solid var(--line); border-radius: 8px; background: var(--sheet); }
.clock-toggle:hover { background: #f2f4e8; }
.card.hinted { border-color: #d6931e; box-shadow: 0 0 0 3px #f4c652, 0 4px 12px #7c521055; }
.card.hinted::after {
  content: "★"; position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: #f5c84c; color: #3c2905; font: 700 14px/1 "Segoe UI", sans-serif;
  box-shadow: 0 1px 3px #281b0455; pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .card.hinted { animation: pexeso-hint 1.4s ease-in-out infinite alternate; }
  @keyframes pexeso-hint { to { box-shadow: 0 0 0 5px #f4c652, 0 4px 14px #7c521077; } }
}
.card.name-card { container-type: inline-size; }
.card.name-card .front { align-items: center; padding: .2rem; }
.card.name-card.matched .front { grid-template-rows: 1fr; background: var(--pair-bg); }
.card.name-card .name { color: #2f4838; font: 650 clamp(0.6875rem, calc(136cqi / var(--letters)), 1.625rem)/1.12 "Segoe UI", sans-serif; overflow-wrap: anywhere; }
.card.name-card .caption { display: none; }
.picture { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.picture img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.picture img.ready { opacity: 1; background: #fcf6e9; }
.picture .fallback { font: 500 clamp(1.25rem, 4.2vw, 3.375rem)/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
.picture .fallback.text-only { font: 650 clamp(0.6875rem, 1.7vw, 1.0625rem)/1.2 "Segoe UI", sans-serif; overflow-wrap: anywhere; padding: 3px; }
.caption { display: none; background: var(--pair-bg); color: #243a2e; padding: 3px 2px; font-weight: 700; font-size: clamp(0.6875rem, 1.15vw, 0.875rem); line-height: 1.15; overflow-wrap: anywhere; }
.matched .caption { display: block; }
.message { margin-top: 13px; color: var(--green); text-align: center; line-height: 1.35; font-weight: 600; }
aside { display: grid; gap: 16px; }
.progress-head strong { padding: 4px 11px; color: #345339; background: #e9efe1; border-radius: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
progress { appearance: none; display: block; width: 100%; height: 7px; background: #e6ebdd; border: 0; border-radius: 12px; color: #769765; overflow: hidden; margin: 14px 0 17px; }
progress::-webkit-progress-bar { background: #e6ebdd; }
progress::-webkit-progress-value { background: #769765; border-radius: 12px; }
progress::-moz-progress-bar { background: #769765; }
.numbers { display: grid; }
.round-numbers { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.round-numbers.no-clock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.numbers dt { font-size: 0.875rem; color: var(--muted); }
.numbers dd { font-size: 1.4375rem; line-height: 1.28; font-weight: 650; font-variant-numeric: tabular-nums; }
.totals { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 16px; }
.totals div { display: flex; flex-direction: column; align-items: start; justify-content: space-between; gap: 5px; padding: 10px 12px; background: #f2f3e9; border-radius: 8px; }
details { border-top: 1px solid var(--line); margin-top: 16px; }
summary { min-height: 43px; padding: 11px 0 0; font-weight: 650; }
#awards { list-style: none; padding: 0; margin: 7px 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
#awards li { border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; font-size: 0.875rem; }
#awards .earned { background: #f4e6bd; border-color: #d7bf82; }
.result { background: #e5eedb; border: 1px solid #b9c8af; border-radius: 14px; margin-bottom: 15px; padding: 17px 20px; }
.result p { margin-top: 5px; }
dialog label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; cursor: pointer; }
.check input { width: 21px; height: 21px; margin: 0; accent-color: var(--green); }
@media (hover:hover) {
  .card:not([aria-disabled=true]):hover { border-color: #ad9d73; }
}
@media (prefers-reduced-motion: no-preference) {
  .back, .front { transition: opacity .13s ease; }
}
@media (min-width: 721px) and (max-height: 830px) {
  .paper { padding: 16px 18px; }
  .deck { margin-top: 12px; }
}
@media (max-width: 720px) {
  .layout { display: flex; flex-direction: column; gap: 12px; }
  .table, aside { width: 100%; }
  .paper { padding: 12px; }
  .deck { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
  .card { border-radius: 6px; }
  .card .back, .card .front { border-radius: 4px; }
  .card .caption { line-height: 1.05; font-size: clamp(0.625rem, 2.95vw, 0.875rem); padding: 2px 1px; }
  .message { font-size: 0.9375rem; }
  aside { gap: 12px; }
  .result { align-items: start; flex-direction: column; }
}

/* Verzia 2.3: väčšie tlačidlá a čitateľnejšie drobné texty. */
summary { min-height: 44px; }
.numbers dt { font-size: 0.9375rem; }
.card.name-card .name { font-size: clamp(0.8125rem, calc(136cqi / var(--letters)), 1.75rem); }
@media (min-width: 721px) { .caption { font-size: clamp(0.75rem, 1.5vw, 1rem); } }
/* Tablet na výšku: karty na celú šírku, výsledky pod nimi vedľa seba. */
@media (min-width: 721px) and (orientation: portrait) {
  .layout { display: flex; flex-direction: column; gap: 12px; }
  .table, aside { width: 100%; }
  aside { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 12px; }
  .deck { --card-limit: clamp(62px, calc((100vh - 560px) / var(--rows)), 190px); }
  @supports (height: 1dvh) { .deck { --card-limit: clamp(62px, calc((100dvh - 560px) / var(--rows)), 190px); } }
}
/* Na malých kartách ostáva názov menší, aby sa zmestil celý. */
.card.name-card .name { font-size: clamp(max(0.6875rem, min(0.8125rem, 18cqi)), calc(136cqi / var(--letters)), min(1.75rem, 36cqi)); hyphens: auto; }
/* Úzky telefón s väčším písmom: karty s názvami v troch stĺpcoch, aby sa dlhé názvy neorezali. */
@media (max-width: 400px) {
  html:not([data-herna-velkost="normal"]) .deck:has(.name-card) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 721px) and (orientation: landscape) and (max-height: 700px) {
  .deck { --card-limit: clamp(62px, calc((100vh - 262px) / var(--rows)), 147px); }
}
