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

body {
    overflow: hidden;
    font-family: 'Quicksand', 'Noto Sans KR', sans-serif;
    background: #0a0015;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

.hidden { display: none !important; }

/* ===== START SCREEN ===== */
#start-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a0a30 0%, #0a0015 70%);
    overflow: hidden;
}

.stars-bg {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, white, transparent),
        radial-gradient(1px 1px at 30% 60%, white, transparent),
        radial-gradient(1.5px 1.5px at 50% 10%, #ffccdd, transparent),
        radial-gradient(1px 1px at 70% 80%, white, transparent),
        radial-gradient(1.5px 1.5px at 90% 40%, #ffccdd, transparent),
        radial-gradient(1px 1px at 15% 85%, white, transparent),
        radial-gradient(1px 1px at 45% 45%, white, transparent),
        radial-gradient(1.5px 1.5px at 80% 15%, #ccddff, transparent),
        radial-gradient(1px 1px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 25% 35%, white, transparent);
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.start-content {
    text-align: center;
    color: white;
    z-index: 1;
    position: relative;
    animation: fadeInUp 1s ease-out;
}

.start-planet-icon {
    font-size: 5rem;
    margin-bottom: 0.3em;
    animation: floatSlow 3s ease-in-out infinite;
}

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

.start-content h1 {
    font-size: 4.5rem;
    text-shadow: 0 0 40px rgba(255,105,180,0.6), 0 4px 20px rgba(0,0,0,0.3);
    margin-bottom: 0.1em;
    font-family: 'Noto Sans KR', sans-serif;
}

.start-content h2 {
    font-size: 1.6rem;
    font-weight: 400;
    opacity: 0.85;
    margin-bottom: 0.8em;
    letter-spacing: 0.1em;
}

.start-content > p {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 1.5em;
}

.start-planets-preview {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2.5em;
    flex-wrap: wrap;
}

.planet-preview {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 0.5em 1.2em;
    border-radius: 25px;
    font-size: 0.95rem;
    backdrop-filter: blur(5px);
}

#start-btn, #replay-btn {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 0.8em 3em;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #ff69b4, #ff91a4);
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 25px rgba(255,105,180,0.4);
    letter-spacing: 0.05em;
}

#start-btn:hover, #replay-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 35px rgba(255,105,180,0.6);
}

.controls-hint {
    margin-top: 1.2em;
    font-size: 0.85rem;
    opacity: 0.5;
}

/* Show desktop hint on non-touch, hide mobile hint */
@media (hover: hover) and (pointer: fine) {
    .mobile-hint { display: none !important; }
}

/* Show mobile hint on touch devices, hide desktop hint */
@media (hover: none), (pointer: coarse) {
    .desktop-hint { display: none !important; }
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    pointer-events: none;
}

.hud-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 15px 20px;
}

.planet-name-display {
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-items {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 18px;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.3s ease, background 0.3s ease;
}

.hud-item.complete {
    background: rgba(50,200,50,0.3);
    border-color: rgba(50,200,50,0.3);
}

.hud-item.pulse {
    animation: hudPulse 0.5s ease-out;
}

.hud-icon { font-size: 1.2rem; }

/* ===== QUEST TRACKER ===== */
.quest-tracker {
    position: fixed;
    top: 70px;
    left: 20px;
    z-index: 50;
}

.quest-text {
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 12px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    border-left: 3px solid #ff69b4;
    max-width: 300px;
}

/* ===== INTERACT PROMPT ===== */
#interact-prompt {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    animation: promptBounce 1.5s ease-in-out infinite;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

#interact-prompt:active {
    transform: translateX(-50%) scale(0.95);
    background: rgba(255,105,180,0.4);
}

.interact-key {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    border: 1px solid rgba(255,255,255,0.3);
}

.interact-label {
    font-size: 1rem;
    font-weight: 600;
}

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

/* Mobile: prompt plus gros et sans la touche E */
@media (hover: none), (pointer: coarse) {
    #interact-prompt {
        padding: 15px 30px;
        font-size: 1.1rem;
        bottom: 120px;
    }
    #interact-prompt:active {
        animation: none;
    }
}

/* ===== DIALOGUE BOX ===== */
#dialogue-box {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    width: min(90vw, 650px);
    animation: dialogueIn 0.3s ease-out;
}

.dialogue-content {
    display: flex;
    gap: 15px;
    background: rgba(10,5,25,0.85);
    backdrop-filter: blur(20px);
    padding: 20px 25px;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.15);
    color: white;
}

.dialogue-portrait {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    border: 2px solid rgba(255,255,255,0.2);
}

.dialogue-text-area {
    flex: 1;
}

.dialogue-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffb6c1;
    margin-bottom: 6px;
}

.dialogue-text {
    font-size: 1rem;
    line-height: 1.5;
    opacity: 0.9;
}

.dialogue-continue {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
    margin-top: 8px;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@keyframes dialogueIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== COLLECT FLASH ===== */
#collect-flash {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 55;
    pointer-events: none;
}

#collect-flash-text {
    font-size: 1.8rem;
    color: white;
    text-shadow: 0 0 20px rgba(255,105,180,0.8);
    font-weight: 700;
    animation: collectFlash 1.2s ease-out forwards;
}

/* ===== MESSAGE DISPLAY ===== */
#message-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 56;
    animation: messageIn 0.5s ease-out;
}

.message-content {
    background: rgba(10,5,25,0.9);
    backdrop-filter: blur(20px);
    padding: 30px 50px;
    border-radius: 20px;
    border: 2px solid rgba(255,182,193,0.3);
    text-align: center;
    max-width: 450px;
}

.message-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.message-content p {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.6;
}

.message-continue {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
    margin-top: 12px;
    animation: blink 1.5s ease-in-out infinite;
}

/* ===== PLANET TRANSITION ===== */
#planet-transition {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0015;
    animation: fadeIn 0.5s ease-out;
}

.transition-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.transition-stars {
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, white, transparent),
        radial-gradient(1px 1px at 30% 60%, white, transparent),
        radial-gradient(2px 2px at 50% 30%, #ffccdd, transparent),
        radial-gradient(1px 1px at 70% 80%, white, transparent),
        radial-gradient(1px 1px at 90% 40%, white, transparent),
        radial-gradient(1px 1px at 25% 45%, white, transparent),
        radial-gradient(2px 2px at 65% 55%, #ccddff, transparent),
        radial-gradient(1px 1px at 85% 25%, white, transparent);
    animation: twinkle 2s ease-in-out infinite alternate;
}

.transition-text {
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 0 30px rgba(255,105,180,0.5);
    animation: fadeInUp 0.8s ease-out;
}

/* ===== ENDING OVERLAY ===== */
#ending-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ending-text {
    color: white;
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 0 30px rgba(255,105,180,0.6), 0 4px 15px rgba(0,0,0,0.5);
    animation: endingTextIn 1s ease-out;
    max-width: 80vw;
    line-height: 1.5;
}

@keyframes endingTextIn {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== FINAL SCREEN ===== */
#final-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    animation: fadeIn 1s ease-out;
}

.final-content {
    text-align: center;
    color: white;
    animation: fadeInUp 1s ease-out;
}

.final-hearts {
    font-size: 3rem;
    margin-bottom: 0.5em;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.final-content h1 {
    font-size: 3.5rem;
    margin-bottom: 0.3em;
    text-shadow: 0 0 40px rgba(255,105,180,0.6);
}

.final-subtitle {
    font-size: 1.2rem;
    opacity: 0.7;
    margin-bottom: 0.3em;
}

.final-subtitle-fr {
    font-size: 1rem;
    opacity: 0.5;
    margin-bottom: 2em;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes messageIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes collectFlash {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5) translateY(-50px); }
}

@keyframes hudPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ===== MOBILE CONTROLS ===== */
#mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    pointer-events: none;
}

#joystick-zone {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(100, 100, 255, 0.5);
    border: 4px solid white;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
}

#joystick-stick.active {
    background: rgba(255, 105, 180, 0.8);
    border-color: rgba(255, 105, 180, 1);
}

#mobile-interact-btn {
    position: fixed;
    right: 15px;
    bottom: 50px;
    bottom: calc(50px + env(safe-area-inset-bottom, 0px));
    width: 80px;
    height: 80px;
    background: rgba(255, 100, 150, 0.7);
    border: 4px solid white;
    border-radius: 50%;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

#mobile-interact-btn span {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#mobile-interact-btn:active,
#mobile-interact-btn.active {
    -webkit-transform: scale(0.9);
    transform: scale(0.9);
    background: rgba(255, 105, 180, 0.9);
}

