html {
  box-sizing: border-box;
  scroll-behavior: smooth;
  height: 100%;
}
*, *::before, *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-main);
  background-image: radial-gradient(circle at 50% 30vh, #080d1b 0%, var(--bg-color) 50%);
  background-attachment: fixed;
  background-repeat: no-repeat;

  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

#tsparticles, #mouse-glow {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1;
  pointer-events: none;
}
#mouse-glow {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0, 247, 255, 0.08) 0%, rgba(0, 247, 255, 0) 60%);
  border-radius: 50%;
  transform: translate(-50%, -50%);

  will-change: transform;
  transition: opacity 0.4s ease;
  opacity: 0;
}
body:hover #mouse-glow { opacity: 1; }

.main-header {
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}
.main-nav {
  display: flex;
  position: relative;
}
.nav-link {
  color: var(--text-secondary-color);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  transition: color 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
  font-size: 1rem;
  position: relative;
  z-index: 2;
}
.nav-link:hover { color: var(--text-color); }
.nav-link.active { color: var(--primary-color); }

.nav-underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background-color: var(--primary-color);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
}

.lang-switcher {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  background-color: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 0.3rem;
}
.lang-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.45rem;
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 0;
  transition: background-color 0.3s ease, transform 0.3s ease;
}
.lang-btn:hover {
  background-color: rgba(0, 247, 255, 0.12);
}
.lang-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
.lang-flag {
  display: block;
  width: 26px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;

  border: 1px solid rgba(255, 255, 255, 0.25);
}

.page-loader {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.loader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 247, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-container {
  padding: 0 2rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;

  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

#app {
  opacity: 1;

  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

body:not(.modal-open) .modal-overlay { display: none; }
.modal-overlay[style*="display: flex"] { display: flex !important; }

.modal-content {
  position: relative;
  padding: 2.5rem;
  max-width: 600px;
  width: 90%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  text-align: left;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.modal-close-btn {
  position: absolute;
  top: 10px; right: 10px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-secondary-color);
  font-size: 1.5rem;
  cursor: pointer;
  transition: 0.3s;
  z-index: 101;
}
.modal-close-btn:hover { color: var(--primary-color); transform: scale(1.1); }

.modal-content h3 { color: var(--primary-color); margin-bottom: 1rem; font-size: 1.5rem; }
.modal-content p { margin-bottom: 1.5rem; line-height: 1.6; color: var(--text-secondary-color); }

.modal-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem;
}
.detail-item {
  background: rgba(13, 2, 33, 0.5); padding: 0.75rem; border-radius: 5px;
  border-left: 3px solid var(--primary-color); color: var(--text-color); font-size: 0.9rem;
}

.star-rating { gap: 4px; font-size: 1.5rem; line-height: 1; vertical-align: middle; }
.star { color: var(--star-filled-color); }
.star.empty { color: var(--star-empty-color); }

.modal-source {
  margin-top: -0.75rem;
  font-size: 0.72rem;
  color: rgba(240, 240, 240, 0.4);
}

.modal-links { display: flex; gap: 1rem; margin-top: 1.5rem; }
.modal-link-btn {
  flex-grow: 1; text-align: center; padding: 0.75rem; border-radius: 8px;
  text-decoration: none; color: var(--text-color);
  background-color: rgba(255, 255, 255, 0.1); border: 1px solid var(--glass-border);
  transition: 0.3s; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.modal-link-btn:hover { background-color: var(--primary-color); color: var(--bg-color); }
.modal-link-btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.tag {
  background-color: rgba(0, 247, 255, 0.1);
  color: var(--primary-color);
  padding: 0.25rem 0.6rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(0, 247, 255, 0.2);
}

.history-item {
  position: relative; padding-left: 25px; margin-bottom: 1rem;
  color: var(--text-secondary-color); font-size: 0.95rem;
}
.history-item::before {
  content: ""; position: absolute; left: 0; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background-color: var(--primary-color);
  box-shadow: 0 0 8px var(--primary-color);
}

.pasek-dolny,
.pasek-arkusz,
.pasek-kurtyna { display: none; }

html.menu-otwarte,
html.menu-otwarte body { overflow: hidden; }

@media (max-width: 820px) {
  .main-nav, .lang-switcher { display: none; }
  .main-header { padding: 0.85rem 1rem; }

  body {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .pasek-dolny {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1001;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: stretch;
    background-color: rgba(6, 8, 22, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  }

  .pasek-link {
    appearance: none;
    background: none;
    border: none;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.28rem;
    padding: 0.6rem 0.25rem 0.7rem;
    color: var(--text-secondary-color);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    transition: color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .pasek-link i {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .pasek-link span {
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .pasek-link::before {
    content: "";
    position: absolute;
    top: 0.35rem;
    width: 2.6rem;
    height: 2rem;
    border-radius: 999px;
    background-color: rgba(0, 247, 255, 0.12);
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .pasek-link.active,
  .pasek-wiecej[aria-expanded="true"] {
    color: var(--primary-color);
  }
  .pasek-link.active::before,
  .pasek-wiecej[aria-expanded="true"]::before {
    opacity: 1;
    transform: scale(1);
  }
  .pasek-link.active i {
    transform: translateY(-1px);
  }
  .pasek-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -4px;
    border-radius: 12px;
  }

  .pasek-kurtyna {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 17, 0.6);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s;
  }
  .pasek-kurtyna.is-open {
    opacity: 1;
    visibility: visible;
  }

  .pasek-arkusz {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0 0.75rem;
    padding: 0.5rem 0.6rem 0.75rem;
    background-color: rgba(10, 12, 28, 0.97);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    transform: translateY(14px) scale(0.97);
    transform-origin: bottom center;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease, visibility 0.3s;
  }
  .pasek-arkusz.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
  }
  .pasek-uchwyt {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.22);
    margin: 0.15rem auto 0.6rem;
  }
  .arkusz-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .arkusz-link i {
    font-size: 1.1rem;
    color: var(--primary-color);
    width: 1.4rem;
    text-align: center;
  }
  .arkusz-link.active {
    background-color: rgba(0, 247, 255, 0.1);
    color: var(--primary-color);
  }
  .arkusz-jezyk {
    display: flex;
    justify-content: center;
    margin-top: 0.55rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .lang-btn-mobilny {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    color: var(--text-secondary-color);
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1;
  }
}
@media (max-width: 768px) {
  .modal-details { grid-template-columns: 1fr; }
  .modal-links { flex-direction: column; }
}

@keyframes wejscie-elementu {
  from { opacity: 0; translate: 0 100px; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes wejscie-naglowka {
  from { opacity: 0; translate: 0 34px; }
  to   { opacity: 1; translate: 0 0; }
}

[data-wejscie] { opacity: 0; }

[data-wejscie].wszedl {
  animation: wejscie-elementu 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.main-header [data-wejscie].wszedl,
.lang-switcher [data-wejscie].wszedl {
  animation-name: wejscie-naglowka;
}

#tsparticles {
  opacity: 0;
  transition: opacity 1200ms ease-out;
}
#tsparticles.wszedl { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  [data-wejscie],
  [data-wejscie].wszedl {
    opacity: 1;
    animation: none;
    translate: none;
  }
  #tsparticles { opacity: 1; transition: none; }
}
