body, html {
    height: 100%;
    min-height: 100vh; /* Добавлено для лучшей совместимости на мобильных */
    margin: 0;
    font-family: 'Roboto Mono', monospace;
    background-color: #0a0a0a;
    color: #f0f0f0;
}

.screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Изменено с height: 100% на min-height: 100vh */
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100; /* Добавлено для предотвращения перекрытия */
    transition: opacity 0.8s ease-in-out;
}

.start-content {
    text-align: center;
    animation: fadeIn 2s ease-in-out;
    position: relative; /* Added for positioning admin-link */
}



#start-screen-logo {
    max-width: 200px; /* Doubled from 100px */
    max-height: 200px;
    margin-bottom: 20px;
}

h1 {
    font-family: 'Tektur', sans-serif;
    font-size: 5rem;
    color: #c80000;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
    margin: 0;
}

.subtitle {
    font-size: 1.2rem;
    color: #a0a0a0;
    margin-top: -10px;
    letter-spacing: 2px;
    white-space: nowrap; /* Ensure text stays on one line */
    overflow: hidden; /* Hide overflow if text is too long */
    text-overflow: ellipsis; /* Add ellipsis for overflowed text */
}

.input-group {
    margin-top: 3em; /* Added for spacing */
    margin-bottom: 20px;
    text-align: center;
}

.input-group label {
    display: block;
    font-size: 1.1rem;
    color: #a0a0a0;
    margin-bottom: 8px;
}

.input-group input[type="text"] {
    background-color: #1a1a1a;
    border: 1px solid #444;
    color: #f0f0f0;
    padding: 10px 15px;
    font-size: 1.2rem;
    font-family: 'Roboto Mono', monospace;
    width: 250px;
    max-width: 80%; /* Ensure responsiveness */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #c80000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

#start-button, #restart-game-btn {
    font-family: 'Tektur', sans-serif;
    font-size: 1.5rem;
    margin-top: 40px;
    padding: 15px 30px;
    border: 2px solid #c80000;
    background-color: transparent;
    color: #c80000;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
}

#start-button:hover, #restart-game-btn:hover {
    background-color: #c80000;
    color: #0a0a0a;
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}

.hidden {
    display: none !important; /* Используем important, чтобы перебить другие display-свойства */
    opacity: 0;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#game-container {
    align-items: flex-start;
    padding-top: 50px;
}

.game-area {
    display: flex;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    border: 1px solid #333;
    background-color: #111;
}

.character-panel {
    flex: 1;
    padding: 20px;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#role-display {
    width: 100%;
    text-align: center;
    font-family: 'Tektur', sans-serif;
    font-size: 1.5rem;
    color: #ddd;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

#character-display {
    width: 250px;
    height: 150px;
    border: 2px solid #444;
    background-color: #000;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.character-body {
    width: 120px;
    height: 80px;
    background-color: #555;
    border-radius: 10px 40px 40px 10px;
}
.character-face {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #333;
    border: 2px solid #444;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    color: #c80000;
    margin-right: -10px;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.7);
}

#status-panel {
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #333;
    background-color: #0a0a0a;
    text-align: center;
}

#status-text {
    font-size: 1.2rem;
    color: #00ff00;
    margin: 0;
    font-weight: bold;
}
#status-description {
    font-size: 0.9rem;
    color: #00bfff;
    margin: 5px 0;
    min-height: 1.8rem;
}
#death-counter {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 10px;
}

.controls-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.control-section {
    margin-bottom: 20px;
}

.control-section h3 {
    font-family: 'Tektur', sans-serif;
    color: #c80000;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.items-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

.item-btn {
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    padding: 10px;
    border: 1px solid #444;
    background-color: #222;
    color: #ddd;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    text-align: center;
}
.item-btn:hover {
    background-color: #333;
    border-color: #666;
}
.item-btn.selected {
    background-color: #c80000;
    color: #0a0a0a;
    border-color: #ff4d4d;
}

.action-btn { /* Specific red styling for action buttons */
    font-family: 'Tektur', sans-serif;
    font-size: 1rem;
    padding: 10px;
    border: 1px solid #7a0000;
    background-color: #2a0000;
    color: #ff4d4d;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    text-align: center;
}
.action-btn:hover {
    background-color: #c80000;
    color: #0a0a0a;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
}

.action-btn:disabled {
    background-color: #1a1a1a;
    border-color: #333;
    color: #555;
    cursor: not-allowed;
}
.action-btn:disabled:hover {
    background-color: #1a1a1a;
    box-shadow: none;
}


#log-panel {
    flex-grow: 1;
    background-color: #0a0a0a;
    border: 1px solid #333;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column; /* Изменено на column */
    max-height: 400px; /* Добавлено для прокрутки */
}

.log-entry {
    background-color: #111;
    border: 1px solid #282828;
    padding: 8px;
    margin-bottom: 8px;
}
.log-entry .effect-name {
    font-weight: bold;
    color: #00ff00;
}
.log-entry .effect-components {
    color: #888;
    font-weight: normal;
    margin-left: 5px;
}
.log-entry .effect-desc {
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 5px;
}


/* Анимации */
.death-animation { animation: character-death 1.5s forwards; }
@keyframes character-death {
    0% { transform: rotate(0deg); opacity: 1; }
    50% { transform: rotate(-20deg) translateX(-50px); opacity: 0.8; }
    100% { transform: rotate(-90deg) translateX(-150px) translateY(100px); opacity: 0; }
}

.poison-animation { animation: poison-pulse 1s 2; }
@keyframes poison-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0); }
    50% { box-shadow: 0 0 25px 5px rgba(0, 255, 0, 0.7); }
}

.escape-animation { animation: character-escape 1.5s forwards; }
@keyframes character-escape {
    0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
    30% { transform: translateY(-50px) rotate(10deg) scale(1.05); opacity: 1; }
    100% { transform: translateY(-200px) rotate(30deg) scale(0.5); opacity: 0; }
}

/* --- Мобильная оптимизация --- */
@media (max-width: 768px) {
    body, html {
        overflow: auto;
        height: auto; /* Добавлено для лучшего поведения на мобильных */
    }
    .game-area {
        flex-direction: column;
        height: auto;
        border: none;
    }
    .character-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #333;
        padding: 10px;
        box-sizing: border-box;
    }
    .controls-panel {
        width: 100%;
        padding: 10px;
        box-sizing: border-box;
    }
    h1 {
        font-size: 3.5rem;
    }
    #character-display {
        width: 200px;
        height: 100px;
    }
    .character-body {
        width: 90px;
        height: 60px;
    }
    .character-face {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    #role-display {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    #status-text {
        font-size: 1rem;
    }
    #status-description {
        font-size: 0.8rem;
    }
    .item-btn {
        font-size: 1.2rem; /* Крупнее для пальцев */
        padding: 12px;
    }
    .control-section h3 {
        font-size: 1.2rem;
    }

    .story-content {
        width: 90%;
        padding: 15px;
    }
    #story-level-title {
        font-size: 2rem;
    }
    #story-text {
        font-size: 1rem;
    }
    #next-story-button {
        font-size: 1.2rem;
        padding: 10px 20px;
    }
}

/* End Screen Specific Styles */
.end-content {
    text-align: center;
    animation: fadeInScale 1.5s ease-out forwards; /* Initial animation for the whole screen */
    padding: 20px;
    max-width: 800px;
}

#end-image {
    max-width: 300px; /* Small enough as requested */
    height: auto;
    margin-bottom: 20px;
    animation: bounceIn 1.5s ease-out; /* Animation for the image */
}

.end-title {
    font-family: 'Tektur', sans-serif;
    font-size: 4rem;
    color: #00ff00; /* Green for success/completion */
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.7);
    margin-bottom: 10px;
    animation: pulseGlow 2s infinite alternate; /* Pulsing glow for title */
}

.end-subtitle { /* New style for the subtitle */
    font-size: 1.6rem; /* Slightly larger than end-message */
    color: #e0e0e0;
    margin-top: -5px; /* Pull it closer to the title */
    margin-bottom: 15px;
    line-height: 1.2;
    animation: fadeIn 2s ease-in-out 0.2s backwards; /* Slightly delayed fade in */
    font-family: 'Tektur', sans-serif; /* Use the Tektur font for impact */
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5); /* Subtle glow */
}

.end-message {
    font-size: 1.4rem;
    color: #e0e0e0;
    margin-bottom: 30px;
    line-height: 1.6;
    animation: fadeIn 2s ease-in-out 0.5s backwards; /* Delayed fade in for message */
}

.end-button {
    font-family: 'Tektur', sans-serif;
    font-size: 1.8rem;
    margin-top: 20px;
    padding: 18px 35px;
    border: 2px solid #00ff00; /* Green border */
    background-color: transparent;
    color: #00ff00;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
    animation: fadeIn 2s ease-in-out 1s backwards; /* Delayed fade in for button */
}

.end-button:hover {
    background-color: #00ff00;
    color: #0a0a0a;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.8);
}

.disclaimer {
    font-size: 0.8rem;
    color: #777;
    margin-top: 40px;
    animation: fadeIn 2s ease-in-out 1.5s backwards; /* Delayed fade in for disclaimer */
}

/* New Keyframe Animations */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bounceIn {
    0%, 20%, 40%, 60%, 80%, 100% {
        transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    }
    0% {
        opacity: 0;
        transform: scale3d(.3, .3, .3);
    }
    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }
    40% {
        transform: scale3d(.9, .9, .9);
    }
    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }
    80% {
        transform: scale3d(.97, .97, .97);
    }
    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Admin Link Styles */
#admin-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px; /* Example size, can be adjusted */
    height: 50px; /* Example size, can be adjusted */
    color: white; /* Make the emoji visible */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    opacity: 1; /* Make it completely visible for testing */
    z-index: 1000; /* Ensure it's on top of other elements */
    cursor: pointer;
}
.story-content {
    text-align: center;
    max-width: 700px;
    padding: 30px;
    background-color: #1a1a1a;
    border: 1px solid #333;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    animation: fadeIn 1.5s ease-in-out;
}

#story-level-title {
    font-family: 'Tektur', sans-serif;
    font-size: 3rem;
    color: #c80000; /* Используем тот же красный цвет, что и для заголовка */
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
    margin-bottom: 20px;
}

#story-text {
    font-size: 1.2rem;
    color: #e0e0e0;
    line-height: 1.6;
    margin-bottom: 30px;
    white-space: pre-wrap; /* Сохраняем форматирование переносов строк */
}

#next-story-button {
    font-family: 'Tektur', sans-serif;
    font-size: 1.5rem;
    padding: 15px 30px;
    border: 2px solid #c80000;
    background-color: transparent;
    color: #c80000;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
    letter-spacing: 1px;
}

#next-story-button:hover {
    background-color: #c80000;
    color: #0a0a0a;
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}