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

:root { --s: 48px; }

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; }

/* ---------- HUD ---------- */
#hud { width: min(94vw, 480px); }

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

.hud-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  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; }

.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;
}

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

#board {
  position: relative;
  width: min(94vw, 460px, calc(100vh - 210px));  /* fallback bez dvh */
  width: min(94vw, 460px, calc(100dvh - 210px));
  aspect-ratio: 1 / 1;
  background: rgba(255, 252, 246, 0.72);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(20, 110, 145, 0.25), inset 0 0 0 3px rgba(255, 255, 255, 0.6);
  overflow: hidden;
  touch-action: none;
}

.cell {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--s);
  height: var(--s);
}

.cell::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 22%;
  background: rgba(150, 205, 225, 0.16);
}

/* trate */
.seg {
  position: absolute;
  border-radius: 3px;
  transition: opacity 0.1s linear;
}

.seg.core {
  left: 32%; top: 32%;
  width: 36%; height: 36%;
  border-radius: 30%;
}

.seg.s-up { left: 32%; width: 36%; top: 0; height: 52%; }
.seg.s-down { left: 32%; width: 36%; top: 48%; height: 52%; }
.seg.s-left { top: 32%; height: 36%; left: 0; width: 52%; }
.seg.s-right { top: 32%; height: 36%; left: 48%; width: 52%; }

/* letiská */
.dot {
  position: absolute;
  left: 13%; top: 13%;
  width: 74%; height: 74%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.96);
  box-shadow:
    0 3px 9px rgba(15, 85, 110, 0.42),
    inset 0 -4px 7px rgba(0, 0, 0, 0.2),
    inset 0 4px 7px rgba(255, 255, 255, 0.5);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* radarový prstenec okolo letiska */
.dot::before {
  content: "";
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.32;
}

.dot svg {
  width: 56%;
  height: 56%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.dot svg path { fill: #fff; }

/* spojené letisko – jemné pulzovanie a rozsvietený prstenec */
.dot.linked { animation: dotPulse 1.4s ease-in-out infinite; }

.dot.linked::before { animation: haloPulse 1.4s ease-in-out infinite; }

@keyframes dotPulse {
  50% { transform: scale(1.07); }
}

@keyframes haloPulse {
  0%, 100% { transform: scale(1); opacity: 0.32; }
  50% { transform: scale(1.16); opacity: 0.1; }
}

/* letisko, z ktorého sa práve kreslí */
.dot.active {
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.65),
    0 3px 12px rgba(15, 85, 110, 0.45),
    inset 0 -4px 7px rgba(0, 0, 0, 0.2),
    inset 0 4px 7px rgba(255, 255, 255, 0.5);
}

/* ---------- spodná lišta ---------- */
/* lišta je ukotvená k spodku okna – nezávisí od výpočtu výšky #app */
#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); }

/* počítadlo pomôcok */
.badge {
  position: absolute;
  right: -3px;
  top: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff6f61;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 85, 110, 0.4);
}

.badge:empty { display: none; }

.badge.zero { background: #9bb4bf; }

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

/* ---------- 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.5);
  backdrop-filter: blur(5px);
  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; }

.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); }

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

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