/* Pišklubka v3 — MojeGalanterka.cz */
:root {
  --plum: #b5486b;
  --plum-dark: #8e3654;
  --mint: #6fae9c;
  --mint-dark: #3e8e75;
  --blue: #3f7bc4;
  --blue-dark: #2c5a94;
  --red: #cc4b42;
  --orange: #e0932c;
  --cream: #f6ecdb;
  --ink: #4a3b2f;
  --card: rgba(255, 252, 245, 0.92);
  --shadow: 0 8px 26px rgba(90, 60, 30, 0.22);
}

/* Barevné motivy prostředí (Část C3) — mění dílnu a plátno kolem,
 * NE barvy klubíček a jehlic na desce (ty jsou ve všech motivech stejné). */
html[data-theme="pulnoc"] {
  --cream: #241d18;
  --ink: #f2e8dc;
  --card: rgba(44, 36, 30, 0.95);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}
html[data-theme="vres"] {
  --cream: #f2e8f2;
  --ink: #463349;
  --card: rgba(253, 249, 253, 0.94);
  --shadow: 0 8px 26px rgba(142, 54, 84, 0.18);
}

* { 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(--cream);
}

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

#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;
  background: linear-gradient(180deg, rgba(122, 86, 48, 0.96), rgba(96, 66, 34, 0.94));
  box-shadow: 0 3px 12px rgba(60, 40, 15, 0.35);
  color: #fdf6ea;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 2px;
  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: #a8cdf2; }
.brand .vs b.foe { color: #f2b1a8; }
.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, #f6e7ee, #eaf4f0);
  color: var(--plum-dark);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.5;
}
.sheet-promo { text-align: center; margin-top: 14px; }

.install-btn, .rules-btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 9px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--mint), var(--mint-dark));
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.install-btn:active, .rules-btn:active { transform: scale(0.96); }

.end-promo b, .sheet-promo b { color: var(--plum); }
.end-promo:hover, .sheet-promo:hover { box-shadow: 0 3px 12px rgba(181, 72, 107, 0.25); }

.clocks { display: flex; gap: 6px; flex-shrink: 0; }
.clock-chip {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid transparent;
  white-space: nowrap;
}
#clockHuman.active { border-color: #a8cdf2; background: rgba(63, 123, 196, 0.35); }
#clockAI.active { border-color: #f2b1a8; background: rgba(204, 75, 66, 0.35); }

/* ---------- Stavový řádek ---------- */
.status-chip {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: min(92vw, 640px);
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 0.98rem;
  font-weight: 600;
  text-align: center;
}
.status-chip.thinking { background: #fdf0e0; color: #8a5a17; }
.status-chip.won { background: #e6f4ee; color: #226349; }
.status-chip.lost { background: #fbe9e7; color: #97362f; }

/* ---------- Spodní panel nástrojů ---------- */
#toolbar {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
#toolbar button {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 58px;
  white-space: nowrap;
}
#toolbar button i { font-size: 1.2rem; }
.icon-badge { position: relative; display: inline-block; }
.icon-badge .badge {
  position: absolute;
  top: -6px;
  right: -12px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--mint-dark);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}
#toolbar button:disabled .badge { background: #b7aa96; }
#toolbar button:hover { background: rgba(181, 72, 107, 0.1); }
#toolbar button:active { transform: scale(0.94); }
#toolbar button:disabled { opacity: 0.4; cursor: default; }

/* ---------- Zoom sloupec ---------- */
#zoomstack {
  position: fixed;
  right: 12px;
  bottom: max(90px, calc(env(safe-area-inset-bottom) + 78px));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#zoomstack button {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
#zoomstack button:active { transform: scale(0.94); }

/* ---------- Nastavení (sheet) ---------- */
#sheet {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(94vw, 440px);
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(60, 40, 15, 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);
  max-height: 78vh;
  overflow-y: auto;
}
#sheet.open { transform: translate(-50%, 0); }
#sheet h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--plum-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sheetClose {
  border: none;
  background: #f1e6d4;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--ink);
}
.sheet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed #e7d9c2;
  font-size: 1rem;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row.sheet-col { flex-direction: column; align-items: flex-start; gap: 9px; }
.sheet-hint { font-size: 0.78rem; opacity: 0.7; }
.sheet-row.sheet-col select { width: 100%; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(74, 59, 47, 0.2);
  cursor: pointer;
  padding: 0;
}
.swatch.sel {
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px #fff;
  transform: scale(1.12);
}
.sheet-row label { font-weight: 600; }
.sheet-row select {
  font-family: inherit;
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1.5px solid #d9c6a4;
  background: var(--card);
  color: var(--ink);
}
.sheet-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--mint-dark);
}
.sheet-stats { display: flex; gap: 14px; font-size: 1rem; }
.sheet-stats b { color: var(--plum-dark); }
.sheet-help {
  font-size: 0.9rem;
  color: #7a6a55;
  line-height: 1.45;
  margin-top: 10px;
}
.sheet-help i { color: var(--mint-dark); width: 20px; text-align: center; }

/* ---------- Konec partie ---------- */
#endModal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 59, 47, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#endModal.visible { opacity: 1; pointer-events: auto; }

/* ---------- Modal s pravidly ---------- */
#rulesModal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(74, 59, 47, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#rulesModal.visible { opacity: 1; pointer-events: auto; }
.rules-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 14px 44px rgba(50, 32, 12, 0.4);
  padding: 22px 24px;
  max-width: min(92vw, 430px);
  width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  text-align: left;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}
#rulesModal.visible .rules-box { transform: translateY(0); }
.rules-box h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  color: var(--plum-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rules-box h2 button {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 8px;
}
.rules-box h3 { font-size: 0.98rem; margin: 14px 0 4px; color: var(--plum-dark); }
.rules-box p, .rules-box li { font-size: 0.9rem; line-height: 1.55; margin: 4px 0; color: var(--ink); }
.rules-box ul { margin: 4px 0; padding-left: 20px; }
.rules-box .rule-note {
  background: #f6ecdb;
  border-radius: 10px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 0.86rem;
}

.end-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 14px 44px rgba(50, 32, 12, 0.4);
  padding: 26px 30px;
  text-align: center;
  max-width: min(90vw, 400px);
  width: 100%;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}
#endModal.visible .end-box { transform: translateY(0); }
.end-box h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--plum-dark); }
.end-box p { margin: 0 0 16px; font-size: 0.95rem; color: #7a6a55; }
.end-box .btns { display: flex; gap: 10px; margin-bottom: 1rem; }
.end-box .btns button { flex: 1; } /* Nová hra + Zavřít půl na půl, Sdílet samo přes celou šířku (Část F) */
.end-box button {
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
	flex: 1;
}

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

.end-box button:active { transform: scale(0.96); }

/* ---------- Mobil ---------- */
/* ---------- Mobil: kompakce horní lišty (jen úzké displeje) ---------- */
@media (max-width: 560px) {
  #topbar { padding: 8px 10px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 1rem; letter-spacing: 1px; }
  .brand .vs { display: none; }
  .hide-sm { display: none; }
  .shop-top { font-size: 0.72rem; }
  .clock-chip { font-size: 0.72rem; padding: 3px 7px; }
  .clocks { gap: 4px; }
  .status-chip { top: 50px; }
}

/* ---------- Dotyková zařízení: větší texty a dotykové cíle
     (mobil i tablet, na výšku i na šířku — podle pointer: coarse) ---------- */
@media (pointer: coarse), (max-width: 560px) {
  .status-chip { font-size: 0.95rem; padding: 8px 15px; }

  #toolbar { gap: 4px; padding: 8px 6px; }
  #toolbar button { min-width: 60px; font-size: 0.85rem; padding: 8px 9px; }
  #toolbar button i { font-size: 1.3rem; }

  #zoomstack button { width: 48px; height: 48px; font-size: 1.15rem; }

  #sheet { padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); }
  #sheet h2 { font-size: 1.3rem; }
  #sheetClose { width: 38px; height: 38px; font-size: 1.05rem; }
  .sheet-row { font-size: 1.15rem; padding: 14px 0; }
  .sheet-row select { font-size: 1.1rem; padding: 10px 14px; }
  .sheet-row input[type="checkbox"] { width: 28px; height: 28px; }
  .swatch { width: 36px; height: 36px; }
  .sheet-stats { font-size: 1.15rem; gap: 16px; }
  .sheet-help { font-size: 1.05rem; line-height: 1.55; }
  .sheet-promo { font-size: 1.08rem; padding: 14px 16px; }

  .end-box { padding: 26px 24px; }
  .end-box h2 { font-size: 1.35rem; }
  .end-box p { font-size: 1rem; }
  .end-box button { font-size: 1.05rem; padding: 12px 22px; }
  .end-promo { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  #sheet, #endModal, .end-box { transition: none !important; }
}
/* Čitelnost nočního motivu */
html[data-theme="pulnoc"] .end-box h2,
html[data-theme="pulnoc"] .rules-box h2 { var(--ink); }
html[data-theme="pulnoc"] .sheet-row select { border-color: #6e5a48; }
html[data-theme="pulnoc"] #sheet h2,
html[data-theme="pulnoc"] .sheet-help p 
 { color: var(--ink); }
html[data-theme="pulnoc"] #sheetClose { color: var(--card); }
