:root {
    --primary: #ff6b6b;
    --secondary: #4ecdc4;
    --accent: #ffe66d;
    --dark: #1a1a1a;
    --glass: rgba(255, 255, 255, 0.15);
    --glass-heavy: rgba(255, 255, 255, 0.25);
    --gold: #d4af37;
}

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

body {
    font-family: 'Outfit', sans-serif;
    color: white;
    background-color: var(--dark);
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 1s ease-in-out;
    z-index: 1;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(0, 0, 0, 0.4) 100%);
    z-index: 2;
}

#minigame-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#ui-layer {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

.glass-panel {
    background: rgba(10, 10, 15, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.dream-scene-panel {
    width: min(760px, 92vw);
    padding: 56px 64px;
    text-align: left;
}

.dream-scene-kicker {
    font-size: 0.8rem;
    letter-spacing: 0.32rem;
    color: rgba(255, 230, 109, 0.82);
    margin-bottom: 18px;
}

.dream-scene-text {
    font-size: 1.4rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.94);
    margin-bottom: 22px;
}

.dream-scene-morning {
    font-size: 0.95rem;
    letter-spacing: 0.12rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.68);
}

.main-title h1 {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.ios-btn {
    padding: 16px 40px;
    border-radius: 50px;
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ios-btn.primary {
    background: linear-gradient(135deg, var(--primary), #ff8787);
    color: white;
}

.ios-btn.secondary {
    background: var(--glass-heavy);
    color: white;
    text-decoration: none;
    display: inline-block;
}

.ios-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Character Selector */
.character-grid {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
}

.char-card {
    width: 200px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.char-card img {
    width: 100%;
    border-radius: 20px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.char-card:hover {
    transform: scale(1.1);
}

.char-card:hover img {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary);
}

.char-info h3 {
    margin-top: 15px;
    color: var(--gold);
}

/* Dialog Screen */
#character-pannel {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80%;
    display: block;
}

#active-char-img,
#raith-img {
    height: 100%;
    max-width: 45%;
    object-fit: contain;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: absolute;
    bottom: 0;
    filter: brightness(0.6);
}

#raith-img {
    left: 10%;
    z-index: 2;
}

#active-char-img {
    right: 10%;
    z-index: 3;
}

.speaking {
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.4)) brightness(1.1) !important;
    transform: scale(1.05) translateY(-20px);
    z-index: 4 !important;
}

.dialog-box {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    padding: 30px 40px;
    text-align: left;
    min-height: 200px;
    cursor: pointer;
    z-index: 100;
}

#char-name {
    font-weight: 900;
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

#dialog-text {
    font-size: 1.3rem;
    line-height: 1.5;
}

#choices-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    background: var(--glass-heavy);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.1rem;
    text-align: left;
    transition: all 0.2s ease;
}

.choice-btn:hover {
    background: var(--primary);
    border-color: transparent;
}

#next-indicator {
    position: absolute;
    bottom: 20px;
    right: 40px;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

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

/* --- Map UI (Phase 11: Thumbnails) --- */
/* --- Map Hotspot System (Phase 26 revision) --- */

.map-hotspots-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    /* container itself doesn't block clicks */
}

.map-hotspot {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    pointer-events: all;
    /* card slides up from the pin, so anchor at the pin bottom */
}

/* --- Styled Teardrop Map Pins --- */
.hotspot-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    animation: pinFloat 2.8s ease-in-out infinite;
    z-index: 2;
    position: relative;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75));
    transition: filter 0.2s ease;
}

@keyframes pinFloat {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-5px); }
}

.map-hotspot:hover .hotspot-pin {
    animation: none;
    transform: translateY(-3px) scale(1.12);
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.85));
}

/* The teardrop shape */
.pin-marker {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 0 8px rgba(255,255,255,0.15), 0 2px 6px rgba(0,0,0,0.4);
}

/* Inner circle highlight */
.pin-marker::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
}

/* Icon counter-rotates to stay upright */
.pin-icon {
    transform: rotate(45deg);
    font-size: 1.05rem;
    line-height: 1;
    position: relative;
    z-index: 1;
}

/* Small label under the pin */
.pin-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
    white-space: nowrap;
    margin-top: 2px;
}

/* Teardrop tip shadow dot */
.pin-tip {
    width: 8px;
    height: 4px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    margin-top: -2px;
    filter: blur(1px);
}

/* Per-location colors */
.pin-park   .pin-marker { background: linear-gradient(135deg, #3d8b37, #6abf4b); }
.pin-library .pin-marker { background: linear-gradient(135deg, #6a3dbf, #9b6be8); }
.pin-gym    .pin-marker { background: linear-gradient(135deg, #1a6bbf, #3d9be8); }
.pin-cafe   .pin-marker { background: linear-gradient(135deg, #bf7a1a, #e8a83d); }
.pin-bar    .pin-marker { background: linear-gradient(135deg, #3d1a6b, #7b3dbf); }
.pin-room   .pin-marker { background: linear-gradient(135deg, #bf3d1a, #e86b3d); }
.pin-store   .pin-marker { background: linear-gradient(135deg, #bf1a7a, #e83dab); }
.pin-antique    .pin-marker { background: linear-gradient(135deg, #4a1a8a, #9b5dcf); }
.pin-jobcenter  .pin-marker { background: linear-gradient(135deg, #2a3a4a, #4a6a8a); }
.pin-beach      .pin-marker { background: linear-gradient(135deg, #c2933a, #3ab8c2); }

/* The card that appears on hover — hidden by default, slides up */
.hotspot-card {
    position: absolute;
    bottom: calc(100% + 8px);
    /* sits just above the pin */
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    width: 190px;
    height: 270px;
    border-radius: 14px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(255, 255, 255, 0.12);
    z-index: 10;
}

/* Show card on hotspot hover */
.map-hotspot:hover .hotspot-card {
    opacity: 1;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

.map-hotspot:hover .hotspot-pin {
    transform: scale(1.2);
    animation: none;
}

.hotspot-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: brightness(0.75);
    transition: filter 0.3s ease, transform 0.4s ease;
}

.map-hotspot:hover .hotspot-card-bg {
    filter: brightness(1);
    transform: scale(1.06);
}

.hotspot-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
    z-index: 2;
    text-align: center;
    box-sizing: border-box;
}

.hotspot-card-content h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Prevent the card from going off-screen for the leftmost hotspot */
.map-hotspot[style*="left:12"] .hotspot-card,
.map-hotspot[style*="left:8"] .hotspot-card {
    left: 0;
    transform: translateX(0) translateY(12px);
}

.map-hotspot[style*="left:12"]:hover .hotspot-card,
.map-hotspot[style*="left:8"]:hover .hotspot-card {
    transform: translateX(0) translateY(0);
}

/* Prevent rightmost cards from overflowing right edge */
.map-hotspot[style*="left:88"] .hotspot-card,
.map-hotspot[style*="left:8"] .hotspot-card {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(12px);
}

.map-hotspot[style*="left:88"]:hover .hotspot-card {
    transform: translateX(0) translateY(0);
}



.location-card {
    position: relative;
    width: 250px;
    height: 400px;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.location-card:hover {
    transform: translateY(-15px) scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s ease, filter 0.3s ease;
    filter: brightness(0.7);
    z-index: 1;
}

.location-card:hover .card-bg {
    transform: scale(1.1);
    filter: brightness(1.1);
}

.card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
    z-index: 2;
    box-sizing: border-box;
    text-align: center;
}

.card-content h3 {
    margin: 0 0 5px 0;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.stat-boost {
    margin: 0;
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.stat-boost.charm {
    color: #ff6b6b;
}

.stat-boost.smarts {
    color: #4facfe;
}

.stat-boost.fitness {
    color: #43e97b;
}

.stat-boost.return {
    color: #eee;
}

/* --- Top Bar & Affection Visualizer --- */
#top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 150;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

#affection-container {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--glass-heavy);
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

#heart-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 5px var(--primary));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heartbeat {
    animation: pump 0.3s ease-in-out;
}

.heart-break {
    animation: breakHeart 0.3s ease-in-out;
    filter: grayscale(100%) !important;
}

@keyframes pump {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

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

@keyframes breakHeart {
    0% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(0.8) rotate(-15deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

.affection-meter {
    width: 150px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
}

#affection-fill {
    height: 100%;
    width: 0%;
    /* Default 0 */
    background: linear-gradient(90deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    box-shadow: 0 0 10px var(--primary);
    transition: width 0.5s ease-in-out, background 0.5s;
    border-radius: 10px;
}

/* System Menu (Save/Load) */
#system-menu {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.sys-btn {
    background: var(--glass-heavy);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sys-btn.toggle-btn.active {
    background: var(--gold);
    color: var(--dark);
    box-shadow: 0 0 10px var(--gold);
}

/* Custom Scrollbar for Log */
#log-container::-webkit-scrollbar {
    width: 8px;
}

#log-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#log-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.log-entry {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.log-name {
    color: var(--primary);
    font-weight: 900;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.log-text {
    font-size: 1.1rem;
    line-height: 1.4;
    color: #eee;
}

/* --- Score Screen Styling --- */
#score-grade-display {
    animation: stampIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform: scale(3);
    opacity: 0;
}

@keyframes stampIn {
    0% {
        transform: scale(3) rotate(15deg);
        opacity: 0;
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.grade-s {
    color: #ff6b81;
    text-shadow: 0 0 30px rgba(255, 107, 129, 0.8) !important;
    filter: drop-shadow(0 0 10px #ffe66d);
}

.grade-s-plus-plus {
    color: #ff3f34;
    text-shadow: 0 0 40px rgba(255, 63, 52, 1) !important;
    filter: drop-shadow(0 0 20px #ff9f43);
    animation: stampIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

.grade-a {
    color: #4ecdc4;
    text-shadow: 0 0 20px rgba(78, 205, 196, 0.6) !important;
}

.grade-b {
    color: #ffe66d;
    text-shadow: 0 0 15px rgba(255, 230, 109, 0.5) !important;
}

.grade-c {
    color: #f39c12;
}

.grade-f {
    color: #ff4757;
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.8) !important;
    filter: grayscale(50%);
}

/* --- Map/Contacts Screen Styling --- */
.map-contact {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    background: var(--glass);
    border: 2px solid transparent;
}

.map-contact:hover {
    transform: translateY(-10px) scale(1.05);
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--secondary);
    box-shadow: 0 15px 30px rgba(78, 205, 196, 0.4);
}

/* --- Hub Screen / Stats Modal --- */
#hub-stats-modal .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#hub-stats-modal .stat-row:last-child {
    border-bottom: none;
}

.tier-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Minigame Styling --- */
#timing-bar {
    width: 600px;
    height: 40px;
    background: #222;
    border: 3px solid #fff;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    margin: 30px auto;
}

#timing-target {
    position: absolute;
    height: 100%;
    background: rgba(0, 168, 255, 0.6);
    /* Blue zone */
    top: 0;
}

#timing-cursor {
    position: absolute;
    width: 10px;
    height: 100%;
    background: var(--primary);
    top: 0;
    box-shadow: 0 0 15px var(--primary);
}

.mg-title {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 230, 109, 0.5);
}

/* Quiz Minigame */
.quiz-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.quiz-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
    border-color: var(--accent);
}

.quiz-btn:active {
    transform: scale(0.98);
}

/* --- Match-3 Intimacy Minigame Styling --- */
#match3-board {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 5px;
    padding: 15px;
    background: rgba(20, 20, 30, 0.8);
    border: 3px solid var(--accent);
    border-radius: 15px;
}

.m3-cell {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    z-index: 1;
}

.m3-cell:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.m3-cell.selected {
    border: 3px solid var(--primary);
    transform: scale(1.15);
    z-index: 3;
    box-shadow: 0 0 20px var(--primary);
}

/* Token Colors */
.token-romance {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Pink/Heart */
.token-passion {
    background: linear-gradient(135deg, #f83600 0%, #f9d423 100%);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Orange/Fire */
.token-charm {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Cyan/Diamond */
.token-flirt {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Purple/Star */

/* Animations */
@keyframes dropIn {
    0% {
        transform: translateY(-100px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes popOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.8;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.m3-dropping {
    animation: dropIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.m3-popping {
    animation: popOut 0.3s ease-in forwards;
}

/* --- Romance Animations --- */
@keyframes hugAnimRaith {
    0% {
        transform: scale(1) translateX(0);
    }

    30% {
        transform: scale(1.05) translateX(30px);
    }

    70% {
        transform: scale(1.05) translateX(30px);
    }

    100% {
        transform: scale(1) translateX(0);
    }
}

@keyframes hugAnimChar {
    0% {
        transform: scale(1) translateX(0);
    }

    30% {
        transform: scale(1.05) translateX(-30px);
    }

    70% {
        transform: scale(1.05) translateX(-30px);
    }

    100% {
        transform: scale(1) translateX(0);
    }
}

@keyframes kissAnimRaith {
    0% {
        transform: scale(1) translateX(0) rotate(0deg);
    }

    20% {
        transform: scale(1.1) translateX(50px) rotate(5deg);
    }

    80% {
        transform: scale(1.1) translateX(50px) rotate(5deg);
    }

    100% {
        transform: scale(1) translateX(0) rotate(0deg);
    }
}

@keyframes kissAnimChar {
    0% {
        transform: scale(1) translateX(0) rotate(0deg);
    }

    20% {
        transform: scale(1.1) translateX(-50px) rotate(-5deg);
        filter: drop-shadow(0 0 10px #ff9a9e);
    }

    80% {
        transform: scale(1.1) translateX(-50px) rotate(-5deg);
        filter: drop-shadow(0 0 20px #ff9a9e);
    }

    100% {
        transform: scale(1) translateX(0) rotate(0deg);
        filter: drop-shadow(0 0 0px transparent);
    }
}

.anim-hug-raith {
    animation: hugAnimRaith 3s ease-in-out;
}

.anim-hug-char {
    animation: hugAnimChar 3s ease-in-out;
}

.anim-kiss-raith {
    animation: kissAnimRaith 4s ease-in-out;
}

.anim-kiss-char {
    animation: kissAnimChar 4s ease-in-out;
}

@keyframes floatHeart {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translateY(-30px) scale(1.2);
        opacity: 1;
    }

    80% {
        transform: translateY(-100px) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-150px) scale(0.8);
        opacity: 0;
    }
}

.floating-heart {
    position: absolute;
    color: #ff6b81;
    font-size: 3rem;
    pointer-events: none;
    z-index: 100;
    animation: floatHeart 2s ease-out forwards;
    left: 50%;
    top: 40%;
}

.mg-btn {
    font-size: 1.5rem;
    padding: 20px 60px;
    margin-top: 20px;
}

/* --- Phase 26: Location Hub & Activity Cards --- */

/* Character badge dots on map cards */
.card-char-badges {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.char-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    object-position: top;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    animation: charBadgePop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes charBadgePop {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Activity Cards inside the Location Hub */
.activity-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 35px 28px;
    min-width: 220px;
    max-width: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    backdrop-filter: blur(12px);
    transition: all 0.25s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.activity-card:hover {
    transform: translateY(-6px);
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
    box-shadow: 0 12px 30px rgba(255, 230, 109, 0.25);
}

.activity-card:active {
    transform: translateY(-2px) scale(0.97);
}

.activity-card .act-icon {
    font-size: 3.8rem;
    line-height: 1;
}

.activity-card .act-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.activity-card .act-reward {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
}

.activity-card .act-cost {
    font-size: 0.95rem;
    color: #ffd700;
    font-weight: 600;
    background: rgba(255, 215, 0, 0.12);
    padding: 3px 10px;
    border-radius: 20px;
}

.activity-card .act-cost.free {
    color: #43e97b;
    background: rgba(67, 233, 123, 0.12);
}

.activity-card .act-restore {
    font-size: 0.9rem;
    color: #4facfe;
    font-weight: 600;
}


/* Pulse dot indicating "free" activity */
.activity-card.is-premium {
    border-color: rgba(255, 215, 0, 0.3);
}

/* Phase 39: Gym sub-area picker cards */
.gym-area-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    min-height: 160px;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    margin-bottom: 12px;
}

.gym-area-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.gym-area-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.55);
    transition: filter 0.18s ease;
}

.gym-area-card:hover .gym-area-bg {
    filter: brightness(0.7);
}

.gym-area-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 20px 16px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
    width: 100%;
}

.gym-area-icon {
    font-size: 2.2rem;
    line-height: 1;
    margin-bottom: 6px;
    display: block;
}

.gym-area-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
    margin-bottom: 3px;
}

.gym-area-desc {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.65);
    letter-spacing: 0.04em;
}

/* Activity feedback overlay */
#act-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    gap: 15px;
    animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#act-feedback-overlay .fb-icon {
    font-size: 5rem;
}

#act-feedback-overlay .fb-title {
    font-size: 1.8rem;
    color: white;
    font-weight: 700;
}

#act-feedback-overlay .fb-stat {
    font-size: 3rem;
    color: var(--accent);
    font-weight: 900;
}

/* --- In-game Toast Notification (replaces alert()) --- */
#game-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 28px;
    border-radius: 16px;
    background: rgba(20, 20, 35, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 500px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
}

#game-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

#game-toast .toast-icon {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}

#game-toast .toast-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#game-toast .toast-title {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 800;
}

#game-toast .toast-msg {
    font-size: 0.95rem;
    color: #ccc;
    line-height: 1.4;
}

/* --- Phase 28: Needs Bars --- */
.needs-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 20px;
}

.need-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.need-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ccc;
    min-width: 100px;
}

.need-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.need-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 100%;
}

.need-fill.energy {
    background: linear-gradient(90deg, #4facfe, #00f2fe);
}

.need-fill.hunger {
    background: linear-gradient(90deg, #f7971e, #ffd200);
}

.need-fill.grooming {
    background: linear-gradient(90deg, #f093fb, #f5576c);
}

.need-fill.need-low {
    animation: needPulse 0.8s ease-in-out infinite alternate;
}

@keyframes needPulse {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

.need-val {
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    min-width: 25px;
    text-align: right;
}

/* --- Phase 29: Interactive Room Hotspots --- */
/* --- Room Interaction Zones --- */
/* Invisible at rest. On hover: soft radial warm glow + tooltip. */
/* Each zone has a tiny pulsing dot to hint interactivity. */

.room-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.room-zone {
    position: absolute;
    cursor: pointer;
    pointer-events: all;
    border-radius: 20px;
    border: none;
    background: transparent;
    transition: background 0.3s ease;
}

/* On hover: soft radial warm glow — like lamplight catching the object */
.room-zone:hover {
    background: radial-gradient(ellipse at center,
        rgba(255, 210, 130, 0.20) 0%,
        rgba(255, 200, 100, 0.08) 55%,
        transparent 100%);
}

/* ── Dot indicator ── */
/* A tiny glowing dot pinned to a specific spot within the zone.
   Positioned via inline style on the element itself (left/top as % of zone). */
.room-zone-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 210, 100, 0.75);
    box-shadow: 0 0 6px 2px rgba(255, 200, 80, 0.45);
    transform: translate(-50%, -50%);
    animation: dotPulse 2.8s ease-in-out infinite;
    transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

@keyframes dotPulse {
    0%, 100% {
        opacity: 0.45;
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 5px 1px rgba(255, 200, 80, 0.3);
    }
    50% {
        opacity: 0.85;
        transform: translate(-50%, -50%) scale(1.5);
        box-shadow: 0 0 10px 3px rgba(255, 200, 80, 0.55);
    }
}

.room-zone:hover .room-zone-dot {
    opacity: 1;
    background: rgba(255, 230, 120, 1);
    box-shadow: 0 0 14px 5px rgba(255, 210, 80, 0.75);
    transform: translate(-50%, -50%) scale(1.8);
    animation: none;
}

/* ── Tooltip card ── */
.room-zone-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(8, 8, 20, 0.92);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
}
.room-zone:hover .room-zone-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Directional variants */
.room-zone-tooltip.rzt-below {
    bottom: auto;
    top: calc(100% + 14px);
    transform: translateX(-50%) translateY(-8px);
}
.room-zone:hover .room-zone-tooltip.rzt-below {
    transform: translateX(-50%) translateY(0);
}
.room-zone-tooltip.rzt-right {
    bottom: auto;
    left: calc(100% + 14px);
    top: 40%;
    transform: translateY(-50%) translateX(-8px);
}
.room-zone:hover .room-zone-tooltip.rzt-right {
    transform: translateY(-50%) translateX(0);
}
.room-zone-tooltip.rzt-left {
    bottom: auto;
    right: calc(100% + 14px);
    left: auto;
    top: 40%;
    transform: translateY(-50%) translateX(8px);
}
.room-zone:hover .room-zone-tooltip.rzt-left {
    transform: translateY(-50%) translateX(0);
}

/* Tooltip text elements */
.rzt-icon {
    font-size: 1.7rem;
    line-height: 1;
}
.rzt-label {
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 800;
    color: white;
    letter-spacing: 0.3px;
}
.rzt-sub {
    font-family: var(--font);
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.48);
    font-weight: 500;
}

/* --- Room Navigation Tab Bar --- */
#room-nav-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    display: flex;
    gap: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.room-nav-btn {
    flex: 0 0 auto;
    padding: 12px 28px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.55);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.room-nav-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.07);
}

.room-nav-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(255, 230, 109, 0.06);
}

/* --- Room Bottom HUD Bar --- */
.room-bottom-hud {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px 25px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    z-index: 50;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.room-hud-left {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.room-hud-tag {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
    padding: 5px 12px;
    border-radius: 8px;
}

.room-hud-needs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    max-width: 300px;
}

.goals-modal-card {
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: min(82vh, 860px);
    background: rgba(11, 14, 25, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    padding: 22px;
    color: #f3f3f3;
}

.goals-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.goals-modal-head h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent);
    letter-spacing: 0.8px;
}

.goals-modal-meta {
    font-size: 0.82rem;
    color: #b6bfd3;
    margin-bottom: 12px;
}

.journal-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.journal-tab {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #d9d9d9;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    cursor: pointer;
}

.journal-tab.active {
    background: rgba(255, 230, 109, 0.18);
    color: var(--accent);
    border-color: rgba(255, 230, 109, 0.45);
}

.goals-modal-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 6px;
}

.goals-modal-item {
    font-size: 0.92rem;
    line-height: 1.4;
    color: #ececec;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.goals-modal-item strong {
    color: var(--accent);
}

.journal-route-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.journal-route-accordion {
    gap: 0;
}

.journal-route-toggle {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.journal-route-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.journal-route-heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.journal-route-head-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.journal-route-summary {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.68);
    line-height: 1.35;
}

.journal-route-chevron {
    width: 18px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
}

.journal-route-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 900px) {
    .goals-modal-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
    }

    .goals-modal-list .journal-route-card {
        height: fit-content;
    }
}

.journal-route-status {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    color: #d5dbe4;
}

.journal-route-status.locked,
.journal-route-status.closed-off {
    background: rgba(255, 107, 107, 0.16);
    color: #ffb0b0;
}

.journal-route-status.active,
.journal-route-status.scene-ready {
    background: rgba(255, 214, 102, 0.16);
    color: #ffd666;
}

.journal-route-status.max-tier {
    background: rgba(122, 222, 152, 0.18);
    color: #9af5b0;
}

.journal-route-status.gate-pending,
.journal-route-status.not-met {
    background: rgba(123, 188, 255, 0.16);
    color: #a9d4ff;
}

.journal-route-progressline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    color: #aab6c3;
}

.journal-route-progressline span {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
}

.journal-route-goal {
    display: grid;
    gap: 4px;
}

.journal-route-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #98a7b8;
}

.journal-route-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.journal-route-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd666, #ff9f67);
}

.journal-route-note {
    font-size: 0.8rem;
    color: #c7d1db;
}

.journal-subgoal-list {
    display: grid;
    gap: 8px;
}

.journal-subgoal {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.journal-subgoal.done {
    border: 1px solid rgba(122, 222, 152, 0.22);
}

.journal-subgoal.todo {
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.journal-subgoal-mark {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffd666;
    line-height: 1.4;
}

.journal-subgoal.done .journal-subgoal-mark {
    color: #9af5b0;
}

.journal-subgoal-copy {
    display: grid;
    gap: 2px;
}

.journal-subgoal-copy strong {
    color: #eef2f6;
    font-size: 0.82rem;
}

.journal-subgoal-copy span {
    color: #aab6c3;
    font-size: 0.78rem;
}

.room-hud-needs .need-row {
    flex: 1;
}

.room-hud-needs .need-label {
    min-width: auto;
    font-size: 1rem;
}

.room-hud-needs .need-bar {
    min-width: 50px;
}

@media (max-width: 1100px) {
    .room-bottom-hud {
        flex-wrap: wrap;
    }

    .room-hud-needs {
        max-width: none;
        width: 100%;
    }
}
