/* Knoflíková dáma — MojeGalanterka.cz
 * Barevné motivy: světlý (výchozí), denim, levandule, tmavý.
 * Přepínají se atributem <html data-theme="…">. */
:root {
  --bg: #f1f2ec;                 /* lněné plátno s chladným nádechem */
  --ink: #33403c;
  --card: rgba(253, 253, 249, 0.94);
  --topbar1: rgba(45, 95, 90, 0.97);   /* petrolejová */
  --topbar2: rgba(33, 74, 70, 0.95);
  --topbar-ink: #eef7f4;
  --accent: #2d5f5a;             /* petrolej — hlavní akce */
  --accent-dark: #214a46;
  --coral: #e07856;              /* korálová nit — zvýraznění */
  --coral-dark: #c25c3d;
  --gold: #e3b23c;
  --shadow: 0 8px 26px rgba(40, 60, 55, 0.22);
  --promo1: #e9f2ef;
  --promo2: #fbeee7;
}
html[data-theme="denim"] {
  --bg: #e9edf3;
  --ink: #2e3a4a;
  --card: rgba(250, 251, 253, 0.94);
  --topbar1: rgba(51, 80, 110, 0.97);
  --topbar2: rgba(38, 61, 86, 0.95);
  --topbar-ink: #edf3fa;
  --accent: #3c6493;
  --accent-dark: #2c4c72;
  --coral: #d9814f;
  --coral-dark: #b8663a;
  --shadow: 0 8px 26px rgba(35, 55, 80, 0.24);
  --promo1: #e8eef6;
  --promo2: #f8ede4;
}
html[data-theme="tmava"] {
  --bg: #23211d;
  --ink: #e8e2d6;
  --card: rgba(46, 43, 38, 0.96);
  --topbar1: rgba(26, 24, 21, 0.97);
  --topbar2: rgba(18, 17, 15, 0.95);
  --topbar-ink: #efe8da;
  --accent: #c99b3f;
  --accent-dark: #a67d2c;
  --coral: #d98a5a;
  --coral-dark: #b86e40;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  --promo1: #37332c;
  --promo2: #3d352c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  transition: background 0.3s;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: manipulation;
  cursor: pointer;
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

/* ---------- Horní lišta ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, var(--topbar1), var(--topbar2));
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
  color: var(--topbar-ink);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 1.5px;
  font-weight: 800;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.brand .vs {
  font-size: 0.85rem;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand .vs b.you { color: #ffd9a8; }
.brand .vs b.foe { color: #b8d8f2; }
.brand a, .shop-top { color: #ffe1b8; text-decoration: none; font-weight: 700; font-size: 0.88rem; white-space: nowrap; }
.brand a:hover, .shop-top:hover { text-decoration: underline; }
.shop-top { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.shop-link { cursor: pointer; }
.end-promo, .sheet-promo {
  display: block;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--promo1), var(--promo2));
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.5;
}
.sheet-promo { text-align: center; margin-top: 14px; }
.end-promo b, .sheet-promo b { color: var(--coral-dark); }
.end-promo:hover, .sheet-promo:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18); }

.clocks { display: flex; gap: 6px; flex-shrink: 0; }
.clock-chip {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.clock-chip.active { background: rgba(255, 255, 255, 0.3); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35) inset; }

/* ---------- Stavový štítek ---------- */
.status-chip {
  position: fixed;
  z-index: 15;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 7px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  max-width: calc(100vw - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.25s;
}
.status-chip.alert { background: var(--coral); color: #fff; }

/* ---------- Spodní lišta nástrojů ---------- */
#toolbar {
  position: fixed;
  z-index: 20;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 8px;
  background: var(--card);
  padding: 8px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 16px);
}
#toolbar button {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 58px;
  padding: 8px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
#toolbar button i { font-size: 1.05rem; color: var(--accent); }
#toolbar button:hover { background: rgba(0, 0, 0, 0.06); }
html[data-theme="tmava"] #toolbar button:hover { background: rgba(255, 255, 255, 0.08); }
#toolbar button:active { transform: scale(0.94); }
#toolbar button:disabled { opacity: 0.4; cursor: default; transform: none; }
#toolbar button:focus-visible, .install-btn:focus-visible, #sheet button:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}

.icon-badge { position: relative; display: inline-block; }
.icon-badge .badge {
  position: absolute;
  top: -7px; right: -12px;
  background: var(--coral);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 5px;
}

/* ---------- Panel Menu (bottom sheet, vycentrovaný jako u Pišklubky) ---------- */
#sheet {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(94vw, 440px);
  max-height: 78vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  transition: transform 0.3s cubic-bezier(0.4, 1.1, 0.5, 1);
}
#sheet.open { transform: translate(-50%, 0); }
#sheet h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#sheet h2 button, #rulesModal h2 button {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 8px;
}
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(125, 125, 125, 0.3);
  font-size: 1rem;
}
.sheet-row:last-of-type { border-bottom: none; }
.sheet-row.sheet-col { flex-direction: column; align-items: flex-start; gap: 8px; }
.sheet-row label { font-weight: 600; }
.sheet-row select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(125, 125, 125, 0.4);
  background: var(--card);
  color: var(--ink);
}
.sheet-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.sheet-subhead {
  padding-top: 14px; padding-bottom: 2px; border-bottom: none;
  font-weight: 700;
  opacity: 0.5;
}
.sheet-stats { display: flex; gap: 12px; }
.sheet-help { font-size: 0.9rem; opacity: 0.85; line-height: 1.5; margin-top: 10px; }
.sheet-help p { margin: 5px 0; }
.sheet-help i { color: var(--accent); width: 18px; text-align: center; }

.install-btn, .rules-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 7px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
}
.install-btn:active, .rules-btn:active { transform: scale(0.96); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.25), inset 0 3px 5px rgba(255, 255, 255, 0.35);
}
.swatch.sel { border-color: var(--gold); transform: scale(1.12); }

/* ---------- Modaly (konec partie, pravidla) ---------- */
#endModal, #rulesModal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 25, 0.5);
  padding: 16px;
}
#endModal.visible, #rulesModal.open { display: flex; }
.end-box, .rules-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
  width: 100%;
  text-align: center;
  animation: pop 0.3s ease;
}
/* Modál konce partie je užší než pravidla — viz pokyny, Část F. */
.end-box { max-width: min(90vw, 400px); width: 100%; }
.rules-box { max-width: min(92vw, 430px); }
.rules-box {
  text-align: left;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.end-box h2 { margin: 0 0 6px; font-size: 1.5rem; }
.end-box p { margin: 0 0 16px; opacity: 0.85; }
.end-box .btns { display: flex; gap: 10px; justify-content: center; margin-bottom: 1rem; }
.end-box .btns button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
	flex: 1;
}

#endNew { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
#endClose { background: rgba(125, 125, 125, 0.18); color: var(--ink); }
#endShare { background: rgba(125, 125, 125, 0.18); color: var(--ink); width: 100%; }

#rulesModal h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rules-box h3 { font-size: 0.98rem; margin: 14px 0 4px; color: var(--accent-dark); }
html[data-theme="tmava"] .rules-box h3 { color: var(--accent); }
.rules-box p, .rules-box li { font-size: 0.9rem; line-height: 1.55; margin: 4px 0; }
.rules-box ul { margin: 4px 0; padding-left: 20px; }
.rules-box .rule-note {
  background: var(--promo2);
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 0.86rem;
}

/* ---------- Drobnosti ---------- */
.hide-sm { display: inline; }
@media (max-width: 620px) {
  .hide-sm { display: none; }
  .brand .vs { display: none; }
  .brand h1 { font-size: 1rem; letter-spacing: 1px; }
  #toolbar button { min-width: 50px; padding: 7px 7px; }
  .clock-chip { font-size: 0.82rem; padding: 3px 7px; }
}
@media (max-width: 380px) {
  .shop-top { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
