/* Coral Kingdom — палитра и HUD */
:root {
  --ink: #04263f;
  --deep: #06365e;
  --water: #1a8fdc;
  --aqua: #4fcbe8;
  --foam: #eefaff;
  --sun: #ffe58a;
  --coral: #ff6b9d;
  --coral-2: #ff9a3c;
  --mint: #7ef0d8;
  --card: rgba(6, 40, 66, 0.92);
  --radius: 22px;
  font-size: 16px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--deep);
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--foam);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; display: block; }

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(2, 20, 38, 0.42) 100%);
}

/* ---------- бренд ---------- */
#brand {
  position: fixed; top: 14px; left: 16px;
  display: flex; align-items: center; gap: 10px;
  z-index: 20; pointer-events: none;
}
#brand .seal {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(145deg, var(--coral), var(--coral-2));
  display: grid; place-items: center;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 17px;
  color: #fff; box-shadow: 0 4px 14px rgba(255, 107, 157, 0.4);
}
#brand strong {
  display: block; font-family: 'Baloo 2', sans-serif;
  font-size: 19px; letter-spacing: 0.04em; color: var(--foam);
  text-shadow: 0 2px 8px rgba(2, 20, 40, 0.6);
}
#brand span {
  display: block; font-size: 10px; letter-spacing: 0.18em;
  color: var(--aqua); font-weight: 700;
}

#editorLink {
  position: fixed; bottom: 10px; left: 14px; z-index: 20;
  font-size: 10px; letter-spacing: 0.14em; font-weight: 700;
  color: rgba(238, 250, 255, 0.4); text-decoration: none;
}
#editorLink:hover { color: var(--aqua); }

/* ---------- кнопки ---------- */
#pauseBtn, #helpBtn, #musicBtn {
  position: fixed; z-index: 22;
  border: 2px solid rgba(238, 250, 255, 0.35);
  background: rgba(6, 40, 66, 0.6);
  color: var(--foam);
  border-radius: 14px;
  font-family: 'Baloo 2', sans-serif; font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.15s, background 0.2s;
}
#pauseBtn:hover, #helpBtn:hover, #musicBtn:hover { transform: scale(1.06); background: rgba(26, 143, 220, 0.5); }
#pauseBtn { top: 70px; left: 16px; width: 42px; height: 42px; font-size: 15px; }
#helpBtn { top: 118px; left: 16px; width: 42px; height: 42px; font-size: 18px; }
#musicBtn {
  top: 166px; left: 16px; height: 42px; padding: 0 12px;
  display: flex; align-items: center; gap: 6px; font-size: 12px; letter-spacing: 0.08em;
}
#musicBtn.muted { opacity: 0.45; }
#musicBtn.muted .music-note { text-decoration: line-through; }

/* ---------- счётчики (сверху-справа) ---------- */
#counters {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 22;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--card);
  border: 2px solid rgba(126, 240, 216, 0.4);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  font-family: 'Baloo 2', sans-serif;
  color: var(--foam);
  box-shadow: 0 6px 20px rgba(2, 20, 40, 0.35);
}
.chip .chip-icon {
  font-size: 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.chip b {
  font-size: 20px; font-weight: 800; letter-spacing: 0.02em;
  min-width: 46px; text-align: center;
}
.chip-friend { background: linear-gradient(145deg, rgba(126,240,216,0.35), rgba(6,40,66,0.85)); }
.chip-pearl  { background: linear-gradient(145deg, rgba(255,155,200,0.35), rgba(6,40,66,0.85)); }
.chip-chest  { background: linear-gradient(145deg, rgba(255,213,120,0.35), rgba(6,40,66,0.85)); }
.chip-scene  { background: linear-gradient(145deg, rgba(120,180,255,0.35), rgba(6,40,66,0.85)); }

/* ---------- дневник — скрытая книжка ---------- */
#bookWrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 24;
}
#bookBtn {
  width: 76px; height: 76px;
  border: none; padding: 0; cursor: pointer;
  background: none;
  filter: drop-shadow(0 6px 14px rgba(2,20,40,0.5));
  transition: transform 0.2s;
}
#bookBtn:hover { transform: scale(1.08) rotate(-3deg); }
#bookImg {
  width: 100%; height: 100%;
  object-fit: contain;
}

#slotsPanel {
  position: absolute;
  right: 0;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  background: var(--card);
  border: 2px solid rgba(126, 240, 216, 0.4);
  border-radius: 22px;
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 48px rgba(2, 20, 40, 0.6);
  min-width: 460px;
  max-width: 62vw;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.94);
  transform-origin: bottom right;
  transition: opacity 0.25s, transform 0.25s;
}
#bookWrap:hover #slotsPanel,
#bookWrap.open #slotsPanel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.book-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(126, 240, 216, 0.3);
  margin-bottom: 4px;
}
.book-head span {
  font-size: 10px; letter-spacing: 0.22em; font-weight: 800; color: var(--aqua);
}
.book-head b {
  font-family: 'Baloo 2', sans-serif; font-size: 20px; color: var(--foam);
}
.slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slot-row::before {
  content: attr(data-label);
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--aqua);
  width: 78px;
  text-align: right;
  flex: none;
}
.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
}
.slot {
  width: 60px; height: 60px;
  border-radius: 10px;
  background: rgba(238, 250, 255, 0.09);
  border: 2px dashed rgba(126, 240, 216, 0.3);
  display: grid; place-items: center;
  cursor: default;
  transition: transform 0.2s, background 0.2s;
  overflow: hidden;
  padding: 0;
  color: var(--foam);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 16px;
}
.slot-creature {
  cursor: pointer;
}
.slot img {
  width: 100%; height: 100%; object-fit: contain;
  filter: brightness(0) invert(1) opacity(0.28);
  transition: filter 0.35s, transform 0.35s;
}
.slot.discovered {
  background: rgba(126, 240, 216, 0.14);
  border: 2px solid rgba(126, 240, 216, 0.7);
  animation: slotPop 0.5s ease-out;
}
.slot.discovered img {
  filter: none;
  transform: scale(1.05);
}
.slot-pearl.collected {
  background: radial-gradient(circle at 40% 30%, #ffd0e6, #ff6b9d);
  border: 2px solid #ffd0e6;
  box-shadow: 0 0 12px rgba(255, 107, 157, 0.6);
  animation: slotPop 0.5s ease-out;
}
.slot-chest {
  color: rgba(238, 250, 255, 0.4);
}
.slot-chest.collected {
  color: #ffe58a;
  background: rgba(244, 193, 74, 0.18);
  border: 2px solid rgba(244, 193, 74, 0.6);
  animation: slotPop 0.5s ease-out;
}
@keyframes slotPop {
  0% { transform: scale(0.6) rotate(-6deg); }
  60% { transform: scale(1.2) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}
@media (max-width: 760px) {
  #counters { top: 8px; right: 8px; gap: 4px; }
  .chip { padding: 5px 9px; }
  .chip .chip-icon { font-size: 15px; }
  .chip b { font-size: 14px; min-width: 34px; }
  #bookBtn { width: 58px; height: 58px; }
  #slotsPanel { min-width: 320px; padding: 10px 12px; bottom: 72px; }
  .slot-row::before { width: 60px; font-size: 8px; }
  .slot { width: 40px; height: 40px; border-radius: 8px; font-size: 12px; }
}

/* ---------- тост ---------- */
#toast {
  position: fixed; top: 84px; left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: linear-gradient(145deg, var(--coral), var(--coral-2));
  color: #fff; font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 17px;
  padding: 10px 26px; border-radius: 999px;
  box-shadow: 0 8px 28px rgba(255, 107, 157, 0.45);
  opacity: 0; pointer-events: none; z-index: 30;
  transition: opacity 0.3s, transform 0.3s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- модалки ---------- */
#overlay, .help-overlay, .card-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(3, 22, 40, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s;
}
#overlay.show, .help-overlay.show, .card-overlay.show { opacity: 1; pointer-events: auto; }

.modal, .help-modal {
  width: min(520px, calc(100vw - 48px));
  background: var(--card);
  border: 2px solid rgba(126, 240, 216, 0.35);
  border-radius: var(--radius);
  padding: 26px 30px 30px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(2, 16, 32, 0.6);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
#modalArt {
  width: 100%; max-height: 240px; object-fit: cover;
  border-radius: 16px; margin-bottom: 16px;
}
#modalKicker, .help-kicker {
  font-size: 11px; letter-spacing: 0.26em; font-weight: 800; color: var(--mint);
}
.modal h1, .help-modal h3 {
  font-family: 'Baloo 2', sans-serif; font-size: 30px; line-height: 1.15;
  margin: 8px 0 12px; color: var(--foam);
}
.modal p, .help-body {
  font-size: 15px; line-height: 1.55; color: rgba(238, 250, 255, 0.85);
}
.modal button, .help-modal button, .card-actions button {
  margin-top: 20px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px;
  padding: 12px 34px; border: none; border-radius: 999px;
  background: linear-gradient(145deg, var(--coral), var(--coral-2));
  color: #fff; cursor: pointer;
  box-shadow: 0 10px 26px rgba(255, 107, 157, 0.45);
  transition: transform 0.15s;
}
.modal button:hover, .help-modal button:hover, .card-actions button:hover { transform: scale(1.05); }

/* ---------- карточка существа ---------- */
.creature-card {
  width: min(640px, calc(100vw - 40px));
  display: flex; gap: 22px; align-items: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(126, 240, 216, 0.12), transparent 50%),
    var(--card);
  border: 2px solid rgba(126, 240, 216, 0.4);
  border-radius: 26px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(2, 16, 32, 0.65);
  animation: cardPop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
  max-height: calc(100vh - 32px);
}
@keyframes cardPop {
  from { transform: scale(0.7) rotate(-2deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.card-photo {
  flex: 0 0 42%;
  background: linear-gradient(180deg, #9adfff, #2f9fd8);
  border-radius: 18px;
  border: 4px solid #fff;
  padding: 12px;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(2, 20, 40, 0.4);
  transform: rotate(-2.5deg);
}
.card-photo img { width: 100%; max-height: 230px; object-fit: contain; }
.card-info { flex: 1; text-align: left; }
.card-info h2 {
  font-family: 'Baloo 2', sans-serif; font-size: 27px; color: var(--foam);
}
.card-info em {
  display: block; font-size: 12px; color: var(--aqua);
  margin: 2px 0 14px; letter-spacing: 0.06em;
}
.fact-label {
  display: inline-block;
  font-size: 10px; letter-spacing: 0.22em; font-weight: 800;
  color: #ffd28a; margin-bottom: 6px;
}
#cardFact { font-size: 15px; line-height: 1.5; color: rgba(238, 250, 255, 0.9); }
.card-actions { display: flex; gap: 12px; align-items: center; }
#cardVoice {
  background: rgba(126, 240, 216, 0.18);
  border: 2px solid rgba(126, 240, 216, 0.5);
  box-shadow: none;
  color: var(--mint);
  font-size: 15px;
  padding: 10px 20px;
}

/* ---------- мобильное управление ---------- */
#mobileControls { display: none; }
body.touch #mobileControls { display: block; }
#stick {
  position: fixed; left: 26px; bottom: 30px; z-index: 26;
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(6, 40, 66, 0.4);
  border: 2px solid rgba(238, 250, 255, 0.3);
  backdrop-filter: blur(4px);
}
#stick i {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--aqua), var(--water));
  box-shadow: 0 6px 18px rgba(2, 20, 40, 0.5);
}
#mobileButtons { position: fixed; right: 26px; bottom: 34px; z-index: 26; }
#actionBtn {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(145deg, var(--coral), var(--coral-2));
  font-size: 38px;
  box-shadow: 0 10px 30px rgba(255, 107, 157, 0.5);
}
#actionBtn:active { transform: scale(0.92); }

/* ---------- поворот экрана ---------- */
.rotate-wall {
  position: fixed; inset: 0; z-index: 60;
  display: none; place-items: center;
  background: linear-gradient(180deg, var(--deep), var(--ink));
  text-align: center;
}
.rotate-wall.show { display: grid; }
.rotate-box h2 { font-family: 'Baloo 2', sans-serif; font-size: 26px; margin: 18px 0 8px; }
.rotate-box p { font-size: 14px; color: rgba(238, 250, 255, 0.75); line-height: 1.5; }
.rotate-icon { color: var(--aqua); animation: rock 1.6s ease-in-out infinite; }
@keyframes rock {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-90deg); }
}

@media (max-width: 760px) {
  #brand strong { font-size: 15px; }
  #brand span { display: none; }
  .hud-panel .score { padding: 6px 12px; }
  .hud-panel .score b { font-size: 16px; }
  .creature-card { flex-direction: column; gap: 14px; padding: 18px; overflow-y: auto; }
  .card-photo { flex: none; width: 60%; }
  .card-photo img { max-height: 140px; }
  .card-info { text-align: center; }
  .card-actions { justify-content: center; }
  #editorLink { display: none; }
}
