/* Klubíčko vzhůru — MojeGalanterka.cz
 * Vizuální motiv: klubíčko skáče vzhůru po klubkách, knoflících, háčcích
 * a poličkách proti ranní obloze. */
:root {
  --sky-top: #bfe3ee;
  --sky-bottom: #fdf1dd;
  --navy: #2d3a4a;
  --navy-dark: #1c2531;
  --sun: #eeb04a;
  --sun-dark: #c98c28;
  --yarn: #e0724f;
  --yarn-dark: #b8543a;
  --leaf: #4f9d69;
  --leaf-dark: #377349;
  --card: rgba(255, 253, 248, 0.95);
  --ink: #2d3a4a;
  --shadow: 0 8px 26px rgba(30, 40, 55, 0.22);
}

/* Barevné motivy prostředí (Část C3) — mění oblohu a dílnu kolem,
 * NE barvu klubíčka (ta má vlastní volbu) ani plošinky. */
html[data-theme="zapad"] {
  --sky-top: #f4b183;
  --sky-bottom: #fbe3c9;
  --navy: #7c3f4e;
  --navy-dark: #55293a;
  --card: rgba(255, 250, 243, 0.95);
  --ink: #4a2d38;
  --shadow: 0 8px 26px rgba(85, 41, 58, 0.24);
}
html[data-theme="noc"] {
  --sky-top: #141c33;
  --sky-bottom: #2c3a5e;
  --navy: #3a4a6e;
  --navy-dark: #1a2338;
  --card: rgba(30, 38, 60, 0.96);
  --ink: #e8edfa;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}

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

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

/* ---------- 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(45, 58, 74, 0.96), rgba(28, 37, 49, 0.94));
  box-shadow: 0 3px 12px rgba(15, 20, 28, 0.35);
  color: #f2f7fa;
}
.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 a, .shop-top { color: #d9ecf3; 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, #eaf5f8, #fdf0da);
  color: var(--navy-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(--leaf), var(--leaf-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(--navy); }
.end-promo:hover, .sheet-promo:hover { box-shadow: 0 3px 12px rgba(45, 58, 74, 0.25); }

/* ---------- HUD skóre nad hrou ---------- */
.score-hud {
  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: 700;
  text-align: center;
}
.score-hud b { color: var(--yarn-dark); }

/* ---------- Herní plocha ---------- */
#gameWrap {
  position: fixed;
  inset: 0;
  padding-top: 96px;
  padding-bottom: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
#gameFrame {
  background: linear-gradient(155deg, #4a6178, #2d3a4a);
  border-radius: 22px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(20, 26, 36, 0.35);
  position: relative;
}
#game {
  display: block;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  touch-action: none;
}

#pauseOverlay, #startOverlay {
  position: absolute;
  inset: 10px;
  border-radius: 14px;
  background: rgba(28, 37, 49, 0.55);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
#pauseOverlay.visible, #startOverlay.visible { display: flex; }
#pauseOverlay h3, #startOverlay h3 { margin: 0; font-size: 1.3rem; }
#pauseOverlay p, #startOverlay p { margin: 0; font-size: 0.95rem; opacity: 0.9; max-width: 260px; }
#startOverlay button, #pauseOverlay button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--yarn), var(--yarn-dark));
  color: #fff;
  cursor: pointer;
}
#startOverlay button:active, #pauseOverlay button:active { transform: scale(0.96); }

/* ---------- 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: 8px;
  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 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 64px;
  white-space: nowrap;
}
#toolbar button i { font-size: 1.25rem; }
#toolbar button:hover { background: rgba(45, 58, 74, 0.1); }
#toolbar button:active { transform: scale(0.94); }
#toolbar button:disabled { opacity: 0.4; cursor: default; }

/* ---------- 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(15, 20, 28, 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(--navy-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sheetClose {
  border: none;
  background: #eaf1f4;
  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 #dbe7ec;
  font-size: 1rem;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row.sheet-col { flex-direction: column; align-items: flex-start; gap: 6px; }
.sheet-hint { font-size: 0.86rem; color: #6d7f8f; }
.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 #c3d2de;
  background: var(--card);
  color: var(--ink);
}
.sheet-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--leaf-dark);
}
.color-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.08);
  cursor: pointer;
  padding: 0;
  position: relative;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.12), inset 0 2px 2px rgba(255,255,255,0.5);
  transition: transform 0.12s ease;
}
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.selected {
  border-color: var(--navy-dark, #2d3a4a);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.12), inset 0 2px 2px rgba(255,255,255,0.5), 0 0 0 2px #fff, 0 0 0 4px var(--navy-dark, #2d3a4a);
}
.color-swatch.selected::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,0.55);
  font-size: 0.95rem;
  font-weight: 700;
}
.sheet-stats { display: flex; gap: 12px; font-size: 0.98rem; flex-wrap: wrap; justify-content: flex-end; }
.sheet-stats b { color: var(--navy-dark); }
.sheet-help { font-size: 0.9rem; color: #5c6f80; line-height: 1.45; margin-top: 10px; }
.sheet-help i { color: var(--leaf-dark); width: 20px; text-align: center; }

/* ---------- Konec hry / pravidla ---------- */
#endModal, #rulesModal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 26, 36, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}
#endModal.visible, #rulesModal.visible { opacity: 1; pointer-events: auto; }
.end-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 14px 44px rgba(15, 18, 26, 0.4);
  padding: 26px 30px;
  text-align: center;
  max-width: min(90vw, 400px);
  width: 100%;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}
.rules-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 14px 44px rgba(15, 18, 26, 0.4);
  padding: 22px 26px;
  max-width: min(92vw, 430px);
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.25s ease;
  text-align: left;
}
#endModal.visible .end-box, #rulesModal.visible .rules-box { transform: translateY(0); }
.end-box h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--navy-dark); }
.end-box p { margin: 0 0 16px; font-size: 0.95rem; color: #5c6f80; }
.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(--yarn), var(--yarn-dark)); color: #fff; }
#endClose { background: #eaf1f4; color: var(--ink); }
#endShare { background: #eaf1f4; color: var(--ink); width: 100%; }

.end-box button:active { transform: scale(0.96); }
.rules-box h2 { margin: 0 0 12px; font-size: 1.25rem; color: var(--navy-dark); display: flex; justify-content: space-between; align-items: center; }
.rules-box h3 { margin: 14px 0 4px; font-size: 1.02rem; color: var(--yarn-dark); }
.rules-box p, .rules-box li { margin: 0 0 8px; font-size: 0.98rem; line-height: 1.5; color: var(--ink); }
.rules-box ul { margin: 4px 0; padding-left: 20px; }
.rules-box table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.92rem; }
.rules-box th, .rules-box td { text-align: left; padding: 4px 6px; border-bottom: 1px dashed #dbe7ec; }
#rulesClose {
  border: none;
  background: #eaf1f4;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
}

/* ---------- Mobil ---------- */
@media (max-width: 560px) {
  #topbar { padding: 8px 10px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 0.98rem; letter-spacing: 0.5px; }
  .brand .vs { display: none; }
  .hide-sm { display: none; }
  .shop-top { font-size: 0.72rem; }
  .score-hud { top: 50px; font-size: 0.88rem; padding: 6px 14px; }
  #gameWrap { padding-top: 92px; }
}

@media (pointer: coarse), (max-width: 560px) {
  #toolbar { gap: 5px; padding: 8px 6px; }
  #toolbar button { min-width: 66px; font-size: 0.85rem; padding: 8px 10px; }
  #toolbar button i { font-size: 1.3rem; }

  #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.12rem; padding: 14px 0; }
  .sheet-row input[type="checkbox"] { width: 28px; height: 28px; }
  .sheet-stats { font-size: 1.02rem; gap: 12px; }
  .sheet-help { font-size: 1.02rem; line-height: 1.55; }
  .sheet-promo { font-size: 1.05rem; 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, #rulesModal, .rules-box { transition: none !important; }
}
/* Čitelnost nočního motivu */
html[data-theme="noc"] .sheet-hint { color: rgba(232, 237, 250, 0.65); }
html[data-theme="noc"] .sheet-row select { border-color: #4a5a7e; }
html[data-theme="noc"] #sheet h2,
html[data-theme="noc"] .sheet-help p 
	{ color: var(--ink); }
html[data-theme="noc"] #sheetClose { color: var(--navy); }