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

:root { --tw: 40px; --th: 51px; }

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(52px + max(10px, env(safe-area-inset-bottom)));
  gap: 10px;
  overflow: hidden;
}

#hud { flex-shrink: 0; }

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

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

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

#board {
  position: relative;
  width: min(98vw, 560px);
  height: 100%;
  touch-action: none;
}

.tile {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--tw);
  height: var(--th);
  border-radius: 18%;
  background: linear-gradient(165deg, #fffdf6 0%, #fff4dd 60%, #f7e6c4 100%);
  border: 1px solid rgba(160, 130, 80, 0.35);
  box-shadow:
    0 2px 0 rgba(150, 120, 70, 0.55),
    0 4px 6px rgba(20, 80, 110, 0.28),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--tw) * 0.6);
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.2s ease;
}

/* vyššie vrstvy vrhajú väčší tieň – kôpka pôsobí priestorovo */
.tile[data-l="1"] {
  box-shadow:
    0 3px 0 rgba(150, 120, 70, 0.55),
    0 7px 12px rgba(20, 80, 110, 0.34),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.tile[data-l="2"] {
  box-shadow:
    0 4px 0 rgba(150, 120, 70, 0.55),
    0 10px 16px rgba(20, 80, 110, 0.38),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.tile[data-l="3"] {
  box-shadow:
    0 5px 0 rgba(150, 120, 70, 0.55),
    0 13px 20px rgba(20, 80, 110, 0.42),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

/* zablokované dlaždice stmavené – hneď vidno, s čím sa dá hýbať */
.tile.blocked {
  filter: brightness(0.72) saturate(0.7);
  cursor: default;
}

.tile.sel {
  transform: translateY(-3px) scale(1.06);
  border-color: #ff6f61;
  box-shadow:
    0 0 0 3px rgba(255, 111, 97, 0.85),
    0 6px 10px rgba(20, 80, 110, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.95);
}

.tile.hint { animation: hintFlash 0.7s ease-in-out 3; }

@keyframes hintFlash {
  50% {
    box-shadow: 0 0 0 4px rgba(77, 150, 255, 0.9), 0 6px 12px rgba(20, 80, 110, 0.4);
    transform: translateY(-3px) scale(1.06);
  }
}

.tile.deny { animation: denyShake 0.32s ease; }

@keyframes denyShake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.tile.gone { animation: tileGone 0.28s ease-in forwards; pointer-events: none; }

@keyframes tileGone {
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.2) rotate(12deg); opacity: 0; }
}

/* ---------- 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(96vw, 520px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

#player-pill {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  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: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  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;
}

/* upozornenie, že treba zamiešať */
.icon-btn.nudge {
  animation: nudge 0.7s ease-in-out infinite;
  background: #fff0ee;
}

@keyframes nudge {
  50% { transform: scale(1.16); box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.45); }
}

/* ---------- 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); }

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