:root {
  --bg: #f1f9ee;                 /* velmi svetle zelene pozadi */
  --text: #1b2b1b;
  --muted: #5c6b58;
  --tile-border: #a7c39e;
  --tile-border-active: #6f8f68;
  --key-bg: #b7cbb0;             /* zakladni klavesy */
  --green: #4a9d47;
  --orange: #e0a12b;
  --blue: #3f7fd6;
  --black: #5a5e5b;
  --key-black: #3a3d3b;
  --ok-active: #4a9d47;
  --ok-disabled: #9db597;
  --del-bg: #c78a7c;
  --gap: 5px;
}

* { box-sizing: border-box; }

.hidden { display: none; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

header {
  position: relative;
  text-align: center;
  padding: 8px 0 2px;
  border-bottom: 1px solid var(--tile-border);
  width: 100%;
}

h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 6px;
  font-weight: 800;
  color: #23611f;
}

.logo-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
}
.logo {
  height: 52px;
  width: auto;
  display: block;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;   /* logo doleva */
  gap: 12px;
  padding: 4px 0 6px;            /* levy padding nastavuje JS (nad prvni dlazdici) */
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: left;
  max-width: 150px;
  line-height: 1.3;
}

.menu-btn {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 22px;
  line-height: 1;
  background: none;
  border: none;
  color: #23611f;
  cursor: pointer;
  padding: 4px 8px;
}
.help-btn {
  right: 48px;
  font-weight: 800;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  width: 100%;
  max-width: 500px;
  justify-content: space-between;
}

/* ---- Board ---- */
.board {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 12px;
  margin: 0 auto;                /* deska vycentrovana */
}

.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  position: relative;
}

/* Zaskrtavaci pole napravo od radku - jen v testovacim rezimu */
.row-check { display: none; }
body.test-mode .row-check {
  display: block;
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #3f6fae;
  background: rgba(255,255,255,0.6);
  cursor: pointer;
}
body.test-mode .row-check.checked {
  background: var(--green);
  border-color: var(--green);
}
body.test-mode .row-check.checked::after {
  content: '✓';
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.tile {
  width: 58px;
  height: 58px;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
  color: var(--text);
  background: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.tile.filled {
  border-color: var(--tile-border-active);
  animation: pop 0.1s ease;
}

.tile.cursor {
  border-width: 4px;
  border-color: #1b2b1b;
}

.tile.green  { background: var(--green);  border-color: var(--green);  color: #fff; }
.tile.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.tile.blue   { background: var(--blue);   border-color: var(--blue);   color: #fff; }
.tile.black  { background: var(--black);  border-color: var(--black);  color: #fff; }
/* Test: "smi sem" (z oranzoveho) - svetle zelena, aby se nepletla s domovskou */
.tile.lightgreen { background: #a7d89b; border-color: #a7d89b; color: #1b2b1b; }

.tile.locked { cursor: default; }

.tile.flash-red { animation: flashred 0.45s ease; }
@keyframes flashred {
  25%, 60% { background: #d64545; border-color: #d64545; color: #fff; }
}

@keyframes pop {
  0% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.tile.reveal { animation: flip 0.5s ease forwards; }
@keyframes flip {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

/* ---- Message ---- */
.message {
  min-height: 20px;
  font-size: 14px;
  color: #b5651d;
  text-align: center;
  padding: 2px 0;
}

/* ---- Obecne tlacitko (restart, hotovo) ---- */
.ok-btn {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--ok-active);
  border: none;
  border-radius: 8px;
  padding: 12px 30px;
  cursor: pointer;
}

/* ---- Klavesnice (telefonni typ) ---- */
.keyboard {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 6px 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.kb-line {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 52px;
  border: none;
  border-radius: 7px;
  background: var(--key-bg);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.key:active { transform: scale(0.95); }

.key.action {
  flex: 1.5 1 0;
  font-size: 14px;
  text-transform: none;
}
.key.del  { background: var(--del-bg); color: #fff; font-size: 20px; }
.key.test { background: var(--blue); color: #fff; }
.key.ok   { background: var(--ok-active); color: #fff; }
.key.ok:disabled { background: var(--ok-disabled); cursor: default; }
.key.back { background: var(--black); color: #fff; }   /* Zpet v testu */

/* Stav pismen */
.key.green  { background: var(--green);  color: #fff; }
.key.orange { background: var(--orange); color: #fff; }
.key.blue   { background: var(--blue);   color: #fff; }
.key.black  { background: var(--key-black); color: #8f948f; }

/* Rohove znacky variant: male pismeno, nebo barevna tecka pri odhaleni */
.hint {
  position: absolute;
  top: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #6b6b6b;
  pointer-events: none;
}
.hint-r { right: 4px; }
.hint-l { left: 4px; }
.hint.dot {
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.hint.dot.green  { background: var(--green); }
.hint.dot.orange { background: var(--orange); }
.hint.dot.blue   { background: var(--blue); }
.hint.dot.black  { background: var(--key-black); }
.key.green .hint, .key.orange .hint, .key.blue .hint, .key.black .hint { color: rgba(255,255,255,0.85); }

/* Ztlumeni skupiny pri odznaceni prepinace pod klavesnici */
.keyboard.dim-vowels .key.vowel { opacity: 0.2; }
.keyboard.dim-cons   .key.cons  { opacity: 0.2; }

/* ---- Prepinace samohlasky / souhlasky ---- */
.letter-filter {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}
.letter-filter label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.letter-filter input { cursor: pointer; }

/* ---- Bublina s diakritikou (long-press) ---- */
.accent-popup {
  position: fixed;
  z-index: 30;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: #2b2b2b;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.popt {
  min-width: 42px;
  height: 48px;
  padding: 0 8px;
  border-radius: 7px;
  background: #5b5f5b;
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popt.sel { outline: 3px solid #fff; background: #757a75; }
.popt.green  { background: var(--green); }
.popt.orange { background: var(--orange); }
.popt.blue   { background: var(--blue); }
.popt.black  { background: var(--key-black); }

/* ---- Overlay konce hry ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,40,20,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: #f3faf1;
  color: var(--text);
  padding: 28px 32px;
  border-radius: 12px;
  text-align: center;
  max-width: 300px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.overlay-card h2 { margin: 0 0 8px; font-size: 24px; color: #23611f; }
.overlay-card p  { margin: 0 0 18px; font-size: 16px; color: var(--muted); }

/* ---- Nastaveni (hamburger) ---- */
.settings-panel {
  position: fixed;
  inset: 0;
  background: rgba(20,40,20,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.settings-panel.hidden { display: none; }
.settings-card {
  background: #f3faf1;
  color: var(--text);
  padding: 24px 28px;
  border-radius: 12px;
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.settings-card h2 { margin: 0 0 16px; font-size: 22px; color: #23611f; }
.setting { margin-bottom: 18px; }
.setting-label { font-weight: 700; margin-bottom: 8px; }
.setting label { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.settings-card .ok-btn { width: 100%; }
.settings-btn {
  width: 100%;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
}
.settings-btn.giveup { background: #c0554a; }

.confirm-q { margin: 4px 0 16px; font-size: 17px; font-weight: 700; text-align: center; }
.confirm-row { display: flex; gap: 10px; }
.confirm-row .settings-btn, .confirm-row .ok-btn { margin-bottom: 0; flex: 1; }

/* ---- Pridani na plochu ---- */
.install-card { text-align: center; max-width: 300px; }
.install-icon {
  width: 76px;
  height: 76px;
  border-radius: 16px;
  margin: 0 auto 12px;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.install-steps { font-size: 15px; line-height: 1.5; margin: 0 0 16px; text-align: center; }

/* ---- Prezdivka + zebricek ---- */
.nick-info { font-size: 14px; color: var(--muted); margin: 0 0 12px; text-align: left; line-height: 1.4; }
.nick-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  margin-bottom: 6px;
  box-sizing: border-box;
}
.nick-input:focus { outline: none; border-color: var(--green); }
.nick-msg { min-height: 16px; font-size: 13px; color: #c0554a; margin: 0 0 12px; text-align: left; }

.lb-list { max-height: 60vh; overflow-y: auto; margin-bottom: 14px; text-align: left; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-size: 15px;
}
.lb-row.me { background: rgba(74,157,71,0.15); border-radius: 6px; }
.lb-rank { width: 28px; text-align: right; color: var(--muted); font-weight: 700; }
.lb-nick { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lb-empty { color: var(--muted); font-size: 14px; padding: 10px 0; text-align: center; }

.secure-hint, .secure-toggle { font-size: 14px; margin: 10px 0 0; text-align: left; color: var(--muted); }
.secure-toggle { text-align: center; }
.secure-hint a, .secure-toggle a { color: var(--blue); font-weight: 700; text-decoration: none; }
.overlay-cta { font-size: 14px; color: var(--muted); margin: 0 0 16px; line-height: 1.4; }
.overlay-cta a { color: var(--blue); font-weight: 700; text-decoration: none; }

/* ---- Pravidla hry ---- */
.rules-card { max-width: 360px; width: 90vw; }
.rules-text {
  max-height: 62vh;
  overflow-y: auto;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.rules-text h3 { margin: 14px 0 4px; font-size: 15px; color: #23611f; }
.rules-text h3:first-child { margin-top: 0; }
.rules-text p { margin: 0 0 6px; }
.rules-text ul { margin: 0 0 6px; padding-left: 20px; }
.rules-text li { margin-bottom: 4px; }
.rules-text a { color: var(--blue); font-weight: 700; text-decoration: none; }

/* ---- Minula hra (jen na cteni) ---- */
.lg-panel {
  position: fixed;
  inset: 0;
  background: rgba(20,40,20,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.lg-panel.hidden { display: none; }
.lg-card {
  background: #f3faf1;
  color: var(--text);
  padding: 22px 26px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.lg-card h2 { margin: 0 0 14px; font-size: 22px; color: #23611f; }
.lg-board { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.lg-row { display: flex; gap: 4px; justify-content: center; }
.lg-tile {
  width: 34px;
  height: 34px;
  border: 2px solid var(--tile-border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
}
.lg-tile.green  { background: var(--green);  border-color: var(--green);  color: #fff; }
.lg-tile.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.lg-tile.blue   { background: var(--blue);   border-color: var(--blue);   color: #fff; }
.lg-tile.black  { background: var(--black);  border-color: var(--black);  color: #fff; }
.lg-card p { margin: 0 0 16px; font-size: 16px; color: var(--muted); }

/* ---- Testovaci rezim: modre pozadi ---- */
body.test-mode {
  --bg: #eef4fd;
  background: var(--bg);
}
body.test-mode header { border-bottom-color: #a8c2e6; }

/* ---- Responsive ---- */
@media (max-width: 400px) {
  .tile { width: 48px; height: 48px; font-size: 22px; }
  .key { height: 48px; font-size: 16px; }
  .key.action { font-size: 13px; }
  h1 { font-size: 26px; }
}
