/* 🐔 Курц был здесь */

body {
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
    background-color: #1a1a1a;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}


/* =====================
   ЭКРАН 1: КОНВЕРТ
   ===================== */

#start-screen {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    width: 100vw;
    height: 100vh;
    animation: fadeIn 1.2s forwards;
    overflow: hidden;
}

#glitchCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#start-screen > *:not(#glitchCanvas) {
    position: relative;
    z-index: 1;
}

#cursed-curs-title {
    font-size: 2.2rem;
    color: #ff4444;
    text-align: center;
    margin: 0;
    cursor: pointer;
    letter-spacing: 1px;
}

.envelope {
    position: relative;
    width: 340px;
    height: 220px;
    perspective: 800px;
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 170px solid transparent;
    border-right: 170px solid transparent;
    border-top: 110px solid #3a2a1a;
    transform-origin: top center;
    transform-style: preserve-3d;
    z-index: 3;
    transition: transform 0.7s ease;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.envelope.open .envelope-flap {
    transform: rotateX(-180deg);
}

.envelope-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #2e1f0e 0%, #3a2a1a 50%, #2a1a0a 100%);
    border-radius: 4px 4px 8px 8px;
    border: 1px solid #5a3a1a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7), inset 0 0 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    z-index: 1;
}

/* Треугольники низа конверта */
.envelope-body::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 170px solid #2a1a0a;
    border-right: 0 solid transparent;
    border-bottom: 110px solid #1a1a1a;
    opacity: 0.6;
}

.envelope-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-right: 170px solid #2a1a0a;
    border-left: 0 solid transparent;
    border-bottom: 110px solid #1a1a1a;
    opacity: 0.6;
}

.envelope-hint {
    font-size: 0.85rem;
    color: #a07040;
    text-align: center;
    margin: 0;
    padding: 0 1.5rem;
    font-style: italic;
    position: relative;
    z-index: 2;
}

.start-button {
    position: relative;
    z-index: 2;
    padding: 0.7rem 1.8rem;
    font-size: 1rem;
    font-family: 'Courier New', Courier, monospace;
    background-color: #5a3010;
    color: #f0c060;
    border: 1px solid #a06020;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
}

.start-button:hover {
    background-color: #7a4020;
    box-shadow: 0 0 12px rgba(200, 100, 20, 0.5);
}

/* =====================
   ЭКРАН 2: СВИТОК
   ===================== */

#game-screen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    animation: fadeIn 3s forwards;
    z-index: 10;
}

#organicCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#game-screen-container > *:not(#organicCanvas) {
    position: relative;
    z-index: 1;
}

.scroll-wrap {
    position: relative;
    display: flex;
    align-items: flex-start;
    max-width: 640px;
    width: 90vw;
    margin: 2rem 1rem;
}

.scroll-candles {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 1.5rem 0;
}

.candle-left {
    margin-right: -8px;
}

.candle-right {
    margin-left: -8px;
}

.scroll-content {
    flex: 1;
    background: linear-gradient(180deg,
        #f5e6c8 0%,
        #ede0b0 20%,
        #e8d89a 50%,
        #ede0b0 80%,
        #f5e6c8 100%
    );
    border-radius: 60px 60px 60px 60px / 20px 20px 20px 20px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow:
        0 0 0 6px #c8a050,
        0 0 0 8px #8a6020,
        0 8px 32px rgba(0,0,0,0.6);
    color: #1a0a00;
    position: relative;
    /* Изолируем от органического canvas-фона */
    isolation: isolate;
}

.scroll-content::before,
.scroll-content::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #c8a050, transparent);
}

.scroll-content::before { top: 1.2rem; }
.scroll-content::after  { bottom: 1.2rem; }

.scroll-content h1 {
    font-size: 1.6rem;
    color: #5a2a00;
    margin-bottom: 1rem;
}

.scroll-content p {
    font-size: 1rem;
    color: #2a1000;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.cursed {
    color: #8b0000;
    font-weight: bold;
    cursor: pointer;
}

.candle {
    display: inline-block;
    width: 20px;
    height: 50px;
    margin: 0 6px;
    animation: flicker 1s infinite;
}

.candle-center {
    width: 24px;
    height: 60px;
}

#ritual {
    display: none;
    margin-top: 1.5rem;
    text-align: center;
}

#countdown {
    font-size: 1.3rem;
    margin-top: 0.8rem;
    color: #8b0000;
    font-weight: bold;
}

/* =====================
   КНОПКА ЗАГАДАТЬ ЖЕЛАНИЕ
   ===================== */

.curse-button {
    position: relative;
    padding: 12px 28px;
    font-size: 1.1rem;
    font-family: 'Courier New', Courier, monospace;
    color: #ff0000;
    background-color: #330000;
    border: 2px solid #660000;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.curse-button::before,
.curse-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 0, 0, 0.3);
    top: 0;
    left: 0;
    transform: skewX(-45deg) translateX(-100%);
    transition: all 0.5s ease;
}

.curse-button::after {
    background: rgba(255, 0, 0, 0.5);
    transition-delay: 0.2s;
}

.curse-button:hover {
    background-color: #660000;
    color: #fff;
    border-color: #ff0000;
    box-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000, 0 0 40px #ff0000;
}

.curse-button:hover::before,
.curse-button:hover::after {
    transform: skewX(-45deg) translateX(100%);
}

.blood-drip {
    position: absolute;
    width: 2px;
    height: 20px;
    background: #ff0000;
    bottom: -20px;
    animation: drip 1s infinite;
}

.blood-drip:nth-child(1) { left: 10%; animation-delay: 0.2s; }
.blood-drip:nth-child(2) { left: 30%; animation-delay: 0.4s; }
.blood-drip:nth-child(3) { left: 50%; animation-delay: 0.6s; }
.blood-drip:nth-child(4) { left: 70%; animation-delay: 0.8s; }
.blood-drip:nth-child(5) { left: 90%; animation-delay: 1s; }

/* =====================
   РИКРОЛЛ + КНОПКА ПРОПУСКА
   ===================== */

#rickroll-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#rickroll-video {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#rickroll-video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#skipRick {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0, 0, 0, 0.6);
    color: #ccc;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease, color 0.2s, border-color 0.2s;
    z-index: 10;
}

#skipRick.visible {
    opacity: 1;
    pointer-events: auto;
}

#skipRick:hover {
    color: #fff;
    border-color: #aaa;
    background: rgba(0, 0, 0, 0.8);
}

/* =====================
   СКРИМЕР
   ===================== */

#screamer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#screamer-video {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#screamer-video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* =====================
   ГАЛЕРЕЯ
   ===================== */

#gallery-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 2rem 1rem 3rem;
    box-sizing: border-box;
    animation: fadeIn 1s forwards;
}

#gallery-header {
    text-align: center;
    margin-bottom: 2rem;
}

#gallery-header h2 {
    font-size: 2rem;
    color: #ff4444;
    margin-bottom: 0.4rem;
}

.gallery-subtitle {
    font-size: 0.95rem;
    color: #666;
    margin: 0;
    font-style: italic;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 1100px;
}

.gallery-card {
    overflow: hidden;
    border-radius: 8px;
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    opacity: 0;
    animation: galleryCardIn 0.5s forwards ease-out;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-card:hover {
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

.gallery-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-empty {
    color: #555;
    font-style: italic;
    text-align: center;
    grid-column: 1 / -1;
    padding: 3rem 0;
}

/* =====================
   LIGHTBOX
   ===================== */

#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
}

#lightbox-img {
    position: relative;
    z-index: 1001;
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    object-fit: contain;
    animation: galleryCardIn 0.2s forwards;
}

#lightbox-close {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    z-index: 1002;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#lightbox-close:hover {
    opacity: 1;
    background-color: transparent;
}

#lightbox-prev,
#lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1002;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.8rem;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
}

#lightbox-prev { left: 1.2rem; }
#lightbox-next { right: 1.2rem; }

#lightbox-prev:hover,
#lightbox-next:hover {
    opacity: 1;
    background: rgba(0,0,0,0.7);
}

/* =====================
   ОБЩИЕ ЭЛЕМЕНТЫ
   ===================== */

#whiteOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 4s ease-in-out;
}

.hidden {
    animation: fadeOut 3s forwards;
}

.jumping-letter {
    display: inline-block;
    position: relative;
    animation: jump 1s infinite ease-in-out;
}

.blinking {
    animation: blink 1s infinite;
}

.cursed-click-1 {
    color: #ff4444;
    animation: pulse 1s infinite;
    text-shadow: 0 0 10px #ff4444;
    transform-origin: center;
}

.cursed-click-2 {
    color: #ff0000;
    animation: horror 0.5s infinite;
    text-shadow: 0 0 15px #ff0000, 0 0 25px #800000;
    letter-spacing: 2px;
}

.cursed-click-3 {
    color: #8b0000;
}

/* =====================
   АНИМАЦИИ
   ===================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

@keyframes drip {
    0%   { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(20px); opacity: 0; }
}

@keyframes jump {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25%       { transform: translateY(-20px) rotate(-10deg); }
    50%       { transform: translateY(0) rotate(0deg); }
    75%       { transform: translateY(-20px) rotate(10deg); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

@keyframes pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.1); text-shadow: 0 0 20px #ff4444; }
    100% { transform: scale(1); }
}

@keyframes horror {
    0%   { transform: translate(0, 0) skew(0deg); }
    25%  { transform: translate(-5px, 5px) skew(-5deg); color: #800000; }
    50%  { transform: translate(5px, -5px) skew(5deg);  color: #ff0000; }
    75%  { transform: translate(-3px, -3px) skew(-3deg); color: #660000; }
    100% { transform: translate(0, 0) skew(0deg); }
}

@keyframes galleryCardIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================
   СВИТОК — ПОЖЕЛАНИЯ И ЦИТАТЫ
   ===================== */

.scroll-wish {
    font-size: 0.95rem;
    color: #2a1000;
    line-height: 1.7;
    margin-bottom: 1rem;
    text-align: left;
}

.scroll-divider {
    text-align: center;
    color: #c8a050;
    font-size: 1.1rem;
    letter-spacing: 0.4rem;
    margin: 1.4rem 0 1rem;
    opacity: 0.8;
}

.scroll-section-title {
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.2rem;
    text-transform: uppercase;
    color: #8a6030;
    margin-bottom: 1rem;
}

/* Тикер цитат */
.quote-ticker-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin-bottom: 1rem;
    /* Fade по краям */
    mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

.quote-ticker {
    display: flex;
    gap: 1rem;
    width: max-content;
    animation: tickerScroll 40s linear infinite;
}

.quote-ticker:hover {
    animation-play-state: paused;
}

.quote-card {
    flex-shrink: 0;
    width: 260px;
    background: linear-gradient(135deg, #f0dca8, #e8d090);
    border: 1px solid #b07830;
    border-radius: 8px;
    padding: 0.9rem 1rem 0.9rem 1.4rem;
    position: relative;
    font-size: 0.83rem;
    color: #2a1000;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.quote-card p { margin: 0 0 0.3rem; }
.quote-card p:last-child { margin-bottom: 0; }

.quote-mark {
    position: absolute;
    top: 0.2rem;
    left: 0.45rem;
    font-size: 1.8rem;
    color: #ff4444;
    opacity: 0.7;
    line-height: 1;
    font-family: Georgia, serif;
}

.quote-caps {
    font-size: 0.75rem;
    letter-spacing: 0.05rem;
    color: #aa2200;
    font-weight: bold;
    margin-top: 0.3rem !important;
}

.quote-note {
    font-style: italic;
    color: #7a5020;
    font-size: 0.78rem;
}

.quote-dialog p { margin: 0.15rem 0; }

.quote-speaker {
    color: #8b2500;
    font-weight: bold;
}

@keyframes tickerScroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* =====================
   ФИНАЛЬНЫЙ БЛОК ГАЛЕРЕИ
   ===================== */

#gallery-footer {
    text-align: center;
    padding: 4rem 1rem 2rem;
    width: 100%;
    max-width: 600px;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#gallery-footer.visible {
    opacity: 1;
}

#gallery-footer-title {
    font-size: 2.2rem;
    color: #ff4444;
    margin-bottom: 0.8rem;
    animation: pulse 2s infinite;
}

.gallery-footer-wish {
    font-size: 1rem;
    color: #888;
    font-style: italic;
    margin-bottom: 2rem;
}

.restart-button {
    padding: 0.7rem 2rem;
    font-size: 1rem;
    font-family: 'Courier New', Courier, monospace;
    background: transparent;
    color: #666;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    letter-spacing: 1px;
}

.restart-button:hover {
    color: #ccc;
    border-color: #888;
    background: transparent;
}

/* =====================
   ИНДИКАТОР ПРОГРЕССА
   ===================== */

#progress-indicator {
    position: fixed;
    bottom: 1.4rem;
    right: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 500;
    animation: fadeIn 0.5s forwards;
}

.progress-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #444;
    transition: background 0.3s, transform 0.3s;
}

.progress-dot.active {
    background: #ff4444;
    transform: scale(1.5);
}
