/* Korálková střílečka — MojeGalanterka.cz
 * Vizuální motiv: sametový tácek šperkařské dílny, lesklé skleněné korálky
 * (stejná kresba jako v Korálkovém Reversi) na šestiúhelníkové mřížce. */
:root {
  --velvet: #3a2438;
  --velvet-light: #4f3049;
  --velvet-dark: #241521;
  --gold: #e3b23c;
  --gold-dark: #bd8425;
  --ruby: #c1443a;
  --ruby-dark: #93342c;
  --accent: #c1443a;
  --accent-dark: #93342c;
  --cream: #f6eef2;
  --ink: #3a2438;
  --card: rgba(253, 250, 251, 0.94);
  --shadow: 0 8px 26px rgba(50, 25, 45, 0.25);
}

/* Barevné motivy prostředí (Část C3) — mění stránku a odstín sametu desky,
 * deska zůstává ve všech motivech tmavá (lesklé korálky na ní vynikají). */
html[data-theme="noc"] {
  --velvet: #e8cfe0;
  --velvet-light: #3f2340;
  --velvet-dark: #170d18;
  --cream: #191019;
  --ink: #f3e9f0;
  --card: rgba(38, 24, 36, 0.96);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
}
html[data-theme="smaragd"] {
  --velvet: #2c4a38;
  --velvet-light: #2e4a3c;
  --velvet-dark: #16281e;
  --cream: #eef4ef;
  --ink: #23392c;
  --card: rgba(250, 253, 250, 0.95);
  --shadow: 0 8px 26px rgba(22, 40, 30, 0.28);
}

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

#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(58, 36, 56, 0.96), rgba(36, 21, 33, 0.94));
  box-shadow: 0 3px 12px rgba(20, 10, 18, 0.35);
  color: #f9eef3;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  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;
}
.shop-top { color: #f0d4a8; text-decoration: none; font-weight: 700; font-size: 0.88rem; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.shop-top:hover { text-decoration: underline; }
.shop-link { cursor: pointer; }

.clocks { display: flex; gap: 6px; flex-shrink: 0; }
.clock-chip {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.clock-chip b { font-weight: 800; }

/* ---------- Herní plocha ---------- */
#gameArea {
  position: fixed;
  top: 44px; bottom: 92px; left: 0; right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "board right";
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}
#sidePanelRight { grid-area: right; }
#boardWrap { grid-area: board; min-width: 0; min-height: 0; }
.side-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; min-width: 0; }
.side-box {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.side-label { font-size: 0.72rem; font-weight: 700; color: var(--velvet); text-transform: uppercase; letter-spacing: 0.5px; }
.next-list { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.next-item canvas { background: rgba(58, 36, 56, 0.08); border-radius: 999px; }

#boardWrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#board {
  background: linear-gradient(160deg, var(--velvet-light), var(--velvet-dark));
  border-radius: 10px;
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(227, 178, 60, 0.18);
}

#pauseOverlay, #idleOverlay {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: none;
  align-items: center; justify-content: center;
  background: rgba(20, 10, 18, 0.72);
  border-radius: 10px;
  z-index: 15;
  text-align: center;
  padding: 20px;
  cursor: pointer;
}
#pauseOverlay.show, #idleOverlay.show { display: flex; }
.pause-card {
  color: #fff; text-align: center; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.pause-card i { font-size: 2rem; color: var(--gold); }

.idle-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: #fff; padding: 20px; max-width: 280px; }
.idle-card h3 { margin: 0; font-size: 1.3rem; }
.idle-card span { margin: 0; font-size: 0.95rem; opacity: 0.9; }
.idle-card button {
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 10px 24px; margin-top: 4px; border-radius: 12px; border: none;
  cursor: pointer; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; gap: 8px;
}
.idle-card button:active { transform: scale(0.96); }

/* ---------- Ovládací lišta ---------- */
#toolbar {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: 96vw;
}
#menuIdle, #menuPlaying {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 6px;
}
#menuPlaying { display: none; }
#toolbar button {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 12px;
  white-space: nowrap;
  min-width: 48px;
  padding: 7px 9px;
  font-size: 0.7rem;
}
#toolbar button i { font-size: 1.15rem; }
#toolbar button:active, #toolbar button:hover { background: rgba(58, 36, 56, 0.12); }

.toolbar-divider { width: 1px; align-self: stretch; margin: 4px 2px; background: rgba(58, 36, 56, 0.15); }
.round-btn { min-width: 0; width: 40px; height: 40px; padding: 0; border-radius: 999px !important; background: rgba(58, 36, 56, 0.1) !important; }
.round-btn i { font-size: 1.05rem; }

/* ---------- Nastavení (sheet) ---------- */
#sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(94vw, 440px);
  transform: translate(-50%, 105%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(20, 10, 18, 0.35);
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  z-index: 40;
  transition: transform 0.28s ease;
}
#sheet.show { transform: translate(-50%, 0); }
#sheet h2 { margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; color: var(--velvet); }
#sheet h2 button { border: none; background: none; font-size: 1.1rem; color: var(--ink); cursor: pointer; padding: 4px 8px; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(58, 36, 56, 0.08); font-size: 1rem; }
.sheet-row:last-of-type { border-bottom: none; }
.sheet-col { flex-direction: column; align-items: stretch; gap: 4px; }
.sheet-row label { font-weight: 700; color: var(--velvet); }
.sheet-hint { font-size: 0.78rem; color: rgba(58, 36, 56, 0.65); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; width: 100%; }
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 3px; background: rgba(58, 36, 56, 0.08); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stat-label { font-size: 0.68rem; color: rgba(58, 36, 56, 0.65); line-height: 1.25; }
.stat-value { font-size: 1.15rem; font-weight: 800; color: var(--velvet); }
#sheet select, #sheet input[type=checkbox] { font-size: 1rem; }
#sheet select { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(58, 36, 56, 0.2); background: #fff; color: var(--ink); }
#sheet input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.rules-btn, .install-btn { border: none; border-radius: 10px; padding: 8px 14px; font-weight: 700; cursor: pointer; background: var(--accent); color: #fff; font-family: inherit; font-size: 0.9rem; }
.sheet-help { margin-top: 6px; font-size: 0.9rem; color: rgba(58, 36, 56, 0.85); line-height: 1.6; }
.sheet-help p { margin: 4px 0; }
.sheet-promo, .end-promo { display: block; margin-top: 16px; padding: 10px 14px; border-radius: 12px; background: linear-gradient(135deg, #f5e9ef, #fbf0e0); color: #3a2438; /* pevná — box má pevné světlé pozadí ve všech motivech */ text-decoration: none; font-size: 1rem; line-height: 1.5; text-align: center; }

/* ---------- Modály (pravidla, konec hry) ---------- */
#rulesModal, #endModal {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(20, 10, 18, 0.55);
  padding: 16px;
}
#rulesModal.show, #endModal.visible { display: flex; }
.rules-box, .end-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  max-height: 84vh;
  overflow-y: auto;
}
.end-box { max-width: min(90vw, 400px); width: 100%; }
.rules-box { max-width: min(92vw, 430px); width: 100%; }
.rules-box h2, .end-box h2 { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; color: var(--velvet); font-size: 1.15rem; }
.rules-box h2 button { border: none; background: none; font-size: 1.1rem; color: var(--ink); cursor: pointer; }
.rules-box h3 { margin: 14px 0 4px; font-size: 0.95rem; color: var(--ruby-dark); }
.rules-box p, .rules-box li { margin: 4px 0; font-size: 0.92rem; line-height: 1.55; }
.rules-box table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.88rem; }
.rules-box th, .rules-box td { text-align: left; padding: 5px 8px; border-bottom: 1px solid rgba(58, 36, 56, 0.1); }
.end-box { text-align: center; }
.end-box p { font-size: 1rem; }
.end-box .btns { display: flex; gap: 10px; justify-content: center; margin: 14px 0 4px; }
.end-box .btns button { border: none; border-radius: 12px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-family: inherit; flex: 1; }

#endNew { background: var(--accent); color: #fff; }
#endClose { background: rgba(58, 36, 56, 0.1); color: var(--ink); }
#endShare { background: rgba(58, 36, 56, 0.1); color: var(--ink); width: 100%; }

@media (max-width: 700px) {
  #gameArea { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "right" "board"; }
  .side-panel { flex-direction: row; justify-content: center; width: 100%; }
  .side-box { flex-direction: row; padding: 6px 10px; gap: 8px; }
  .next-list { flex-direction: row; gap: 6px; }
  #boardWrap { width: 100%; height: 100%; }
}

@media (max-width: 480px) {
  .brand .vs { display: none; }
  #gameArea { gap: 6px; }
  .side-box { padding: 6px 8px; }
  .side-label { font-size: 0.62rem; }
  #sheet input[type="checkbox"] { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  #sheet { transition: none; }
}
