/* =========================================
   1. SETUP GENERALE & VARIABILI
   ========================================= */

@font-face {
    font-family: 'Minecraft';
    src: url('Minecraft.ttf') format('truetype');
}

:root {
    --blue-dark: #001D3D;
    --yellow-main: #FFD500;
    --stroke-light: #FFFB84; 
    --stroke-transparent: rgba(255, 251, 132, 0.4);
}

/* Reset universale */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Impostazioni Body + Cursore */
body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: 'Minecraft', sans-serif;
    background-color: #000;
    cursor: url('img/cursor.cur'), auto !important;
}

/* Cursore "manina" */
a, 
button, 
.pixel-btn, 
select, 
input[type="checkbox"], 
input[type="radio"],
label,
.lang-flag,
.credits-link,
.credits-link-corner,
.logo-above-box {
    cursor: url('img/pointer.cur'), pointer !important;
}

/* =========================================
   2. BACKGROUND & CORNICE
   ========================================= */

#dynamic-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 0;
    transition: background-image 0.5s ease;
}

#dynamic-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Cornice esterna (Tornata responsive) */
.site-frame {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    border: 4vh solid var(--blue-dark); /* Bordo proporzionale all'altezza */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: border-width 0.3s ease;
}

.content-wrapper {
    width: 100%;
    max-width: 1600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px 40px;
    position: relative;
}

/* =========================================
   3. ELEMENTI COMUNI
   ========================================= */

.triangle {
    width: 0; height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid var(--blue-dark);
    margin-left: 15px;
}
.triangle-left {
    width: 0; height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid var(--blue-dark);
    margin-right: 10px;
}
.triangle-right {
    width: 0; height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid var(--blue-dark);
    margin-left: 10px;
}

/* =========================================
   4. HOMEPAGE
   ========================================= */

.header-area {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 10px;
    height: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    max-width: 600px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 0 rgba(0,0,0,0.3));
    transition: filter 0.3s;
}
.logo:hover { filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.4)); }

.game-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 50px;
    flex-grow: 1;
    height: 70%;
}

.col-side {
    width: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--yellow-main);
    font-size: 22px;
    line-height: 1.5;
    text-shadow: 2px 2px 0 #000;
}
.underline { border-bottom: 2px solid var(--yellow-main); }
.left-text { align-items: flex-start; text-align: left; }
.left-text p { margin-bottom: 25px; }
.right-text { align-items: center; text-align: center; }

.lang-selector {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.lang-flag {
    width: 40px;
    height: auto;
    cursor: pointer;
    opacity: 0.6;
    transition: transform 0.2s, opacity 0.2s;
    border: 2px solid transparent;
}

.lang-flag:hover, .lang-flag.active {
    transform: scale(1.1);
    opacity: 1;
    border-color: var(--yellow-main);
}

.altar-box {
    width: 500px;
    height: 550px;
    background-color: var(--blue-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border: 4px solid #000;
    box-shadow: 0 0 50px rgba(0,0,0,0.6);
}
.sphere-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}
.sphere-img {
    width: 420px;
    height: 420px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(100, 200, 255, 0.2));
}

.btn-start {
    width: 100%;
    height: 80px;
    background-color: var(--yellow-main);
    border: 8px solid var(--stroke-transparent);
    color: var(--blue-dark);
    font-family: 'Minecraft';
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-clip: padding-box;
    margin-top: 10px;
}
.btn-start:hover { text-decoration: underline; }

.btn-cookie {
    margin-top: 20px;
    margin-bottom: 30px;
    background-color: var(--yellow-main);
    border: 6px solid var(--stroke-transparent);
    color: var(--blue-dark);
    font-family: 'Minecraft';
    font-size: 16px;
    padding: 12px 15px;
    cursor: pointer;
    background-clip: padding-box;
    white-space: nowrap;
    width: auto;
    min-width: 220px;
}
.btn-cookie:hover { text-decoration: underline; }

.credits-link {
    display: block;
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 30px;
}
.designer-logo {
    width: 180px;
    height: 170px;
    background-image: url('img/design-by-ds-white.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.1s;
}
.credits-link:hover .designer-logo { background-image: url('img/design-by-ds-color.png'); }

.clock-area {
    position: absolute;
    bottom: 20px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
}
#clock-icon {
    width: 160px;
    margin-bottom: 5px;
    transition: transform 0.2s;
}
#clock-time { font-size: 48px; color: #FFF; }
.clock-area:hover #clock-time { text-decoration: underline; }

/* =========================================
   5. PAGINA GIOCO & ALTRE
   ========================================= */

.header-top-right {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    height: 80px;
}

.clock-widget-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
}
.clock-widget-top #clock-icon { width: 100px; margin-bottom: 5px; }
.clock-widget-top #clock-time { font-size: 32px; color: #FFF; text-shadow: 2px 2px 0 #000; }
.clock-widget-top:hover #clock-time { text-decoration: underline; }

.game-container {
    display: flex;
    justify-content: center;
    align-items: flex-end; 
    gap: 60px;
    flex-grow: 1;
    margin-bottom: 40px;
    height: 100%;
}

.col-equal {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 420px;
    width: 100%;
}

.logo-above-box {
    display: block;
    text-align: center;
    margin-bottom: 20px;
    transition: transform 0.2s;
}
.logo-above-box:hover { transform: scale(1.02); }
.logo-above-box:hover .logo-img {
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.4));
}

.logo-img {
    width: 100%;
    max-width: 380px;
    height: auto;
    filter: drop-shadow(0 5px 0 rgba(0,0,0,0.3));
    transition: filter 0.3s;
}

.box-shared {
    width: 100%;
    height: 550px;
    border: 4px solid #000;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    padding: 25px;
    position: relative;
    transition: height 0.3s ease;
}

.altar-style {
    background-color: var(--blue-dark);
    justify-content: space-between;
}
.altar-style .sphere-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.altar-style .sphere-img {
    width: 90%;
    height: auto;
    object-fit: contain;
    max-height: 350px;
    transition: max-height 0.3s ease;
}

.btn-status {
    width: 100%;
    height: 70px;
    background-color: var(--yellow-main);
    border: 8px solid var(--stroke-transparent);
    color: var(--blue-dark);
    font-family: 'Minecraft';
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-clip: padding-box;
    cursor: default;
    pointer-events: none;
    margin-top: 10px;
    text-align: center;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
    display: inline-block;
    width: 20px;
    text-align: left;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.form-style {
    background-color: rgba(0, 29, 61, 0.9);
    border-color: var(--blue-dark);
    justify-content: space-between;
}
.form-intro {
    color: var(--yellow-main);
    font-size: 18px;
    margin-bottom: 20px;
    text-shadow: 1px 1px 0 #000;
    line-height: 1.4;
}

.input-group { margin-bottom: 15px; }
.input-group label {
    display: block;
    color: #FFF;
    font-size: 16px;
    margin-bottom: 5px;
}

.input-style {
    width: 100%;
    height: 45px;
    background-color: rgba(255, 213, 0, 0.15);
    border: 2px solid var(--yellow-main);
    color: var(--yellow-main);
    font-family: 'Minecraft';
    font-size: 18px;
    padding: 0 10px;
    outline: none;
    transition: background-color 0.2s, border-width 0.1s;
}

.input-style:focus { 
    background-color: rgba(255, 213, 0, 0.3);
    border-width: 4px;
}
.input-style:focus::placeholder { opacity: 0; transition: opacity 0.2s; }
.input-style::placeholder { color: rgba(255, 213, 0, 0.4); transition: opacity 0.2s; }

.date-inputs { display: flex; gap: 8px; }
.input-style.small { width: 60px; text-align: center; }
.input-style.medium { width: 90px; text-align: center; }

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    gap: 15px;
}
.btn-nav {
    height: 50px;
    width: 50%;
    background-color: var(--yellow-main);
    border: 4px solid var(--stroke-transparent);
    color: var(--blue-dark);
    font-family: 'Minecraft';
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background-clip: padding-box;
    transition: opacity 0.3s;
}
.btn-nav:not(.disabled):hover { text-decoration: underline; }
.btn-nav.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.credits-corner {
    position: absolute;
    bottom: 85px; 
    right: 85px;
    z-index: 10;
}
.credits-link-corner { display: block; width: 150px; height: 150px; }
.designer-logo-corner {
    width: 100%;
    height: 100%;
    background-image: url('img/design-by-ds-white.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.1s;
}
.credits-link-corner:hover .designer-logo-corner { background-image: url('img/design-by-ds-color.png'); }

/* =========================================
   CUSTOM SELECT
   ========================================= */

.custom-select-container {
    position: relative;
    width: 100%;
    font-family: 'Minecraft';
    font-size: 18px;
}

.select-selected {
    background-color: rgba(255, 213, 0, 0.15);
    border: 2px solid var(--yellow-main);
    color: var(--yellow-main);
    padding: 10px;
    cursor: pointer;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.select-selected.placeholder-active { color: rgba(255, 213, 0, 0.4); }
.select-selected.select-arrow-active {
    background-color: rgba(255, 213, 0, 0.3);
    border-width: 4px;
}

.select-selected:after {
    content: "";
    width: 0; height: 0;
    border: 6px solid transparent;
    border-top-color: var(--yellow-main);
    margin-left: 10px;
    transform: translateY(3px);
}
.select-selected.select-arrow-active:after {
    border-top-color: transparent;
    border-bottom-color: var(--yellow-main);
    transform: translateY(-3px);
}

.select-items {
    position: absolute;
    background-color: var(--blue-dark);
    border: 2px solid var(--yellow-main);
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0; right: 0;
    display: none;
}

.select-items.select-show { display: block; }

.select-items div {
    color: var(--yellow-main);
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 213, 0, 0.2);
}
.select-items div:last-child { border-bottom: none; }
.select-items div:hover {
    background-color: var(--yellow-main);
    color: var(--blue-dark);
}

/* =========================================
   TEXTAREA & ANSWER
   ========================================= */

textarea.input-style {
    height: 250px;
    resize: none;
    padding: 15px;
    line-height: 1.5;
    vertical-align: top;
}

.textarea-container { position: relative; width: 100%; }

.char-counter {
    position: absolute;
    bottom: 15px; right: 15px;
    font-size: 14px;
    color: var(--blue-dark);
    background-color: rgba(255, 213, 0, 0.1);
    padding: 2px 5px;
    pointer-events: none;
    font-weight: bold;
}

.answer-container {
    width: 100%;
    height: 350px;
    background-color: transparent;
    padding: 10px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ai-text {
    font-family: 'Minecraft', sans-serif;
    font-size: 20px;
    color: #FFFFFF;
    line-height: 1.6;
    text-shadow: 2px 2px 0px #000;
    white-space: pre-wrap;
}

.cursor-blink::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--yellow-main);
}
@keyframes blink { 50% { opacity: 0; } }

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-height: 900px), (max-width: 1440px) {
    .site-frame { border-width: 20px; }
    .content-wrapper { padding: 10px 20px; }
    .header-area { margin-top: 20px; }
    .logo { max-width: 380px; }
    .altar-box { width: 380px; height: 420px; padding: 10px; }
    .sphere-img { width: 280px; height: 280px; }
    .btn-start { height: 60px; font-size: 20px; border-width: 6px; }
    .col-side { font-size: 18px; width: 200px; }
    .left-text p { margin-bottom: 15px; }
    .btn-cookie { font-size: 14px; min-width: 180px; border-width: 4px; }
    .designer-logo { width: 100px; height: 100px; }
    .credits-link { margin-top: 15px; }
    #clock-icon { width: 100px; }
    #clock-time { font-size: 32px; }
    .game-container { gap: 30px; margin-bottom: 20px; }
    .col-equal { max-width: 360px; }
    .logo-img { max-width: 280px; }
    .logo-above-box { margin-bottom: 10px; }
    .box-shared { height: 440px; padding: 15px; }
    .altar-style .sphere-img { max-height: 250px; }
    .btn-status { height: 50px; font-size: 18px; border-width: 6px; }
    .form-intro { font-size: 16px; margin-bottom: 10px; }
    .input-group { margin-bottom: 10px; }
    .input-group label { font-size: 14px; margin-bottom: 3px; }
    .input-style { height: 35px; font-size: 16px; border-width: 2px; }
    .select-selected { height: 35px; font-size: 16px; border-width: 2px; }
    .select-selected.select-arrow-active { border-width: 2px; }
    .btn-nav { height: 40px; font-size: 16px; border-width: 3px; }
    .credits-corner { width: 100px; height: 100px; bottom: 50px; right: 50px; }
    textarea.input-style { height: 180px; }
    .answer-container { height: 250px; }
    .ai-text { font-size: 18px; }
}

@media (max-width: 1024px) {
    .header-area { flex-direction: column; height: auto; }
    .game-grid { flex-direction: column; height: auto; gap: 30px; padding-bottom: 100px; }
    .clock-area { position: static; margin-top: 30px; }
    .game-container { flex-direction: column; align-items: center; height: auto; padding-bottom: 50px; }
    .col-equal { max-width: 450px; width: 95%; }
    .box-shared { height: 550px; }
    .header-top-right { justify-content: center; margin-bottom: 10px; }
    .credits-corner { position: static; margin: 20px auto; display: flex; justify-content: center; }
}

/* =========================================
   MUSIC PLAYER (8-BIT STYLE)
   ========================================= */

.music-container {
    z-index: 1000;
}

.pixel-btn {
    background-color: var(--yellow-main);
    color: var(--blue-dark);
    border: 4px solid var(--blue-dark);
    font-family: 'Minecraft', sans-serif;
    font-size: 14px;
    padding: 8px 12px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 
        inset -4px -4px 0px 0px rgba(0,0,0,0.2), 
        4px 4px 0px 0px #000; 
    image-rendering: pixelated;
    outline: none;
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pixel-btn:active {
    box-shadow: inset 4px 4px 0px 0px rgba(0,0,0,0.2);
    transform: translateY(4px);
}

.pixel-btn:hover { background-color: #ffe033; }

.music-container.home-position {
    margin-top: 25px;
    display: flex;
    justify-content: flex-start;
}

.music-container.fixed-position {
    position: fixed;
    bottom: 30px;
    left: 30px;
}

@media (max-width: 1024px) {
    .music-container.fixed-position {
        bottom: 15px;
        left: 15px;
    }
}

/* =========================================
   SCROLLBAR 8-BIT
   ========================================= */

::-webkit-scrollbar {
    width: 18px; height: 18px;
}
::-webkit-scrollbar-track {
    background-color: var(--blue-dark);
    border: 4px solid #000;
    background-image: 
        linear-gradient(45deg, #000 25%, transparent 25%), 
        linear-gradient(-45deg, #000 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #000 75%), 
        linear-gradient(-45deg, transparent 75%, #000 75%);
    background-size: 8px 8px;
}
::-webkit-scrollbar-thumb {
    background-color: var(--yellow-main);
    border: 4px solid #000;
    box-shadow: inset 2px 2px 0px rgba(255,255,255,0.5), inset -2px -2px 0px rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:hover { background-color: #ffe033; }
::-webkit-scrollbar-corner { background-color: var(--blue-dark); }