* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  background: linear-gradient(160deg, #c9ecf7 0%, #a9e8e0 45%, #ffeccb 100%);
  color: #1f4652;
}

#app {
  height: 100vh;        /* fallback pre staršie prehliadače bez dvh */
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* dole je rezervované miesto pre pevne ukotvenú lištu */
  padding: max(8px, env(safe-area-inset-top)) 8px calc(54px + max(10px, env(safe-area-inset-bottom)));
  gap: 10px;
  overflow: hidden;
}

#hud { flex-shrink: 0; width: min(94vw, 480px); }

.hud-row { display: flex; gap: 8px; align-items: stretch; }

.hud-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 8px 12px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(30, 120, 150, 0.18);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 66px;
}

.hud-wide { flex: 1; }

.hud-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a8ba0;
}

.hud-value { font-size: 22px; font-weight: 800; line-height: 1.2; }

.hud-target { font-size: 13px; font-weight: 800; color: #e8574a; }

/* posun je blízko – varovanie */
#hud-push.warn { background: #fff0ee; }
#hud-push.warn .hud-value { color: #e8574a; animation: pushPulse 1s ease-in-out infinite; }

@keyframes pushPulse { 50% { transform: scale(1.2); } }

.progress {
  height: 8px;
  border-radius: 999px;
  background: #d6edf2;
  margin: 4px 0 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb347, #ff6f61);
  transition: width 0.35s ease;
}

/* ---------- plocha ---------- */
#board-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#cv {
  width: min(96vw, 460px);
  height: 100%;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.24));
  box-shadow: 0 10px 30px rgba(20, 110, 145, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
  touch-action: none;
}

/* ---------- spodná lišta ---------- */
#bottom-bar {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(94vw, 480px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

#player-pill {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  color: #3f7286;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#player-label { font-weight: 700; color: #e8574a; }

#player-label:not(:empty)::after { content: " · "; color: #86aebb; font-weight: 400; }

.icon-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30, 120, 150, 0.25);
  transition: transform 0.1s ease;
}

.icon-btn:active { transform: scale(0.88); }

/* ---------- toast ---------- */
#toast-holder { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

.toast {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  background: rgba(12, 75, 95, 0.88);
  color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  animation: toastIn 2.2s ease forwards;
}

@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
  10%, 82% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 60, 85, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  transition: opacity 0.3s ease;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  background: linear-gradient(170deg, #fbfeff, #fff5e3);
  border-radius: 28px;
  padding: 28px 24px;
  width: min(88vw, 360px);
  text-align: center;
  box-shadow: 0 18px 50px rgba(10, 60, 90, 0.45);
  animation: panelIn 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.panel.tall {
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px 18px;
}

@keyframes panelIn {
  from { transform: scale(0.75) translateY(24px); opacity: 0; }
}

.panel-emoji { font-size: 42px; margin-bottom: 6px; }

.panel h1 {
  font-size: 25px;
  font-weight: 900;
  color: #e8574a;
  margin-bottom: 8px;
}

.panel p {
  font-size: 15px;
  color: #3f7286;
  line-height: 1.5;
  margin-bottom: 14px;
}

.help-body {
  flex: 1;
  overflow-y: auto;
  text-align: left;
  margin-bottom: 14px;
}

.h-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.4;
  color: #3f7286;
}

.h-ico { font-size: 20px; flex-shrink: 0; }

.mode-line {
  font-size: 12px !important;
  font-weight: 700;
  color: #55889c !important;
  margin-bottom: 10px !important;
}

.ver-line {
  font-size: 11px !important;
  color: #9bb4bf !important;
  margin: 2px 0 10px !important;
}

.stars { font-size: 32px; min-height: 8px; margin-bottom: 10px; letter-spacing: 4px; }
.stars:empty { display: none; }

.stars span {
  display: inline-block;
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.stars span:nth-child(2) { animation-delay: 0.18s; }
.stars span:nth-child(3) { animation-delay: 0.36s; }

@keyframes starPop { from { transform: scale(0) rotate(-120deg); } }

.big-btn {
  background: linear-gradient(135deg, #ffb347, #ff6f61);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 36px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 111, 97, 0.45);
}

.big-btn:active { transform: scale(0.95); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.conf { position: absolute; top: -20px; border-radius: 2px; }
