:root {
  --men: #2f6bff;
  --men-dark: #1746c2;
  --women: #ff4d97;
  --women-dark: #c41e6b;
  --talk: #ffb020;
  --show: #8b5cf6;
  --bg: #12101e;
  --bg2: #1c1930;
  --card: #262240;
  --text: #f2f0ff;
  --muted: #a7a2c8;
  --ok: #28c76f;
  --skip: #ff5b5b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Open Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at 20% 0%, #2a2350 0%, var(--bg) 55%);
  color: var(--text);
  overscroll-behavior: none;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; padding: 20px; max-width: 640px; margin: 0 auto; width: 100%; }
.screen.active { display: flex; }

h1 { font-size: 2rem; margin: 0.2em 0; text-align: center; }
h1 .vs { color: var(--muted); font-weight: 400; }
.subtitle { text-align: center; color: var(--muted); margin-top: 0; }

/* ---------- Tlačidlá ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--card);
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn.big { font-size: 1.3rem; padding: 20px; width: 100%; }
.btn.men { background: linear-gradient(135deg, var(--men), var(--men-dark)); }
.btn.women { background: linear-gradient(135deg, var(--women), var(--women-dark)); }
.btn.primary { background: linear-gradient(135deg, #6d5cff, #3f2fb0); }
.btn.ghost { background: transparent; border: 2px solid var(--muted); color: var(--muted); }

/* ---------- Menu ---------- */
.field { margin: 14px 0; }
.field label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field select {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid #3a3560;
  background: var(--bg2); color: var(--text); font-size: 1rem;
}
.field.row { display: flex; gap: 14px; align-items: center; }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline label { margin: 0; }
.settings { background: var(--bg2); border-radius: 16px; padding: 16px; margin: 16px 0; }
.settings h3 { margin: 0 0 8px; font-size: 1rem; color: var(--muted); }
.menu-emoji { font-size: 3rem; text-align: center; margin: 10px 0; }

/* ---------- Board ---------- */
.turn-label { font-size: 1.4rem; font-weight: 800; text-align: center; margin: 4px 0; }
.turn-label.men { color: var(--men); }
.turn-label.women { color: var(--women); }

.activity-badge {
  text-align: center; font-size: 1.5rem; font-weight: 800; padding: 14px;
  border-radius: 16px; margin: 10px 0 4px;
}
.activity-badge.rozpravanie { background: rgba(255,176,32,.18); color: var(--talk); border: 2px solid var(--talk); }
.activity-badge.ukazovanie { background: rgba(139,92,246,.18); color: var(--show); border: 2px solid var(--show); }
.activity-badge.kreslenie { background: rgba(0,184,212,.16); color: #2fd0e6; border: 2px solid #00b8d4; }
.activity-badge.special { background: rgba(255,77,151,.16); color: #ff7ab3; border: 2px solid #ff4d97; }

/* mode selektor */
.mode-selector { display: flex; gap: 8px; }
.mode-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px; border-radius: 14px; border: 2px solid #3a3560;
  background: var(--bg); color: var(--text); cursor: pointer;
  transition: transform .08s, border-color .15s, background .15s;
}
.mode-btn:active { transform: scale(0.97); }
.mode-btn.active { border-color: #6d5cff; background: rgba(109,92,255,.18); }
.mode-btn .mode-emoji { font-size: 1.6rem; }
.mode-btn .mode-name { font-size: .8rem; font-weight: 700; text-align: center; }
.mode-desc { color: var(--muted); font-size: .85rem; margin: 12px 2px 0; text-align: center; }
.activity-hint { text-align: center; color: var(--muted); margin: 4px 0 14px; font-size: .95rem; }

.scores { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }

.track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 8px 0 18px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px;
  background: radial-gradient(circle at 30% 0%, #221d3c, #16132a);
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px #ffffff12, 0 8px 24px #0006;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card);
  font-size: 1.2rem;
  box-shadow: 0 2px 6px #0004;
}
/* spojky medzi poľami — cestička hadíka */
.conn { position: absolute; background: #ffffff26; border-radius: 4px; z-index: 0; }
.conn.right { right: -15px; top: 50%; transform: translateY(-50%); width: 16px; height: 7px; }
.conn.left  { left: -15px;  top: 50%; transform: translateY(-50%); width: 16px; height: 7px; }
.conn.down  { bottom: -15px; left: 50%; transform: translateX(-50%); height: 16px; width: 7px; }
.cell.rozpravanie { background: rgba(255,176,32,.14); border: 1px solid rgba(255,176,32,.4); }
.cell.ukazovanie { background: rgba(139,92,246,.14); border: 1px solid rgba(139,92,246,.4); }
.cell.kreslenie { background: rgba(0,184,212,.14); border: 1px solid rgba(0,184,212,.4); }
.cell.special { background: rgba(255,77,151,.16); border: 1px solid rgba(255,77,151,.5); }
.cell.start { background: rgba(255,255,255,.1); border: 1px solid #fff5; }
.cell.finish { background: rgba(40,199,111,.2); border: 1px solid var(--ok); }
.cell-emoji { opacity: .8; position: absolute; }
.cell-diff { position: absolute; bottom: 2px; right: 4px; font-size: .6rem; letter-spacing: -1px; }
.pawns {
  position: absolute; inset: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2px; padding: 2px; pointer-events: none;
}
.pawn {
  width: 42%; aspect-ratio: 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 900; color: #fff;
  box-shadow: 0 2px 6px #0009;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* badge obtiažnosti */
.diff-badge { text-align: center; color: var(--muted); font-size: .9rem; margin: 4px 0; }
.diff-badge b { color: var(--text); }

/* dynamické skóre */
.score-chip {
  padding: 8px 10px; border-radius: 10px; background: var(--bg2);
  font-size: .82rem; font-weight: 700; border: 1px solid transparent;
}
.score-chip.active { box-shadow: 0 0 0 2px currentColor inset; }

/* editor tímov */
.team-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.swatch { width: 22px; height: 22px; border-radius: 6px; flex: 0 0 auto; }
.team-name { flex: 1 1 auto; min-width: 0; padding: 10px; border-radius: 10px; border: 1px solid #3a3560; background: var(--bg2); color: var(--text); }
.team-cat { flex: 0 0 auto; max-width: 46%; padding: 10px; border-radius: 10px; border: 1px solid #3a3560; background: var(--bg2); color: var(--text); }
.team-del { flex: 0 0 auto; width: 40px; height: 40px; border: none; border-radius: 10px; background: #3a2540; color: #ff8aa6; font-size: 1rem; cursor: pointer; }
.team-del:disabled { opacity: .35; cursor: not-allowed; }
#addTeamBtn { width: 100%; margin-top: 4px; }

/* ---------- Hra ---------- */
.play-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.play-team { font-weight: 800; font-size: 1.2rem; }
.play-team.men { color: var(--men); }
.play-team.women { color: var(--women); }
.timer {
  font-size: 2.2rem; font-weight: 900; font-variant-numeric: tabular-nums;
  background: var(--bg2); padding: 4px 16px; border-radius: 12px; min-width: 70px; text-align: center;
}
.timer.low { color: var(--skip); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

.special-banner {
  background: rgba(255,77,151,.14);
  border: 1px solid rgba(255,77,151,.5);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 10px 0 0;
  text-align: center;
  font-size: .95rem;
  color: #ffd0e3;
}
.special-banner b { color: #ff7ab3; font-size: 1.05rem; }

#singlePlay { flex: 1; display: flex; flex-direction: column; }
#listPlay { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.list-hint { text-align: center; color: var(--muted); font-size: .9rem; margin: 12px 0 8px; }
.word-list { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 2px; }
.word-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 16px; padding: 10px 12px;
  animation: pop .2s ease;
}
.wr-word { flex: 1; text-align: center; font-size: 1.8rem; font-weight: 800; }
.wr-btn {
  border: none; border-radius: 12px; width: 56px; height: 56px;
  font-size: 1.5rem; font-weight: 900; color: #fff; cursor: pointer; flex: 0 0 auto;
  touch-action: manipulation;
}
.wr-btn:active { transform: scale(0.92); }
.wr-btn.ok { background: linear-gradient(135deg, #28c76f, #128a4a); }
.wr-btn.skip { background: linear-gradient(135deg, #ff6b6b, #c43030); }

.word-card {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--card);
  border-radius: 24px;
  margin: 16px 0;
  padding: 20px;
  text-align: center;
  min-height: 200px;
  transition: background .12s;
}
.word-card.ok { background: rgba(40,199,111,.35); }
.word-card.skip { background: rgba(255,91,91,.35); }
.word { font-size: 2.6rem; font-weight: 800; }

.counters { display: flex; justify-content: center; gap: 24px; color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.counters .c-ok { color: var(--ok); }
.counters .c-skip { color: var(--skip); }

.play-actions { display: flex; gap: 12px; }
.play-actions .btn { flex: 1; font-size: 1.6rem; padding: 22px; }
.btn.correct { background: linear-gradient(135deg, #28c76f, #128a4a); }
.btn.skip { background: linear-gradient(135deg, #ff6b6b, #c43030); }
.end-now { margin-top: 10px; }

/* ---------- Výsledok / výhra ---------- */
.center-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px;
}
.result-team { font-size: 2rem; font-weight: 900; }
.result-team.men { color: var(--men); }
.result-team.women { color: var(--women); }
.result-detail { color: var(--muted); font-size: 1.1rem; }
.result-move { font-size: 1.4rem; font-weight: 800; }
.win-emoji { font-size: 5rem; animation: pop .4s ease; }
.win-text { font-size: 2.4rem; font-weight: 900; }
.win-text.men { color: var(--men); }
.win-text.women { color: var(--women); }

.spacer { flex: 1; }
.footer-btns { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
