@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap');

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #a8d0ff 0%, #d0e6ff 50%, #f0f8ff 100%);
  font-family: 'Roboto Mono', monospace;
  color: #5a2a3b;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 15px 40px;
  user-select: none;
  position: relative;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #b99aa8 transparent;
}
body::-webkit-scrollbar {
  width: 8px;
}
body::-webkit-scrollbar-track {
  background: transparent;
}
body::-webkit-scrollbar-thumb {
  background-color: #b99aa8;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

header {
  width: 100%;
  background-color: rgba(0, 70, 140, 0.85);
  padding: 15px 30px;
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 120, 215, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  border-radius: 0 0 20px 20px;
}
.container {
  max-width: 1200px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.logo {
  font-weight: 900;
  font-size: 1.7rem;
  color: #fff;
  user-select: none;
  cursor: default;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
  letter-spacing: 0.04em;
  outline-offset: 2px;
}
nav {
  display: flex;
  gap: 25px;
}
nav a {
  color: #e0e0e0;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.15rem;
  padding: 8px 16px;
  border-radius: 10px;
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 0 6px transparent;
}
nav a:hover,
nav a:focus {
  background-color: rgba(0, 100, 180, 0.7);
  color: #fff;
  outline: none;
  box-shadow: 0 0 10px rgba(0, 100, 180, 0.7);
}
nav a[aria-current="page"] {
  background-color: rgba(0, 80, 160, 0.8);
  color: #fff;
  box-shadow: 0 0 14px rgba(0, 80, 160, 0.8);
}

h1 {
  margin-bottom: 15px;
  font-weight: 900;
  color: #1a527c;
  text-shadow:
    0 0 6px #5dade2,
    0 0 14px #5dade2;
  text-align: center;
  font-size: 2.8rem;
  letter-spacing: 0.1em;
}

#main-content-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  max-width: 900px;
  width: 100%;
  margin-bottom: 30px;
}

#polybius-container {
  display: inline-grid;
  grid-template-columns: 30px repeat(6, 52px);
  grid-template-rows: 30px repeat(6, 52px);
  gap: 9px;
  user-select: none;
  box-shadow: 0 0 20px #87ceebaa;
  padding: 15px;
  border-radius: 15px;
  background: #e0f2f7;
  flex-shrink: 0;
}
.corner {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}
.col-num, .row-num {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 20px;
  color: #1a3e5c;
  user-select: none;
  font-family: 'Roboto Mono', monospace;
}
.col-num {
  grid-row: 1 / 2;
}
.row-num {
  grid-column: 1 / 2;
}
.cell {
  background:#add8e6;
  border-radius:10px;
  box-shadow:0 0 10px #87ceeb;
  display:flex;
  justify-content:center;
  align-items:center;
  font-size:24px;
  font-weight:700;
  color:#1a3e5c;
  cursor: default;
  user-select:none;
  transition:
    background-color 0.25s ease,
    transform 0.25s ease,
    box-shadow 0.3s ease,
    color 0.25s ease;
}
.cell:hover {
  background-color: #6daee2;
  color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 20px #6daee2;
}

#question-box {
  max-width: 350px;
  background: #e0f2f7;
  border-radius: 15px;
  padding: 25px 30px;
  box-shadow: 0 0 25px #1a527caa;
  font-family: 'Roboto Mono', monospace;
  color: #1a527c;
  font-size: 1.25rem;
  font-weight: 700;
  user-select: none;
  line-height: 1.4;
  flex-shrink: 0;
  flex-grow: 1;
}
#question-box h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-weight: 900;
  font-size: 1.5rem;
  color: #145374;
  border-bottom: 2px solid #87ceeb;
  padding-bottom: 6px;
}
#cipher-text {
  margin-top: 12px;
  font-size: 1rem;
  color: #555;
  font-family: monospace;
  user-select: text;
}

#interaction {
  max-width: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: 'Roboto Mono', monospace;
  margin-top: 20px;
  width: 100%;
}
#answerInput {
  width: 100%;
  max-width: 320px;
  font-size: 20px;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid #b99aa8;
  text-transform: uppercase;
  outline: none;
  transition: box-shadow 0.3s ease;
  box-sizing: border-box;
}
#answerInput:focus {
  box-shadow: 0 0 15px #87ceeb;
  border-color: #6daee2;
}
#checkBtn {
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg,#a3d8f4,#7ec8f8);
  color: #1a3e5c;
  border: none;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 5px 15px rgba(126, 200, 248, 0.8);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
}
#checkBtn:hover {
  background: linear-gradient(135deg,#7ec8f8,#a3d8f4);
  color: #0f2a42;
  box-shadow: 0 8px 30px #7ec8f8;
  transform: scale(1.1);
}
#checkBtn:active {
  transform: scale(0.95);
}
#result {
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.5em;
  color: #1a527c;
  user-select: none;
  text-align: center;
  width: 100%;
}

/* Canvas для фейерверка */
#fireworks-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10000;
  display: none;
  background: transparent;
}
#success-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Roboto Mono', monospace;
  font-size: 6rem;
  font-weight: 900;
  color: #218838;
  text-shadow:
    0 0 15px #218838,
    0 0 30px #218838,
    0 0 45px #218838,
    0 0 60px #218838;
  pointer-events: none;
  z-index: 10001;
  display: none;
  user-select: none;
  text-align: center;
  white-space: nowrap;
}

/* Стили для новых красивых кнопок-стрелок */
.fancy-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6db9f7, #3a8ee6);
  box-shadow:
    0 0 10px rgba(61, 143, 230, 0.8),
    inset 0 0 8px rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition:
    background 0.4s ease,
    box-shadow 0.4s ease,
    transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}
.fancy-btn:hover {
  background: linear-gradient(135deg, #3a8ee6, #6db9f7);
  box-shadow:
    0 0 20px rgba(61, 143, 230, 1),
    inset 0 0 15px rgba(255, 255, 255, 0.9);
  transform: scale(1.15);
}
.fancy-btn:active {
  transform: scale(0.95);
  box-shadow:
    0 0 8px rgba(61, 143, 230, 0.6),
    inset 0 0 6px rgba(255, 255, 255, 0.5);
}
.fancy-btn::before {
  content: '';
  position: absolute;
  top: -15%;
  left: -15%;
  width: 130%;
  height: 130%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61,143,230,0.4) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 0;
}
.fancy-btn:hover::before {
  opacity: 1;
}
.icon-arrow {
  display: block;
  width: 18px;
  height: 18px;
  border: solid #fff;
  border-width: 0 4px 4px 0;
  padding: 3px;
  transition: border-color 0.4s ease;
  z-index: 1;
}
.fancy-btn:hover .icon-arrow {
  border-color: #d0eaff;
}
.icon-arrow.left {
  transform: rotate(135deg);
}
.icon-arrow.right {
  transform: rotate(-45deg);
}

/* Реалистичные SVG облака с анимацией */
.clouds-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
  background: linear-gradient(to bottom, #a8d0ff 0%, #d0e6ff 100%);
}
.cloud {
  position: absolute;
  top: var(--top, 10%);
  left: -20vw;
  width: var(--size, 10vw);
  height: auto;
  opacity: var(--opacity, 0.7);
  animation-name: flyCloud;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-duration: var(--duration, 40s);
  animation-delay: var(--delay, 0s);
}
.cloud svg {
  width: 100%;
  height: auto;
  display: block;
}
@keyframes flyCloud {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(130vw);
  }
}

/* Модальное окно приглашения */
#invitation-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20000;
  user-select: text;
}
#invitation-modal .modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
#invitation-modal .modal-content {
  position: relative;
  background: #f0f8ff;
  border-radius: 15px;
  padding: 30px 40px;
  max-width: 480px;
  box-shadow: 0 0 25px rgba(26, 82, 124, 0.8);
  color: #1a527c;
  font-family: 'Roboto Mono', monospace;
  font-size: 1.15rem;
  z-index: 20001;
  outline: none;
}
#invitation-modal h2 {
  margin-top: 0;
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  color: #145374;
  text-shadow:
    0 0 6px #5dade2,
    0 0 14px #5dade2;
}
#invitation-modal p {
  margin: 15px 0;
  line-height: 1.4;
}
#invitation-modal a {
  color: #1a527c;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.3s ease;
}
#invitation-modal a:hover,
#invitation-modal a:focus {
  color: #3a8ee6;
  outline: none;
}
#modal-close-btn {
  margin-top: 25px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a3e5c;
  background: linear-gradient(135deg,#a3d8f4,#7ec8f8);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(126, 200, 248, 0.8);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
  user-select: none;
}
#modal-close-btn:hover {
  background: linear-gradient(135deg,#7ec8f8,#a3d8f4);
  color: #0f2a42;
  box-shadow: 0 8px 30px #7ec8f8;
  transform: scale(1.1);
}
#modal-close-btn:active {
  transform: scale(0.95);
}