/* RESET + ОСНОВА */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background:
    radial-gradient(
        circle at center,
        #1b2129 0%,
        #11151a 55%,
        #0a0c10 100%
    );
    color: white;
    font-family: Arial, sans-serif;
    text-align: center;
    width: 100%;
}

/* HEADER */
header {
    background: #111;
    padding: 15px;
}

nav a {
    margin: 0 10px;
    color: #00ffd5;
    text-decoration: none;
}

main {
    padding: 20px;
}

.button {
    display: inline-block;
    padding: 10px 20px;
    background: #00ffd5;
    color: black;
    text-decoration: none;
}

/* POPUP */
.card-popup {
    position: fixed;
    pointer-events: none;
    width: 260px;
    background: #111;
    backdrop-filter: blur(6px);
    border: 1px solid #4a9eff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 0 25px rgba(74,158,255,0.4);
    opacity: 0;
    transform: scale(0.9);
    transition: 0.15s;
    z-index: 999;
}

.card-popup.visible {
    animation: popupFade 0.15s ease;
    opacity: 1;
    transform: scale(1);
}

.card-popup img {
    width: 100%;
    border-radius: 8px;
}

@keyframes popupFade {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.popup-info {
    margin-top: 8px;
    text-align: left;
}

.popup-info h3 {
    font-size: 14px;
    margin-bottom: 4px;
}

.popup-info p {
    font-size: 12px;
    color: #aaa;
}

/* BOOK */

.book-title {
    margin-bottom: 20px;
    color: #00ffd5;
    letter-spacing: 2px;
}

.chapter {
    max-width: 800px;
    margin: 10px auto;
    border: 1px solid #333;
    border-radius: 10px;
    overflow: hidden;
    background: #111;
}

.chapter-header {
    padding: 15px;
    cursor: pointer;
    background: #161616;
    color: #00ffd5;
    font-weight: bold;
    text-align: left;
    transition: 0.2s;
}

.chapter-header:hover {
    background: #1f1f1f;
}

.chapter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    padding: 0 15px;
    text-align: left;
    line-height: 1.6;
    color: #ddd;
}

.chapter.active .chapter-content {
    max-height: calc(100vh - 200px); 
    overflow-y: auto; /* 🔥 включает скролл */
    padding: 15px;
}

.chapter-content::-webkit-scrollbar {
    width: 6px;
}

.chapter-content::-webkit-scrollbar-thumb {
    background: #00ffd5;
    border-radius: 4px;
}

.chapter-content::-webkit-scrollbar-track {
    background: #111;
}

/* РЕЖИМ РИДЕРА */

.reader-mode {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    z-index: 9999;
    overflow-y: auto;
    padding: 60px 20px;
}

.reader-content {
    max-width: 700px;
    margin: auto;
    font-size: 18px;
    line-height: 1.8;
    color: #ddd;
}

.reader-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #111;
    border: 1px solid #00ffd5;
    color: #00ffd5;
    padding: 8px 12px;
    cursor: pointer;
}

.read-btn {
    float: right;
    background: transparent;
    border: 1px solid #00ffd5;
    color: #00ffd5;
    cursor: pointer;
    padding: 4px 8px;
}

/* доступные клетки */
.cell.valid-target {
    box-shadow: 0 0 10px #00ffd5, 0 0 20px #00ffd5 inset;
    border: 1px solid #00ffd5;
}

/* выбранные клетки */
.cell.selected-target {
    box-shadow: 0 0 15px #ff00ff, 0 0 30px #ff00ff inset;
    border: 1px solid #ff00ff;
}

/* невалидные */
.cell.invalid-target {
    opacity: 0.3;
}

@keyframes pulse {
    0% { box-shadow: 0 0 5px #00ffd5; }
    50% { box-shadow: 0 0 20px #00ffd5; }
    100% { box-shadow: 0 0 5px #00ffd5; }
}

.cell.valid-target {
    animation: pulse 1.5s infinite;
}

.cell.valid-target:hover {
    transform: scale(1.05);
}