@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Nunito:wght@400;600;700&display=swap');

:root {
    --mansion-cream: #f6efe3;
    --mansion-shadow: rgba(40, 24, 8, 0.18);
    --courtyard-teal: #1f6f78;
    --pool-blue: #3ab7d1;
    --night-ink: #1b1d27;
    --hamster-gold: #f1c26b;
    --cat-orange: #e28f4f;
    --cat-gray: #9aa6ad;
    --cat-cream: #f2d4b0;
    --dog-bronze: #7b4c2b;
    --dog-dark: #3f2a1d;
    --accent-rose: #d07a67;
}

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

body {
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(246, 239, 227, 0.7), transparent 45%),
        radial-gradient(circle at bottom right, rgba(31, 111, 120, 0.6), transparent 50%),
        linear-gradient(135deg, #1c2426 0%, #2c3a3f 40%, #1f6f78 100%);
    color: #1b1d27;
    padding: 16px;
}

.game-container {
    max-width: 1300px;
    margin: 0 auto;
    position: relative;
}

.back-home-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #f6efe3;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

.back-home-link:hover {
    transform: translateX(-4px);
    background: rgba(255, 255, 255, 0.2);
}

.header {
    margin-top: 16px;
    padding: 18px 20px;
    border-radius: 24px;
    background: rgba(246, 239, 227, 0.96);
    box-shadow: 0 16px 40px var(--mansion-shadow);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.title-block h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.3rem;
    letter-spacing: 1px;
    color: #3c2a17;
}

.subtitle {
    margin-top: 6px;
    color: #4f3d2b;
    font-weight: 600;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.stat {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 12px;
    border-radius: 14px;
    display: grid;
    gap: 6px;
    box-shadow: inset 0 0 0 1px rgba(200, 170, 130, 0.2);
}

.stat.compact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b4f32;
}

.value {
    font-weight: 700;
    color: #2a1a10;
}

.stat-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(62, 44, 24, 0.15);
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.2s ease;
}

.stat-fill.hunger {
    background: linear-gradient(90deg, #f1c26b, #e28f4f);
}

.stat-fill.thirst {
    background: linear-gradient(90deg, #52d6e3, #2b9fb6);
}

.stat-fill.rest {
    background: linear-gradient(90deg, #8fd3a0, #4f9d7b);
}

.status-line {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 14px;
    background: rgba(31, 111, 120, 0.12);
    color: #16444b;
    font-weight: 600;
}

.game-notice {
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.notice-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notice-icon {
    font-size: 1.5rem;
}

.notice-text {
    color: #3b2c1e;
    font-weight: 600;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr);
    gap: 18px;
    margin-top: 16px;
}

.game-area {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 12px;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#gameCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 18px;
    background: linear-gradient(120deg, #f8f1e5 0%, #d9e6e7 55%, #b9d5db 100%);
    box-shadow: inset 0 0 0 3px rgba(33, 42, 46, 0.1), 0 18px 40px rgba(17, 24, 39, 0.2);
}

.floating-hint {
    position: absolute;
    bottom: 18px;
    right: 22px;
    padding: 8px 14px;
    background: rgba(27, 29, 39, 0.8);
    color: #f6efe3;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: hintPulse 2.6s ease-in-out infinite;
}

.pointer-overlay {
    position: absolute;
    inset: 12px;
    border-radius: 18px;
    background: rgba(15, 20, 28, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #f6efe3;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.pointer-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.pointer-message {
    max-width: 320px;
    background: rgba(246, 239, 227, 0.92);
    color: #2b1a12;
    padding: 18px;
    border-radius: 18px;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.25);
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

@keyframes hintPulse {
    0%, 100% { transform: translateY(0); opacity: 0.85; }
    50% { transform: translateY(-6px); opacity: 1; }
}

.sidebar {
    background: rgba(246, 239, 227, 0.95);
    border-radius: 24px;
    padding: 18px 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.sidebar h3 {
    font-family: 'Cinzel', serif;
    margin-bottom: 12px;
    color: #3d2b1b;
}

.how-to-play-section {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(100, 70, 40, 0.2);
}

.how-to-play-section ul {
    margin-top: 6px;
    margin-left: 16px;
    color: #3f2c1c;
    font-size: 0.95rem;
    line-height: 1.5;
}

.legend {
    list-style: none;
    margin-left: 0;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.hamster { background: var(--hamster-gold); }
.legend-dot.cat { background: var(--cat-orange); }
.legend-dot.dog { background: var(--dog-dark); }
.legend-dot.hole { background: #2d2b2b; }
.legend-dot.food { background: #f3b35a; }
.legend-dot.water { background: #4fbcd1; }
.legend-dot.rest { background: #6bb88f; }

.controls {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.control-info {
    font-weight: 600;
    color: #3b2a1e;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(135deg, #f1c26b, #d07a67);
    color: #2b1a12;
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 8px 18px rgba(208, 122, 103, 0.35);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.splash-overlay,
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 28, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.splash-content,
.overlay-content {
    background: rgba(246, 239, 227, 0.96);
    padding: 30px;
    border-radius: 26px;
    text-align: center;
    max-width: 520px;
    box-shadow: 0 22px 40px rgba(0, 0, 0, 0.25);
    animation: overlayFloat 1.8s ease-in-out infinite alternate;
}

@keyframes overlayFloat {
    from { transform: translateY(-6px); }
    to { transform: translateY(6px); }
}

.splash-title h1 {
    font-family: 'Cinzel', serif;
    color: #3f2a1b;
    font-size: 2rem;
}

.splash-subtitle {
    color: #5b3c22;
    font-weight: 600;
    margin-top: 6px;
}

.splash-character {
    font-size: 3rem;
    margin: 16px 0;
}

.splash-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 16px 0 20px;
}

.splash-feature {
    background: rgba(208, 122, 103, 0.12);
    padding: 8px 10px;
    border-radius: 12px;
    font-weight: 600;
    color: #3b2a1e;
}

.touch-controls {
    display: none;
    margin-top: 14px;
    gap: 10px;
    flex-direction: column;
    align-items: center;
}

.touch-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.touch-btn {
    background: rgba(246, 239, 227, 0.9);
    border: 1px solid rgba(100, 70, 40, 0.2);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 1rem;
    font-weight: 600;
}

.overlay.hidden {
    display: none;
}

.splash-overlay.hidden {
    display: none;
}

@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .stats {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

    .controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .touch-controls {
        display: flex;
    }
}
