/* Local Font Hosting for Fredoka Variable Font */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-stretch: 100%;
  font-display: swap;
  src: url('./fonts/fredoka.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* CSS Variables for Cartoon Theme */
:root {
    --bg-color-main: #fffae3; /* Vibrant light yellow */
    --bg-color-alt: #e3f2fd; /* Light vibrant blue */
    --text-dark: #1e1e24; /* Very dark blue/charcoal for text */
    --primary-color: #ff6b6b; /* Cartoon red/pink */
    --primary-hover: #ff5252;
    --secondary-color: #4ecdc4; /* Cartoon teal */
    --secondary-hover: #45b7aa;
    --card-bg: #ffffff;
    --shadow: 0 8px 16px rgba(0,0,0,0.1);
    --border-radius: 20px;
    --font-main: 'Fredoka', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--bg-color-main), var(--bg-color-alt));
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* App Container */
#app {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
    overflow: hidden;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

@media screen and (orientation: portrait) {
    body.is-mobile #app.landscape-required > #rotate-overlay { display: flex !important; }
    body.is-mobile #app.landscape-required > .screen { display: none !important; }
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Hide by default */
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

/* UI Auto-Hide feature */
.game-ui {
    transition: opacity 0.5s ease;
}

.ui-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Typography */
h1, h2, h3 {
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: var(--text-dark);
    opacity: 0.8;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    text-align: center;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary { background-color: var(--primary-color); }
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary { background-color: var(--secondary-color); }
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    width: auto;
}

.btn-map-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    min-width: 70px;
    min-height: 70px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 5px;
    text-align: center;
    font-weight: bold;
}
.btn-map-nav .nav-arrow {
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
}

/* Authentication Screen */
#screen-auth {
    justify-content: flex-start;
    align-items: center;
}

.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    border: 3px solid var(--text-dark); /* Cartoon outline */
    margin: auto;
}

.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.2s;
}

.tab-btn.active {
    opacity: 1;
    border-bottom: 3px solid var(--primary-color);
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #ddd;
    font-family: var(--font-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.screen.map-level {
    padding: 0;
    gap: 0;
}

/* Map Screen */
.map-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.map-header * {
    pointer-events: auto;
}

.map-header h2,
.map-header .streak-counter {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border: 2px solid var(--text-dark);
    margin: 0;
}

.map-header .btn {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.map-header .btn-mute {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.header-left, .header-right {
    flex: 1;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
}

.map-header h2 {
    font-size: 1.4rem;
}

/* Responsive Map Header for narrow screens */
@media screen and (max-width: 768px) {
    .map-header {
        padding: 5px;
    }
    .map-header h2 {
        font-size: 0.95rem;
        padding: 4px 8px;
    }
    .map-header .streak-counter {
        font-size: 0.85rem;
        padding: 4px 8px;
    }
    .map-header .btn {
        font-size: 0.75rem;
        padding: 4px 8px;
        min-width: 70px !important;
    }
    .header-left {
        gap: 5px !important;
    }
    .user-stats {
        gap: 5px !important;
    }
}

.user-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
}

.header-buttons-stacked {
    display: flex;
    flex-direction: column;
    gap: 5px;
}



.btn-image-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(43, 45, 66, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}

.btn-image-nav:hover {
    background: rgba(43, 45, 66, 1);
}

#btn-img-prev {
    left: 10px;
}

#btn-img-next {
    right: 10px;
}

.map-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
}

.map-content {
    position: relative;
    width: 100%;
    height: 200%;
    background-position: top center;
    background-repeat: repeat-y;
}

#screen-map-1 .map-content { background-image: url("Orthoptics%20Street.png"); background-size: 100% 100%; height: 100%; }
#screen-map-2 .map-content { background-image: url("Eye%20Town.jpeg"); background-size: 100% 100%; height: 100%; }
#screen-map-3 .map-content { background-image: url("Squint%20Quay1.png"); background-size: 100% 100%; height: 100%; }

.map-path {
    position: absolute;
    top: 0;
    height: 100%;
    left: 0;
    width: 100%;
    z-index: 1;
}

.stage-node {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, z-index 0s;
}
.stage-node:hover {
    z-index: 10;
}
.stage-node.locked {
    filter: grayscale(100%);
    cursor: not-allowed;
    opacity: 0.7;
}

.invisible-node {
    opacity: 0 !important;
}

.transition-hotspot {
    width: 60px;
    height: 150px;
    position: absolute;
    transform: translate(-50%, -50%);
}

.transition-hotspot-horizontal {
    width: 119px;
    height: 38px;
    position: absolute;
    transform: translate(-50%, -50%);
}

.node-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    transition: all 0.3s ease;
    position: relative;
}

/* --- Magical Glowing Rings --- */
@keyframes breatheGlowingRing {
    0% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.4), inset 0 0 10px rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.6);
        border-color: rgba(255, 255, 255, 0.9);
    }
    100% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.4), inset 0 0 10px rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.4);
    }
}

@keyframes pulseGlowingRingHover {
    0% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.6);
        border-color: rgba(255, 255, 255, 1);
        transform: scale(1.15);
    }
    50% {
        box-shadow: 0 0 35px rgba(255, 255, 255, 1), inset 0 0 30px rgba(255, 255, 255, 0.9);
        border-color: rgba(255, 255, 255, 1);
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.6);
        border-color: rgba(255, 255, 255, 1);
        transform: scale(1.15);
    }
}

.node-icon {
    background-color: transparent !important;
    animation: breatheGlowingRing 3s infinite ease-in-out;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.stage-node:not(.locked):hover .node-icon {
    animation: pulseGlowingRingHover 1.5s infinite ease-in-out;
    background-color: transparent !important;
}

/* --- Signboard Transit Nodes --- */

/* Base reset for all signboard icons */
#node-exit1 .node-icon,
#node-entry2 .node-icon,
#node-exit2 .node-icon,
#node-entry3 .node-icon {
    border-radius: 0;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    position: relative;
    animation: none !important;
}
#node-exit1.stage-node:not(.locked):hover .node-icon,
#node-entry2.stage-node:not(.locked):hover .node-icon,
#node-exit2.stage-node:not(.locked):hover .node-icon,
#node-entry3.stage-node:not(.locked):hover .node-icon {
    animation: none !important;
}

/* Common ::before for all signboard icons */
#node-exit1 .node-icon::before,
#node-entry2 .node-icon::before,
#node-exit2 .node-icon::before,
#node-entry3 .node-icon::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: 100% 100%;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.6));
    transition: all 0.3s ease;
    animation: pulseArrowGlow 3s infinite ease-in-out;
}
#node-exit1.stage-node:not(.locked):hover .node-icon::before,
#node-entry2.stage-node:not(.locked):hover .node-icon::before,
#node-exit2.stage-node:not(.locked):hover .node-icon::before,
#node-entry3.stage-node:not(.locked):hover .node-icon::before {
    animation: pulseArrowGlowHover 1.5s infinite ease-in-out;
}

/* 1. Map 1 Exit (Orthoptic Forest) - Option 1: Responsive Distortion */
#node-exit1 .node-icon { width: 11vw; height: 6vh; margin-left: 1.5vw; }
#node-exit1 .node-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Crect x='0' y='0' width='100' height='100' rx='5' ry='5' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='3' vector-effect='non-scaling-stroke' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 2. Map 2 Entry (Orthoptic Clinic) - Option 1: Responsive Distortion */
#node-entry2 .node-icon { width: 16vw; height: 12vh; margin-top: 1.85vh; margin-left: -1.8vw; }
#node-entry2 .node-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Crect x='0' y='0' width='100' height='100' rx='5' ry='5' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='3' vector-effect='non-scaling-stroke' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 3. Map 2 Exit (Orthoptics City) - Option 1: Responsive Distortion */
#node-exit2 .node-icon { width: 14vw; height: 10vh; margin-left: -1vw; margin-top: 1.5vh; }
#node-exit2 .node-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Crect x='0' y='0' width='100' height='100' rx='5' ry='5' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='3' vector-effect='non-scaling-stroke' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* 4. Map 3 Entry (Orthoptic forest) - Option 1: Responsive Distortion */
#node-entry3 .node-icon { width: 11vw; height: 8.5vh; margin-left: 2.5vw; margin-top: 1vh; }
#node-entry3 .node-icon::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Crect x='0' y='0' width='100' height='100' rx='5' ry='5' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='3' vector-effect='non-scaling-stroke' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@keyframes pulseArrowGlow {
    0% { filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); opacity: 0.5; }
    50% { filter: drop-shadow(0 0 12px rgba(255,255,255,0.8)); opacity: 0.8; }
    100% { filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); opacity: 0.5; }
}

@keyframes pulseArrowGlowHover {
    0% { filter: drop-shadow(0 0 8px rgba(255,255,255,0.8)); opacity: 0.8; }
    50% { filter: drop-shadow(0 0 20px rgba(255,255,255,1)) drop-shadow(0 0 10px rgba(255,255,255,0.6)); opacity: 1; }
    100% { filter: drop-shadow(0 0 8px rgba(255,255,255,0.8)); opacity: 0.8; }
}

/* --- Flowing Energy Paths --- */
@keyframes flowPathEnergy {
    to { stroke-dashoffset: -28; }
}

.map-path path {
    stroke: rgba(255, 245, 200, 0.9); /* Golden-white */
    stroke-width: 2.5px;
    stroke-dasharray: 8, 6;
    animation: flowPathEnergy 1s linear infinite;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

.stage-label {
    position: absolute;
    bottom: 100%;
    margin-bottom: 5px;
    white-space: nowrap; /* Keep shorter labels on one line, or use text-align if wrapping is needed */
    width: max-content;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--text-dark);
    padding: 4px 10px;
    border-radius: 20px;
    border: 2px solid var(--text-dark);
    font-size: 0.85rem;
    font-weight: 800;
    pointer-events: auto;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Positions for nodes on horizontal 100x100 grid */
.node-1a, .node-2a, .node-3a, .node-entry2, .node-entry3 {
    top: 50%;
    left: 15%;
    transform: translate(-50%, -50%);
}

.node-1b, .node-2b, .node-3b {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.node-2b {
    top: 75%;
}

.node-exit1, .node-exit2, .node-exit3 {
    top: 50%;
    left: 85%;
    transform: translate(-50%, -50%);
}

.player-avatar {
    position: absolute;
    z-index: 3;
    font-size: 2.5rem;
    top: 50%;
    left: 15%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.cinematic-vehicle {
    position: absolute;
    z-index: 4;
    width: 60px;
    height: auto;
    top: 50%;
    transform: translate(-50%, -50%);
}

.drive-in {
    animation: driveInAnim 2s forwards;
}

.drive-out {
    animation: driveOutAnim 2s forwards;
}

@keyframes driveInAnim {
    0% { left: -20%; }
    100% { left: 85%; }
}

@keyframes driveOutAnim {
    0% { left: 85%; }
    100% { left: 120%; }
}

.bg-sakura { background-color: #ffb7b2; background-size: cover; background-position: center; position: relative; }
.bg-gate { background-color: #ffb7b2; background-size: cover; background-position: center; position: relative; }
.bg-bus { background-color: #a8e6cf; background-size: cover; background-position: center; position: relative; }

/* Game Screen */
#screen-game {
    padding: 0; /* Full screen */
    overflow: hidden;
    touch-action: none;
    background: #ffffff;
}

.game-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.btn-back {
    background: var(--card-bg);
    color: var(--text-dark);
    border: 2px solid var(--text-dark);
}

.timer-container {
    background: var(--text-dark);
    color: white;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.stage-info {
    background: var(--card-bg);
    color: var(--text-dark);
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: 700;
    border: 2px solid var(--text-dark);
}

.canvas-container {
    flex: 1;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#game-image-left, #game-image-right {
    position: absolute;
    height: 85vh;
    width: auto;
    object-fit: contain;
    pointer-events: none;
    mix-blend-mode: multiply;
}


.controls-overlay {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 1000; /* Ensure above canvas */
}

.controls-overlay .btn {
    padding: 10px; 
    font-size: 1.5rem; 
    width: 60px; 
    height: 60px;
    border-radius: 30px; /* Make them perfect circles */
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Landscape Mode Adjustments for Stereogram Training */
@media (orientation: landscape) {
    #screen-game {
        padding: 0;
        flex-direction: row;
    }
    
    .game-header {
        position: absolute;
        top: 10px;
        left: 0;
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding: 0 15px;
        z-index: 110;
        pointer-events: none; /* Let clicks pass through to canvas */
    }
    
    .game-header * {
        pointer-events: auto; /* Re-enable clicks on header buttons */
    }
    
    .controls-overlay {
        position: absolute;
        bottom: 10px;
        top: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 15px;
        z-index: 1000;
    }

    .controls-overlay .btn {
        padding: 10px; 
        font-size: 1.5rem; 
        width: 50px; 
        height: 50px;
        border-radius: 25px; /* Make them perfect circles */
        display: flex;
        justify-content: center;
        align-items: center;
        white-space: nowrap;
    }
    
    .canvas-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 50;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    /* #game-image sizing is handled globally now */
    
    /* Focus Mode overrides */
    .focus-mode #cheerful-decorations {
        display: none !important;
    }
    .focus-mode #game-image {
        width: 100%;
        height: 100%;
    }
    
    #btn-img-prev {
        left: 10px;
    }
    
    #btn-img-next {
        right: 10px; 
    }
}

.btn-debug {
    background-color: #ffd166;
    color: var(--text-dark);
}

/* Toast Notification */
#notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    border: 3px solid var(--text-dark);
    animation: slideDown 0.3s ease;
}

#notification.success {
    background: var(--secondary-color);
}

#notification.warning {
    background: #ffd166;
    color: var(--text-dark);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { transform: translate(-50%, -100%); }
    to { transform: translate(-50%, 0); }
}

@keyframes bounceWiggle {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(-5deg); }
    50% { transform: translateY(0) rotate(0deg); }
    75% { transform: translateY(-10px) rotate(5deg); }
}

.bounce-wiggle {
    animation: bounceWiggle 1s ease-in-out infinite;
}

/* Avatar Selector */
.avatar-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.avatar-selector label {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 50%;
    padding: 5px;
    transition: transform 0.2s, border-color 0.2s;
}

.avatar-selector input[type="radio"] {
    display: none;
}

.avatar-selector img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    box-shadow: var(--shadow);
}

.avatar-selector input[type="radio"]:checked + img {
    border: 3px solid var(--primary-color);
    transform: scale(1.1);
}

.avatar-selector label:hover {
    transform: translateY(-2px);
}

/* Background images for map nodes */
.bg-farm {
    background-color: #a8e6cf;
    background-size: cover;
    background-position: center;
    position: relative;
}

.bg-city {
    background-color: #a1c9f2;
    background-size: cover;
    background-position: center;
    position: relative;
}

.bg-castle {
    background-color: #a1c9f2;
    background-size: cover;
    background-position: center;
    position: relative;
}

.lock-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.lock-overlay svg {
    width: 26px;
    height: 26px;
    fill: white;
}

img.player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    background: transparent;
    border: none;
    box-shadow: none;
}


/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 350px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    border: 3px solid var(--text-dark);
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    border-radius: 10px;
    border: 2px solid #ddd;
    font-size: 1rem;
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

/* --- Progress Report Screen --- */
.progress-container {
    padding: 20px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.progress-view {
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.progress-view.active {
    display: flex;
}

/* Calendar Styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h3 {
    font-size: 1.5rem;
    color: #2b2d42;
    margin: 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 20px;
}

.day-name {
    text-align: center;
    font-weight: bold;
    color: #8d99ae;
    font-size: 0.9rem;
    padding-bottom: 5px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 1.1rem;
    color: #2b2d42;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.active-day {
    background: #ef233c;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(239, 35, 60, 0.3);
}

.calendar-day.active-day:active {
    transform: scale(0.95);
}

.calendar-day.selected {
    border-color: #2b2d42;
    border-radius: 4px;
}

.compact-calendar {
    gap: 4px;
    margin-bottom: 0;
}
.compact-calendar .calendar-day {
    border-radius: 4px;
    font-size: 1rem;
}
.compact-calendar .day-name {
    font-size: 0.85rem;
}
.compact-calendar .calendar-day.active-day {
    font-weight: bold;
    box-shadow: none;
}

.day-details {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    text-align: center;
    margin-top: auto;
}

.day-details h4 {
    margin: 0 0 15px 0;
    color: #2b2d42;
}

.day-details p {
    margin: 5px 0;
    font-size: 1.1rem;
    color: #555;
}

/* Summary Styles */
.summary-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    text-align: center;
    border-left: 5px solid #ffb703;
}

.summary-card h3 {
    margin: 0 0 10px 0;
    color: #8d99ae;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-number {
    margin: 0;
    font-size: 2.5rem;
    font-weight: bold;
    color: #2b2d42;
}

/* --- Bubble Menus --- */
.bubble-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px 20px;
    height: 100%;
}

.bubble-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.bubble-link {
    text-decoration: none;
    display: block;
}

.bubble-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 20px;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    z-index: 100;
}

.bubble-small {
    width: 115px;
    height: 115px;
    background: #ffb703;
}

.bubble-rect {
    width: 90%;
    max-width: 280px;
    height: 85px;
    border-radius: 20px;
}

.menu-bg-farm {
    background: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url('farm_node_v2.png') no-repeat center center;
    background-size: cover;
}

.menu-bg-city {
    background: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url('city_node_v2.png') no-repeat center center;
    background-size: cover;
}

.menu-bg-calibrate {
    background: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url('calibrate_node_v4.png') no-repeat center center;
    background-size: cover;
}

.menu-bg-alarm {
    background: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)), url('clock_bg.png') no-repeat center center;
    background-size: cover;
}

.bubble-alt {
    background: #8ecae6;
}

.bubble-btn:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 25px rgba(0,0,0,0.2);
}

.bubble-btn:active {
    transform: translateY(2px) scale(0.95);
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
}

.bubble-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-dark);
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
    z-index: 2;
}

.bubble-small .bubble-text {
    font-size: 0.95rem;
}

.bubble-text-dark {
    color: #000000;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.9);
}

/* Rotate Overlay */
#rotate-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-color);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}
.rotate-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    border: 4px solid var(--text-dark);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.rotate-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 20px;
    animation: rotate 2s infinite linear;
}
.progress-container {
    padding: 20px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media screen and (orientation: landscape) {
    #screen-game .game-header { top: 10px; }
    #screen-game .controls-overlay { bottom: 10px; transform: scale(0.9) translateX(-55%); }
    .timer-container { padding: 4px 15px; font-size: 1.2rem; }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-20px); }
}

/* Global Mute Button */
.global-mute-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #2b2d42;
    color: #2b2d42;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.global-mute-btn:hover {
    transform: scale(1.1);
    background: #fff;
}

.global-mute-btn:active {
    transform: scale(0.95);
}

/* Embedded Mute Button */
.btn-mute {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #2b2d42;
    color: #2b2d42;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    margin: 0;
    padding: 0;
}

.btn-mute:hover {
    transform: scale(1.1);
    background: #fff;
}

.btn-mute:active {
    transform: scale(0.95);
}

/* Scroll Indicator Styles */
@keyframes bounce-down {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
    40% { transform: translateX(-50%) translateY(-10px); }
    60% { transform: translateX(-50%) translateY(-5px); }
}

.scroll-indicator {
    animation: bounce-down 2s infinite;
}

/* Custom Scrollbar */
.screen::-webkit-scrollbar {
    width: 8px;
}
.screen::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}
.screen::-webkit-scrollbar-thumb {
    background: rgba(43, 45, 66, 0.4);
    border-radius: 10px;
}
.screen::-webkit-scrollbar-thumb:hover {
    background: rgba(43, 45, 66, 0.7);
}


/* Base CSS for Progress Layout (extracted from inline styles) */
.progress-header { padding: 20px; }
.progress-view-layout { flex-direction: row; flex-wrap: nowrap; gap: 20px; }
.calendar-left-pane { flex: 0 0 50%; min-width: 0; }
.progress-day-details { flex: 0 0 calc(50% - 20px); gap: 15px; }
.progress-stats-container { gap: 15px; }
.progress-detail-box { padding: 15px; font-size: 1.1rem; }
.progress-stat-card { padding: 15px; }

/* Default Mobile Layout (Readable Side-by-Side with Scrolling) */
@media screen and (max-width: 768px) {
    #view-calendar {
        flex-direction: row !important; /* Force side-by-side */
    }
    .progress-view-layout { gap: 10px; }
    .calendar-left-pane { flex: 0 0 50% !important; max-width: 50%; } 
    .progress-day-details { flex: 0 0 calc(50% - 10px) !important; max-width: calc(50% - 10px); gap: 10px; }
    
    .calendar-header h3 { font-size: 1rem !important; margin: 5px 0 !important; }
    .calendar-day { aspect-ratio: auto !important; height: 5vh !important; font-size: 0.8rem !important; display: flex; align-items: center; justify-content: center; }
    .day-name { font-size: 0.7rem !important; }
    
    .progress-detail-box { padding: 10px !important; font-size: 0.9rem !important; border-width: 2px !important; border-radius: 6px !important; }
    .progress-stat-card { padding: 8px 10px !important; border-left-width: 4px !important; border-radius: 6px !important; }
    #stat-month, #stat-freq { font-size: 1.1rem !important; margin: 0 !important; }
}



/* === GLOBAL INVISIBLE GLASS STAGE NODES === */
.stage-label {
    transition: transform 0.2s ease;
}
.stage-node:not(.locked):hover .stage-label {
    /* Stable label, no transform on hover */
}

/* Base hover scaling applied above per-map */
/* Ensure all stage labels are visible on map */
.stage-label {
    opacity: 1 !important;
}

/* Mobile Scaling for Signboard Arrows */
/* Removed media query entirely, we are no longer using static scales! */

/* Rectangular labels for transition stages */
.rect-label .stage-label {
    border-radius: 4px !important;
}
@keyframes blinkDot {
    0%, 100% { opacity: 0.35; transform: scale(0.8); }
    50% { opacity: 0.85; transform: scale(1.2); }
}
.pathway-dot-html {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: #ffffff;
    border-radius: 50%;
    transform: translate(-50%, -50%); /* perfectly center it on its coordinate */
    animation: blinkDot 4s infinite ease-in-out;
    pointer-events: none; /* so it doesn't block clicks */
}
