@font-face {
    font-family: 'EditorSerif';
    src: url('GameFonts/EditorSerif-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Narkiss Yair';
    src: url('GameFonts/NarkissYair-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

:root {
    --bg-color: #ffffff;
    --canvas-bg: #072439;
    --accent-color: #5b56a5;
    --secondary-color: #d8b2d4;
    --text-color: #1a1a1a;
    --panel-bg: rgba(0, 0, 0, 0.04);
    --panel-border: rgba(0, 0, 0, 0.1);
    --font-main: 'Narkiss Yair', sans-serif;
    --font-heading: 'Narkiss Yair', sans-serif;
    --font-hand: 'Narkiss Yair', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: #FFFFFF;
    overflow: hidden;
    box-sizing: border-box;
}

.canvas-wrapper {
    position: absolute;
    left: 50vw;
    top: 0;
    width: 50vw;
    height: 100vh;
    background-color: #072439;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#canvas-container {
    width: 32.4vw;
    height: 32.4vw;
    max-width: 85vh;
    max-height: 85vh;
    background: #072439;
    overflow: hidden;
    position: relative;
}

#main-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.controls-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 50vw;
    height: 100vh;
    background-color: #FFFFFF;
    box-sizing: border-box;
}

#controls {
    width: 100%;
    height: 100%;
    position: relative;
}

.step-indicator {
    position: absolute;
    top: 5.37vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1.3vw;
    direction: rtl;
}

.dot {
    width: 1.66vh;
    height: 1.66vh;
    border-radius: 50%;
    background: #ECB1FD;
    opacity: 0.5;
}

.dot.active {
    opacity: 1;
}

.control-group {
    display: none;
}

.control-group.active {
    display: block;
}

.control-group label {
    position: absolute;
    top: 31.66vh;
    left: 50%;
    transform: translateX(-50%);
    width: 80.2%;
    direction: rtl;
    text-align: right;
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 5.2vw;
    color: #072439;
    margin: 0;
    line-height: 1.2;
}

input[type="range"] {
    position: absolute;
    top: 65.18vh;
    left: 50%;
    transform: translateX(-50%);
    -webkit-appearance: none;
    appearance: none;
    width: 80.8%;
    height: 6vh;
    background: transparent;
    outline: none;
    cursor: pointer;
}

/* Chrome, Safari, Edge, Opera */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1.3vh;
    background: #072439;
    border-radius: 50px;
    border: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 5.55vh;
    height: 5.55vh;
    background: #072439;
    border-radius: 50%;
    margin-top: -2.125vh;
    border: none;
    box-shadow: none;
    transition: transform 0.2s ease;
}

/* Firefox */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 1.3vh;
    background: #072439;
    border-radius: 50px;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 5.55vh;
    height: 5.55vh;
    background: #072439;
    border: none;
    border-radius: 50%;
    box-shadow: none;
}

.navigation-bar {
    position: absolute;
    bottom: 5.46vh;
    left: 9.58%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.56vw;
    direction: ltr;
}

.nav-separator {
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 1.66vw;
    color: #ECB1FD;
    line-height: 1;
}

.nav-btn-text {
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 1.66vw;
    color: #ECB1FD;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn-text:hover:not(:disabled) {
    transform: scale(1.1);
}

.nav-btn-text:disabled {
    opacity: 0.2;
    cursor: default;
}

/* Summary Stage Styles */

#summary-stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease;
    padding-top: 1rem;
}

.summary-actions {
    position: absolute;
    top: 75vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2vw;
    width: 80.2%;
    justify-content: center;
}

.summary-feedback {
    position: absolute;
    top: 31.66vh;
    left: 50%;
    transform: translateX(-50%);
    width: 80.2%;
    margin: 0;
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 5.2vw;
    text-align: right;
    direction: rtl;
    line-height: 1.2;
    color: #072439;
}

.action-btn {
    background: #5C38F3;
    color: #FFFFFF;
    border: none;
    outline: none;
    padding: 2vh 4vw;
    border-radius: 50px;
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 1.8vw;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.action-btn:hover {
    background: #5C38F3;
    color: #FFFFFF;
    transform: scale(1.05);
}

.action-btn.secondary {
    background: #ECB1FD;
    color: #FFFFFF;
    border: none;
    outline: none;
}

.action-btn.secondary:hover {
    background: #ECB1FD;
    color: #FFFFFF;
    transform: scale(1.05);
}

#qr-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #fff;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 100;
    text-align: center;
    border: 4px solid #000;
}

.qr-box img {
    width: 120px;
    height: 120px;
}

.qr-box p {
    font-size: 0.7rem;
    margin-top: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
}

#thanks-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 5rem;
    color: var(--accent-color);
    letter-spacing: 0.2rem;
}

.action-bar {
    position: absolute;
    pointer-events: none;
    visibility: hidden;
}

#reset-btn, #print-btn {
    font-family: var(--font-heading);
    padding: 0.6rem 1.5rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.75rem;
}

#reset-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: transparent;
    border: 1px solid #ffffff;
    color: #ffffff;
    z-index: 1000;
    visibility: visible;
    pointer-events: auto;
}

#print-btn {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

#feedback-container {
    width: 100%;
    text-align: center;
    min-height: 2rem;
}

.feedback-he {
    font-family: var(--font-hand);
    font-size: 1.6rem;
    font-weight: 700;
    direction: rtl;
    color: #000;
}

.hidden {
    display: none !important;
}

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

/* Step 5 Next Button Static Label */
#next-step {
    position: relative;
}



/* QR Modal Styles */
#qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.qr-modal-content {
    background: #ffffff;
    padding: 2rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

#qr-code-container {
    padding: 1rem;
    background: #fff;
}

.qr-modal-content p {
    font-family: 'Narkiss Yair', sans-serif;
    font-size: 1.2rem;
    color: #000;
}

#close-qr-btn {
    font-family: 'Narkiss Yair', sans-serif;
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 1rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 0.5rem;
}

/* Loading Overlay Styles */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #072439;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
}

.p5-container {
    width: 150px;
    height: 150px;
    position: relative;
}

/* Mobile Portrait UI Overrides */
@media screen and (max-width: 480px) and (orientation: portrait) {
    body {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    #app {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    .canvas-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 40dvh;
    }

    #canvas-container {
        width: 32dvh;
        height: 32dvh;
        max-width: 80vw;
        max-height: 80vw;
    }

    .controls-panel {
        position: absolute;
        top: 40dvh;
        left: 0;
        width: 100vw;
        height: 60dvh;
        overflow: hidden;
    }

    .loading-overlay {
        height: 100dvh;
    }

    /* Compressing steps content inside controls panel */
    .step-indicator {
        top: 2dvh;
    }

    .control-group label {
        top: 8dvh;
        font-size: 6.5vw;
        width: 85%;
    }

    input[type="range"] {
        top: 26dvh;
        width: 85%;
        height: 5vh;
    }

    .navigation-bar {
        position: absolute;
        top: auto;
        bottom: 2dvh;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        gap: 1.5vh;
        margin-top: 0;
        margin-bottom: 0;
        width: 80.2%;
    }

    .nav-separator {
        display: none;
    }

    .nav-btn-text {
        font-size: 5vw;
        width: 100%;
        text-align: center;
    }

    /* Summary Stage Overrides */
    .summary-feedback {
        top: 8dvh;
        font-size: 6.5vw;
        width: 85%;
    }

    .summary-actions {
        position: absolute;
        top: auto;
        bottom: 2dvh;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        gap: 1.5vh;
        width: 80.2%;
        margin-top: 0;
        margin-bottom: 0;
    }

    .action-btn {
        width: 100%;
        text-align: center;
        font-size: 4.5vw;
        padding: 1.5vh 4vw;
    }
}
