/*
 * Adventure mode layout. Loaded after akhlak.css: it reuses that file's
 * question-card, button, toast and modal styles, and owns the fullscreen
 * canvas / HUD layout that the quiz page does not need.
 */

html,
body.adventure-body {
    width: 100%;
    height: 100%;
}

body.adventure-body {
    margin: 0;
    padding: 0;
    display: block;
    overflow: hidden;
    background: #bfe6f2;
    color: var(--text-color);
    font-family: var(--font-body);
    min-height: 100dvh;
}

#scene {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    background: linear-gradient(#bfe6f2, #eaf6ef);
}

/* ------------------------------------------------------------------ */
/* Overlay screens                                                     */
/* ------------------------------------------------------------------ */

.adv-screen {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 18px);
    background:
        radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.65), transparent 42%),
        radial-gradient(circle at 85% 88%, rgba(244, 208, 111, 0.3), transparent 45%),
        rgba(176, 222, 238, 0.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.adv-card {
    width: 100%;
    max-width: 560px;
    /* As a flex item, min-width:auto would keep the card at its min-content
       width and overflow narrow phones. */
    min-width: 0;
    margin: auto;
    background: var(--card-bg);
    border: 4px solid #e1ded4;
    border-radius: 28px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 18px 40px rgba(44, 62, 53, 0.22);
}

.adv-kicker {
    display: inline-block;
    margin-bottom: 10px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #eaf4ed;
    border: 2px solid #a4d0b3;
    color: var(--dark-green);
    font-size: var(--text-meta);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.adv-title {
    font-family: var(--font-display);
    color: var(--dark-green);
    font-size: var(--text-title);
    line-height: var(--leading-tight);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
    text-shadow: 2px 2px 0 var(--accent-yellow);
}

.adv-subtitle {
    font-size: var(--text-body);
    font-weight: 700;
    color: #5a6b60;
    margin: 0 0 20px;
    line-height: 1.45;
}

.adv-label {
    margin: 20px 0 10px;
    font-size: var(--text-meta);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #7c8f83;
}

.adv-start {
    display: block;
    width: 100%;
    margin-top: 20px;
    white-space: nowrap;
}

/* Character choice */

.gender-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.gender-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 96px;
    padding: 12px;
    background: #f7f9f6;
    border: 3px solid #d5e6db;
    border-radius: 18px;
    color: #5a6b60;
    font-family: var(--font-body);
    font-size: var(--text-small);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.gender-btn:hover {
    border-color: var(--primary-green);
    background: #f0f7f2;
}

.gender-btn.selected {
    border-color: var(--primary-green);
    background: #eaf4ed;
    color: var(--dark-green);
    box-shadow: 0 4px 0 #c7e0cf;
    transform: translateY(-1px);
}

.gender-emoji {
    font-size: 2.1rem;
    line-height: 1.1;
}

/* ------------------------------------------------------------------ */
/* HUD                                                                 */
/* ------------------------------------------------------------------ */

#hud {
    position: fixed;
    inset: 0;
    z-index: 30;
    pointer-events: none;
}

.adv-topbar {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 10px);
    left: calc(env(safe-area-inset-left) + 12px);
    right: calc(env(safe-area-inset-right) + 12px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid #d0e4d7;
    border-radius: 20px;
    box-shadow: 0 6px 18px rgba(44, 62, 53, 0.14);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
}

.adv-topbar .status-home,
.adv-topbar .sound-btn {
    width: var(--tap-min);
    height: var(--tap-min);
}

.adv-zone-badge {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dark-green);
    font-size: var(--text-meta);
    font-weight: 700;
}

.adv-progress-row {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 62px);
    left: calc(env(safe-area-inset-left) + 16px);
    right: calc(env(safe-area-inset-right) + 16px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.adv-progress-row .progress-track {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(44, 62, 53, 0.1);
}

.adv-station-label {
    flex: 0 0 auto;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--dark-green);
    font-size: var(--text-meta);
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(44, 62, 53, 0.1);
}

.adv-quest-card {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 88px);
    left: calc(env(safe-area-inset-left) + 12px);
    max-width: min(300px, calc(100vw - 24px));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 12px;
    background: rgba(255, 255, 255, 0.94);
    border: 2px solid #d0e4d7;
    border-left: 6px solid var(--primary-green);
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(44, 62, 53, 0.14);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.adv-quest-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.quest-compass {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding-left: 8px;
    border-left: 1px solid #e2efe6;
    color: var(--primary-green);
}

#questArrow {
    transition: transform 0.12s linear;
}

#questDistance {
    /* Updated every frame: compact HUD ticker, not reading text. */
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--dark-green);
    line-height: 1;
}

.adv-quest-kicker {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7c8f83;
}

#advQuestText {
    font-size: var(--text-small);
    font-weight: 700;
    color: var(--dark-green);
    line-height: var(--leading-snug);
}

/* Touch controls */

.joystick-zone {
    position: absolute;
    left: calc(env(safe-area-inset-left) + 18px);
    bottom: calc(env(safe-area-inset-bottom) + 22px);
    width: 124px;
    height: 124px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 22px rgba(44, 62, 53, 0.16);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    touch-action: none;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

.joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    border: 3px solid var(--primary-green);
    box-shadow: 0 4px 10px rgba(44, 62, 53, 0.22);
    transition: transform 0.08s ease-out;
}

.action-btn {
    position: absolute;
    right: calc(env(safe-area-inset-right) + 20px);
    bottom: calc(env(safe-area-inset-bottom) + 34px);
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: linear-gradient(135deg, #8fc9a2, var(--primary-green));
    color: #ffffff;
    font-size: 1.7rem;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--dark-green), 0 10px 20px rgba(44, 62, 53, 0.2);
    pointer-events: auto;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.action-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--dark-green);
}

.interact-prompt {
    position: absolute;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 158px);
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 999px;
    background: #fdf0c8;
    border: 2px solid #f0d98a;
    color: #7a5a00;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(44, 62, 53, 0.18);
    animation: promptPulse 1.6s ease-in-out infinite;
}

@keyframes promptPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.04); }
}

/* On touch screens the prompt just says "Tekan"; with a mouse/keyboard it
   spells out the E key so desktop players know how to interact. */
.interact-key {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .interact-key {
        display: inline-block;
        min-width: 1.6em;
        padding: 0.16em 0.42em;
        margin: 0 0.08em;
        border: 1.5px solid #d8b95d;
        border-radius: 0.35em;
        background: #fff8e2;
        box-shadow: 0 2px 0 #d8b95d;
        color: #6b4f00;
        font-family: inherit;
        font-size: 0.78em;
        font-weight: 700;
        line-height: 1.1;
        text-align: center;
        vertical-align: 0.08em;
    }
}

.desktop-hint {
    position: absolute;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(44, 62, 53, 0.5);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0.85;
}

@media (hover: none), (pointer: coarse) {
    .desktop-hint {
        display: none;
    }
}

@media (hover: hover) and (pointer: fine) {
    .joystick-zone {
        display: none;
    }
}

/* ------------------------------------------------------------------ */
/* Question overlay                                                    */
/* ------------------------------------------------------------------ */

.question-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(env(safe-area-inset-top) + 16px) 14px calc(env(safe-area-inset-bottom) + 16px);
    background: rgba(44, 62, 53, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.question-card {
    width: 100%;
    max-width: 680px;
    margin: auto;
    padding: 22px;
    background: var(--card-bg);
    border: 4px solid #e1ded4;
    border-radius: 26px;
    text-align: center;
    box-shadow: 0 22px 46px rgba(20, 32, 26, 0.32);
}

.question-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.question-npc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-display);
    font-size: var(--text-small);
    color: var(--dark-green);
}

.question-count {
    flex: 0 0 auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fdf0c8;
    border: 2px solid #f0d98a;
    color: #7a5a00;
    font-size: var(--text-meta);
    font-weight: 700;
}

.question-card .situation-img {
    max-height: 170px;
}

.question-card .situation-box {
    padding: 16px;
}

.situation-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 112px;
    margin-bottom: 15px;
    border: 2px solid #e2efe6;
    border-radius: 14px;
    background: #ffffff;
    color: #7c8f83;
    font-size: var(--text-small);
    font-weight: 700;
}

.situation-fallback span:first-child {
    font-size: 2.2rem;
    line-height: 1.1;
}

.question-card .options-container {
    gap: 10px;
    margin-bottom: 14px;
}

/* ------------------------------------------------------------------ */
/* Zone map                                                            */
/* ------------------------------------------------------------------ */

.zone-map-card {
    /* Wider than the other cards: zone names and descriptions share the row
       with an emoji tile and a status pill, so two columns need the room. */
    max-width: 760px;
    box-sizing: border-box;
}

.zone-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin: 18px 0 8px;
}

.zone-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "emoji copy status";
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 66px;
    padding: 10px 12px;
    box-sizing: border-box;
    background: #f7f9f6;
    border: 2px solid #d5e6db;
    border-radius: 16px;
    text-align: left;
    font-family: var(--font-body);
    color: var(--text-color);
    cursor: default;
}

.zone-card.current {
    background: #eaf4ed;
    border-color: var(--primary-green);
    box-shadow: 0 4px 0 #c7e0cf;
    cursor: pointer;
}

.zone-card.current:hover {
    transform: translateY(-2px);
}

.zone-card.locked {
    opacity: 0.55;
}

.zone-emoji {
    grid-area: emoji;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: #ffffff;
    border: 2px solid #e1ded4;
    font-size: 1.5rem;
}

.zone-copy {
    grid-area: copy;
    min-width: 0;
}

.zone-name {
    display: block;
    overflow-wrap: break-word;
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--dark-green);
}

.zone-meta {
    display: block;
    margin-top: 1px;
    font-size: var(--text-meta);
    font-weight: 700;
    color: #7c8f83;
}

.zone-status {
    grid-area: status;
    justify-self: end;
    padding: 4px 9px;
    border-radius: 999px;
    background: #ffffff;
    border: 2px solid #d5e6db;
    color: #7c8f83;
    font-size: var(--text-meta);
    font-weight: 700;
    white-space: nowrap;
}

.zone-card.current .zone-status {
    background: var(--primary-green);
    border-color: var(--dark-green);
    color: #ffffff;
}

@media (max-width: 719px) {
    /* On phones the status pill would squeeze the name and description into
       a narrow column, so it sits under the copy instead. */
    .zone-card {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "emoji copy"
            ". status";
        row-gap: 6px;
    }

    .zone-status {
        justify-self: start;
    }
}

@media (min-width: 720px) {
    .zone-list {
        /* minmax(0, …) lets the tracks shrink; plain 1fr keeps the cards'
           min-content width and pushes the second column out of the card. */
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .zone-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

/* ------------------------------------------------------------------ */
/* Zone complete / result                                              */
/* ------------------------------------------------------------------ */

.zone-complete-emoji,
.result-trophy {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 6px;
}

.zone-complete-card .adv-subtitle,
.result-card .adv-subtitle {
    white-space: pre-line;
}

.result-card .adv-title {
    font-size: var(--text-title);
}

/* ------------------------------------------------------------------ */
/* Toast, loading                                                      */
/* ------------------------------------------------------------------ */

.quiz-toast {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 112px);
    z-index: 90;
}

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(#bfe6f2, #eaf6ef);
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 30px;
    background: rgba(255, 255, 255, 0.94);
    border: 4px solid #e1ded4;
    border-radius: 24px;
    box-shadow: 0 16px 36px rgba(44, 62, 53, 0.2);
    color: var(--dark-green);
    font-weight: 700;
}

.loading-card p {
    margin: 0;
    font-size: var(--text-small);
}

.loading-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #d5e6db;
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: advSpin 0.8s linear infinite;
}

@keyframes advSpin {
    to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* Small screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 420px) {
    .adv-card {
        padding: 22px 18px;
        border-width: 3px;
        border-radius: 22px;
    }

    .adv-start {
        font-size: var(--text-option);
        padding: 15px 16px;
    }

    .question-card {
        padding: 16px;
        border-width: 3px;
        border-radius: 20px;
    }

    .question-card .situation-box {
        padding: 14px;
        margin-bottom: 14px;
    }

    .question-card .situation-img {
        max-height: 128px;
    }

    .question-card .option-btn {
        padding: 13px 14px;
    }

    .joystick-zone {
        width: 108px;
        height: 108px;
    }

    .joystick-knob {
        width: 50px;
        height: 50px;
        margin: -25px 0 0 -25px;
    }

    .action-btn {
        width: 62px;
        height: 62px;
        font-size: 1.5rem;
    }

    .interact-prompt {
        font-size: var(--text-meta);
        bottom: calc(env(safe-area-inset-bottom) + 152px);
    }

    .adv-quest-card {
        padding: 7px 10px;
    }

    #advQuestText {
        font-size: var(--text-small);
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .adv-quest-card {
        display: none;
    }

    .adv-progress-row {
        right: 46%;
    }
}
