@import url('https://fonts.googleapis.com/css2?family=Rubik+Gemstones&family=Rubik:wght@400;700&family=Assistant:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #051410;
    --card-bg: rgba(20, 40, 35, 0.65);
    --accent-primary: #00ffaa;
    /* Magic Cyan */
    --accent-secondary: #aa00ff;
    /* Magic Purple */
    --accent-gold: #ffd700;
    --text-primary: #e0f2f1;
    --text-secondary: #80cbc4;
    --border-color: rgba(0, 255, 170, 0.3);

    --font-heading: 'Rubik', sans-serif;
    /* Rubik Gemstones often English only, sticking to Rubik for Hebrew safety but styled */
    --font-body: 'Assistant', sans-serif;

    --shadow-glow: 0 0 15px rgba(0, 255, 170, 0.5);
    --text-glow: 0 0 10px rgba(0, 255, 170, 0.7);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: url('bck_level1.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    direction: rtl;
    position: relative;
}

/* Container */
.container {
    width: 100%;
    max-width: 900px;
    height: 95vh;
    display: flex;
    flex-direction: column;
    background: rgba(10, 20, 18, 0.90);
    /* Increased opacity for readability */
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Header */
header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 20, 15, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--accent-primary);
    text-shadow: var(--text-glow);
    letter-spacing: 1px;
}

.version {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-right: 8px;
    font-family: var(--font-body);
    font-style: normal;
    text-shadow: none;
    opacity: 0.8;
}

.level-indicator {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 6px 16px;
    border-radius: 20px;
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

#current-level {
    color: #fff;
    font-weight: bold;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#instructions-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    width: auto;
    height: auto;
    background: rgba(10, 20, 18, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid var(--accent-secondary);
    border-radius: 30px;
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    z-index: 200;
    /* Higher than container */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: 1rem;
}

#instructions-btn .btn-text {
    position: relative;
    z-index: 2;
}

#instructions-btn .btn-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(170, 0, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

#instructions-btn:hover {
    transform: translateY(-2px);
    border-color: #d187ff;
    color: #fff;
    box-shadow: 0 5px 20px rgba(170, 0, 255, 0.4);
}

#instructions-btn:hover .btn-glow {
    opacity: 1;
}

#instructions-btn svg {
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    width: 20px;
    height: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 170, 0.2);
}

.user-info.hidden {
    display: none;
}

.greeting {
    font-weight: 600;
}

#user-name {
    color: var(--accent-primary);
}

.turns-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--accent-gold);
    font-weight: bold;
}

.turns-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.turns-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Main Chat Area */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    background: transparent;
}

.chat-container {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 15px;
    max-width: 80%;
    animation: fadeIn 0.4s ease-out;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.system {
    align-self: flex-start;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border: 2px solid transparent;
}

.message.system .avatar {
    background: linear-gradient(135deg, #2d3436, #000000);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.3);
}

.message.user .avatar {
    background: linear-gradient(135deg, #4b0082, #2d004d);
    color: #fff;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(170, 0, 255, 0.3);
}

.content {
    background: rgba(10, 30, 25, 0.7);
    padding: 16px 22px;
    border-radius: 12px;
    font-size: 1.1rem;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    backdrop-filter: blur(5px);
}

.message.system .content {
    border-right: 3px solid var(--accent-primary);
    color: #e0f2f1;
}

.message.user .content {
    border-left: 3px solid var(--accent-secondary);
    background: rgba(30, 10, 40, 0.7);
    color: #fff;
}

/* Controls */
.controls {
    padding: 25px 35px;
    border-top: 1px solid var(--border-color);
    background: rgba(5, 20, 15, 0.8);
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

.input-group {
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--text-secondary);
    border-radius: 8px;
    padding: 6px;
    transition: all 0.3s;
}

.input-group:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.2);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 12px;
    resize: none;
    font-family: var(--font-body);
    font-size: 1.15rem;
    outline: none;
    max-height: 100px;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#send-btn {
    background: linear-gradient(135deg, var(--accent-secondary), #7e00b3);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(170, 0, 255, 0.3);
}

#send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(170, 0, 255, 0.6);
}

.password-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

#password-input {
    width: 33%;
    /* 1/3 width */
    flex: none;
    /* Disable flex growth */
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--text-secondary);
    color: var(--accent-gold);
    padding: 14px 18px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: bold;
    letter-spacing: 1px;
    outline: none;
    transition: all 0.3s;
}

#password-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-weight: normal;
}

#password-input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

#verify-btn {
    background: transparent;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 0 30px;
    height: 48px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
}

#verify-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    transform: translateY(-2px);
}

/* Error Animation for Button */
@keyframes shake-red {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-5px);
        background-color: rgba(255, 0, 0, 0.2);
        border-color: #ff3333;
        color: #ff3333;
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-5px);
    }

    80% {
        transform: translateX(5px);
    }
}

.btn-error {
    animation: shake-red 0.5s ease-in-out;
    background-color: rgba(255, 0, 0, 0.2) !important;
    border-color: #ff3333 !important;
    color: #ff3333 !important;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4) !important;
}

/* Footer */
footer {
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-body);
    background: rgba(0, 0, 0, 0.2);
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 10, 5, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(10, 30, 25, 0.9);
    border: 2px solid var(--accent-primary);
    padding: 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 80px rgba(0, 255, 170, 0.2), inset 0 0 30px rgba(0, 255, 170, 0.05);
    transform: translateY(0);
    transition: transform 0.3s;
    max-width: 500px;
}

.modal-content h2 {
    color: var(--accent-primary);
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(0, 255, 170, 0.8);
}

.modal-content.victory h2 {
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.modal-content.victory {
    border-color: var(--accent-gold);
}

.modal-content p {
    color: #e0f2f1;
    margin-bottom: 40px;
    font-size: 1.3rem;
}

.modal-content button {
    background: transparent;
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
    padding: 15px 40px;
    border-radius: 50px;
    font-weight: bold;
    font-family: var(--font-heading);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.2);
}

.modal-content button:hover {
    background: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 30px rgba(0, 255, 170, 0.6);
    transform: scale(1.05);
}

.modal-content.victory button {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.modal-content.victory button:hover {
    background: var(--accent-gold);
    color: #000;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

/* Instructions Modal Specifics */
.modal-content.instructions {
    max-width: 600px;
    text-align: right;
}

.instructions-text {
    text-align: right;
    margin-bottom: 30px;
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.8;
}

.instructions-text p {
    margin-bottom: 12px;
    color: #e0f2f1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 170, 0.2);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Blocking Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 2000;
    /* Higher than everything else */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.overlay-content {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 255, 170, 0.2);
    border-top: 5px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#error-overlay .overlay-content h2 {
    color: #ff3333;
    /* Generic error red, fitting dark theme */
    font-family: var(--font-heading);
    margin-bottom: 15px;
    font-size: 2rem;
}

#error-message {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.sub-error {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Finished Message */
.finished-message {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-gold);
    padding: 15px 25px;
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}