/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00ffff;
    --secondary-color: #ff00ff;
    --danger-color: #ff3366;
    --success-color: #00ff88;
    --bg-dark: #0a0a1a;
    --bg-medium: #1a1a2e;
    --bg-light: #2a2a3e;
    --text-primary: #ffffff;
    --text-secondary: #aaaacc;
    --glow-primary: 0 0 20px var(--primary-color);
    --glow-danger: 0 0 20px var(--danger-color);
    
    /* Safe area insets pour les encoches */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 100%);
    color: var(--text-primary);
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Optimisations pour mobile */
    touch-action: none;
    -webkit-touch-callout: none;
}

#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    transform: scale(var(--hud-scale));
    transform-origin: top left;
}

#game-ui > * {
    pointer-events: auto;
}

/* Top HUD */
#top-hud {
    position: absolute;
    top: calc(20px + var(--safe-area-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px;
    background: rgba(26, 26, 46, 0.8);
    padding: 15px 30px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(0, 255, 255, 0.3);
}

.hud-item {
    text-align: center;
}

.hud-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.hud-value {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: var(--glow-primary);
}

/* Center Info */
#center-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

#planet-name {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: var(--glow-primary);
    margin-bottom: 20px;
    opacity: 0.9;
    animation: planetPulse 3s ease-in-out infinite;
}

@keyframes planetPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; }
}

#timing-feedback {
    font-size: 48px;
    font-weight: bold;
    animation: fadeOut 1s forwards;
    pointer-events: none;
}

#timing-feedback.perfect {
    color: var(--success-color);
    text-shadow: 0 0 30px var(--success-color);
}

#timing-feedback.good {
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--primary-color);
}

#timing-feedback.miss {
    color: var(--danger-color);
    text-shadow: 0 0 20px var(--danger-color);
}

/* Combo Display */
#combo-display {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: rgba(26, 26, 46, 0.9);
    padding: 15px 30px;
    border-radius: 15px;
    border: 2px solid var(--success-color);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
    animation: comboAppear 0.3s ease;
}

@keyframes comboAppear {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

#combo-text {
    font-size: 24px;
    font-weight: bold;
    color: var(--success-color);
    text-shadow: 0 0 15px var(--success-color);
    margin-bottom: 8px;
}

#combo-bar-bg {
    width: 150px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

#combo-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--success-color);
}

/* Danger Warning */
#danger-warning {
    margin-top: 8px;
    font-size: 14px;
    font-weight: bold;
    color: var(--danger-color);
    text-align: center;
    animation: dangerBlink 0.5s infinite;
}

@keyframes dangerBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Instability Bar */
#instability-container {
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
}

.instability-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#instability-value {
    color: var(--danger-color);
    font-weight: bold;
}

#instability-bar-bg {
    position: relative;
    width: 100%;
    height: 20px;
    background: rgba(26, 26, 46, 0.8);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 51, 102, 0.3);
}

#instability-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--danger-color));
    transition: width 0.3s ease;
    border-radius: 8px;
}

#instability-danger-zone {
    position: absolute;
    right: 0;
    top: 0;
    width: 30%;
    height: 100%;
    background: rgba(255, 51, 102, 0.2);
    border-left: 2px dashed var(--danger-color);
}

/* Loot Display */
#loot-display {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
}

.loot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(26, 26, 46, 0.8);
    padding: 12px 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(0, 255, 255, 0.3);
}

.loot-item.unsecured {
    border-color: rgba(255, 255, 0, 0.5);
    animation: pulse 2s infinite;
}

.loot-icon {
    font-size: 24px;
}

.loot-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.loot-value {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Action Buttons */
#action-buttons {
    position: absolute;
    bottom: calc(30px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--bg-dark);
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.4);
}

.action-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 255, 0.6);
}

.action-btn.secondary {
    background: rgba(26, 26, 46, 0.9);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.action-btn.secondary:hover:not(:disabled) {
    background: rgba(0, 255, 255, 0.2);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 22px;
}

.btn-uses {
    font-size: 12px;
    opacity: 0.7;
}

/* Event Display */
#event-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: rgba(26, 26, 46, 0.95);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    animation: slideIn 0.3s ease;
}

#event-title {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
}

#event-description {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.5;
}

#event-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-choice-btn {
    padding: 15px;
    background: rgba(42, 42, 62, 0.8);
    border: 2px solid var(--primary-color);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-align: left;
}

.event-choice-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: translateX(5px);
}

/* Game Over Screen */
#gameover-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

#gameover-content {
    text-align: center;
    padding: 40px;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#gameover-title {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 20px;
}

#gameover-title.success {
    color: var(--success-color);
    text-shadow: 0 0 30px var(--success-color);
}

#gameover-title.crash {
    color: var(--danger-color);
    text-shadow: 0 0 30px var(--danger-color);
}

#gameover-stats {
    margin: 30px 0;
    font-size: 18px;
    line-height: 2;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-highlight {
    color: var(--primary-color);
    font-weight: bold;
}

.new-achievements {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 255, 136, 0.1);
    border: 2px solid var(--success-color);
    border-radius: 10px;
}

.new-achievements h3 {
    color: var(--success-color);
    margin-bottom: 10px;
    font-size: 18px;
}

.new-achievement {
    padding: 8px;
    margin: 5px 0;
    background: rgba(0, 255, 136, 0.2);
    border-radius: 5px;
    font-size: 14px;
    color: var(--success-color);
    animation: achievementPop 0.5s ease;
}

@keyframes achievementPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Menu Screen */
#menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#menu-content {
    text-align: center;
    padding: 40px;
    width: 90%;
    max-width: 500px;
    margin: auto;
}

.menu-logo {
    max-width: 80%;
    height: auto;
    margin-bottom: 30px;
    filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.5));
    animation: logoFloat 3s ease-in-out infinite;
}

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

.game-title {
    font-size: 48px;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    text-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
}

#menu-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.menu-stat {
    text-align: center;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.3);
    color: var(--primary-color);
    font-size: 12px;
    cursor: help;
    transition: all 0.2s;
}

.info-icon:hover {
    background: rgba(99, 102, 241, 0.5);
    transform: scale(1.1);
}

.tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    color: white;
    font-size: 12px;
    line-height: 1.4;
    width: 200px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--primary-color);
}

.info-icon:hover + .tooltip,
.info-icon:focus + .tooltip {
    display: block;
    animation: tooltipFadeIn 0.2s ease;
}

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

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

#menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    font-size: 18px;
    font-weight: bold;
    background: rgba(26, 26, 46, 0.8);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all calc(0.3s * var(--menu-animation-speed)) ease;
    font-family: inherit;
}

.menu-btn.mode-btn {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
    gap: 8px;
}

.btn-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-title {
    font-size: 18px;
    font-weight: bold;
}

.btn-description {
    font-size: 13px;
    font-weight: normal;
    opacity: 0.75;
    text-align: center;
    line-height: 1.4;
    color: var(--text-secondary);
}

.menu-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.4);
}

#instructions {
    background: rgba(26, 26, 46, 0.6);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.2);
}

#instructions h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 18px;
}

#instructions p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.instruction-section {
    margin: 10px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid rgba(99, 102, 241, 0.6);
    border-radius: 4px;
}

.instruction-title {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 5px;
    color: #a5b4fc;
}

/* How To Play Modal */
#howtoplay-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

#howtoplay-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: rgba(26, 26, 46, 0.95);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.6);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#howtoplay-content h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    text-align: center;
    font-size: 28px;
    text-shadow: 0 0 20px var(--primary-color);
}

.howtoplay-section {
    margin-bottom: 25px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 51, 102, 0.2);
    border: 2px solid var(--danger-color);
    color: var(--danger-color);
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--danger-color);
}

#howtoplay-start-btn {
    width: 100%;
    margin-top: 20px;
    font-size: 18px;
    padding: 15px;
}

/* Settings Panel */
#settings-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: rgba(26, 26, 46, 0.95);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
}

#settings-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 14px;
}

.setting-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.setting-group span {
    color: var(--primary-color);
    font-weight: bold;
}

/* Achievements Panel */
#achievements-panel,
#chest-panel,
#collection-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: rgba(26, 26, 46, 0.95);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling iOS */
}

#achievements-content h2,
#chest-content h2,
#collection-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
}

#achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.achievement-item {
    background: rgba(42, 42, 62, 0.8);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    border-color: var(--success-color);
    background: rgba(0, 255, 136, 0.1);
}

.achievement-item.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.achievement-name {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.achievement-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.achievement-progress {
    font-size: 11px;
    color: var(--text-secondary);
}

#achievements-stats {
    text-align: center;
    padding: 15px;
    background: rgba(42, 42, 62, 0.6);
    border-radius: 10px;
    margin-bottom: 20px;
}

.achievement-stat {
    font-size: 18px;
    color: var(--primary-color);
}

/* Chest Panel */
.chest-info {
    text-align: center;
    margin-bottom: 20px;
}

.chest-price {
    font-size: 24px;
    color: var(--primary-color);
    margin: 10px 0;
}

.chest-wallet {
    font-size: 18px;
    color: var(--text-secondary);
}

.chest-pity {
    background: rgba(42, 42, 62, 0.6);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.pity-item {
    margin-bottom: 15px;
}

.pity-item:last-child {
    margin-bottom: 0;
}

.pity-bar {
    width: 100%;
    height: 20px;
    background: rgba(10, 10, 26, 0.8);
    border-radius: 10px;
    overflow: hidden;
    margin: 5px 0;
    border: 1px solid var(--primary-color);
}

.pity-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
}

.pity-bar-fill.legendary {
    background: linear-gradient(90deg, #ff00ff, #ffaa00);
}

/* Chest Opening Animation - Black Hole + Shooting Star */
#chest-animation {
    margin: 30px auto;
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Black Hole */
#black-hole-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.black-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #000000 0%, #1a0033 60%, transparent 100%);
    border-radius: 50%;
    animation: blackHolePulse 1s ease-in-out infinite;
}

.event-horizon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110px;
    height: 110px;
    border: 2px solid #ffaa00;
    border-radius: 50%;
    box-shadow: 0 0 20px #ffaa00, inset 0 0 20px #ffaa00;
    animation: horizonRotate 2s linear infinite;
}

.accretion-disk {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(0, 255, 255, 0.3) 0%, transparent 70%);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    animation: diskRotate 3s linear infinite;
}

@keyframes blackHolePulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 40px rgba(255, 170, 0, 0.6);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 60px rgba(255, 170, 0, 0.9);
    }
}

@keyframes horizonRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes diskRotate {
    from { transform: translate(-50%, -50%) rotate(0deg) scaleY(0.3); }
    to { transform: translate(-50%, -50%) rotate(360deg) scaleY(0.3); }
}

/* Shooting Star */
#shooting-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--star-color, #00ffff);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--star-color, #00ffff),
                0 0 20px var(--star-color, #00ffff),
                -150px 0 80px var(--star-color, #00ffff);
    animation: shootingStar 0.8s ease-out forwards;
    top: 50%;
    left: 50%;
}

@keyframes shootingStar {
    0% {
        transform: translate(-50%, -50%) rotate(-45deg) translateX(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) rotate(-45deg) translateX(300px);
        opacity: 0;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

#chest-reveal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
}

#chest-rarity-glow {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    border-radius: 50%;
    opacity: 0;
    animation: rarityGlow 1s ease forwards;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    text-transform: uppercase;
}

@keyframes rarityGlow {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

#chest-rarity-glow.common {
    background: radial-gradient(circle, rgba(170, 170, 170, 0.4) 0%, transparent 70%);
    box-shadow: 0 0 40px rgba(170, 170, 170, 0.6);
    color: #aaaaaa;
}

#chest-rarity-glow.rare {
    background: radial-gradient(circle, rgba(68, 136, 255, 0.4) 0%, transparent 70%);
    box-shadow: 0 0 40px rgba(68, 136, 255, 0.8);
    color: #4488ff;
}

#chest-rarity-glow.epic {
    background: radial-gradient(circle, rgba(170, 68, 255, 0.4) 0%, transparent 70%);
    box-shadow: 0 0 60px rgba(170, 68, 255, 0.9);
    color: #aa44ff;
}

#chest-rarity-glow.legendary {
    background: radial-gradient(circle, rgba(255, 170, 0, 0.5) 0%, transparent 70%);
    box-shadow: 0 0 80px rgba(255, 170, 0, 1), 0 0 120px rgba(255, 170, 0, 0.6);
    color: #ffaa00;
    animation: rarityGlow 1s ease forwards, legendaryPulse 1.5s ease infinite 1s;
}

@keyframes legendaryPulse {
    0%, 100% { box-shadow: 0 0 80px rgba(255, 170, 0, 1), 0 0 120px rgba(255, 170, 0, 0.6); }
    50% { box-shadow: 0 0 100px rgba(255, 170, 0, 1), 0 0 150px rgba(255, 170, 0, 0.8); }
}

#chest-cosmetic-display {
    text-align: center;
    opacity: 0;
    animation: cosmeticReveal 0.8s ease forwards 0.5s;
}

@keyframes cosmeticReveal {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.cosmetic-name {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 0 0 10px var(--primary-color);
}

.cosmetic-type {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.cosmetic-status {
    font-size: 14px;
    margin-top: 10px;
    padding: 5px 15px;
    border-radius: 20px;
    display: inline-block;
}

.cosmetic-status.new {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.cosmetic-status.duplicate {
    background: rgba(170, 170, 204, 0.2);
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
}

#chest-result {
    margin-top: 20px;
    padding: 20px;
    background: rgba(42, 42, 62, 0.8);
    border-radius: 10px;
    border: 2px solid var(--primary-color);
    animation: fadeInScale 0.5s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chest-result-item {
    text-align: center;
}

.chest-result-rarity {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.chest-result-rarity.COMMON { color: #aaaaaa; }
.chest-result-rarity.RARE { color: #4488ff; }
.chest-result-rarity.EPIC { color: #aa44ff; }
.chest-result-rarity.LEGENDARY { color: #ffaa00; }

.chest-result-name {
    font-size: 20px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.chest-result-duplicate {
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
}

/* Collection Panel */
.collection-count {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 18px;
    padding: 15px;
    background: rgba(42, 42, 62, 0.6);
    border-radius: 10px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.collection-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 8px 15px;
    background: rgba(42, 42, 62, 0.8);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    border-color: var(--primary-color);
    background: rgba(0, 255, 255, 0.2);
}

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

#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.cosmetic-card {
    background: rgba(42, 42, 62, 0.8);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cosmetic-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.cosmetic-card.equipped {
    border-color: var(--success-color);
    background: rgba(0, 255, 136, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

.cosmetic-card:not(.locked):hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.5);
}

.cosmetic-rarity {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.cosmetic-rarity.common { color: #aaaaaa; }
.cosmetic-rarity.rare { color: #5599ff; }
.cosmetic-rarity.epic { color: #aa00ff; }
.cosmetic-rarity.legendary { 
    color: #ffaa00;
    text-shadow: 0 0 10px #ffaa00;
}

.cosmetic-name {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.cosmetic-type {
    font-size: 11px;
    color: var(--text-secondary);
}

.cosmetic-equipped-badge {
    display: inline-block;
    background: var(--success-color);
    color: #000;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: bold;
    margin-top: 8px;
}

/* Tutorial Overlay */
#tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#tutorial-content {
    text-align: center;
    padding: 40px;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
}

#tutorial-title {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 28px;
}

#tutorial-text {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 30px;
    line-height: 1.6;
}

#tutorial-highlight {
    position: absolute;
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
    pointer-events: none;
    animation: highlightPulse 2s infinite;
    z-index: 999;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 30px rgba(0, 255, 255, 0.8); }
    50% { box-shadow: 0 0 50px rgba(0, 255, 255, 1); }
}

#tutorial-next-btn,
#tutorial-skip-btn {
    margin: 10px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Galaxy Route HUD */
#galaxy-route {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
}

#route-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#route-progress {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
}

#route-distance {
    font-weight: bold;
    font-size: 18px;
}

#route-next {
    color: var(--text-secondary);
}

.route-separator {
    color: var(--text-secondary);
}

#route-nodes {
    display: flex;
    gap: 8px;
    align-items: center;
}

.route-node {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    background: rgba(0, 255, 255, 0.1);
    position: relative;
    transition: all 0.3s ease;
}

.route-node.current {
    background: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-color);
    animation: pulse-route 2s infinite;
}

.route-node.locked {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.route-node.unlocked {
    background: rgba(0, 255, 255, 0.3);
    border-color: var(--primary-color);
}

.route-node.rare {
    border-color: #00ff88;
}

.route-node.epic {
    border-color: #ff00ff;
}

.route-node.legendary {
    border-color: #ffaa00;
    box-shadow: 0 0 15px #ffaa00;
}

@keyframes pulse-route {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

#route-sector {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Unlock Notification */
.unlock-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.98);
    border: 3px solid var(--primary-color);
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.6);
    animation: unlockAppear 0.4s ease;
}

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

.unlock-notification h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 24px;
}

.unlock-notification .planet-preview {
    margin: 15px 0;
}

.unlock-notification .planet-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
}

.unlock-notification .planet-type {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.unlock-notification .rarity-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    margin: 10px 0;
}

.unlock-notification .rarity-badge.common {
    background: rgba(150, 150, 150, 0.3);
    color: #aaa;
}

.unlock-notification .rarity-badge.rare {
    background: rgba(0, 255, 136, 0.3);
    color: #00ff88;
}

.unlock-notification .rarity-badge.epic {
    background: rgba(255, 0, 255, 0.3);
    color: #ff00ff;
}

.unlock-notification .rarity-badge.legendary {
    background: rgba(255, 170, 0, 0.3);
    color: #ffaa00;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
}

.unlock-notification button {
    margin-top: 15px;
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 8px;
    color: #0a0a1a;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.unlock-notification button:hover {
    transform: scale(1.05);
}

/* Sector Change Notification */
.sector-notification {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 30px var(--primary-color);
    z-index: 1500;
    animation: sectorFade 2s ease forwards;
    pointer-events: none;
}

@keyframes sectorFade {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Colorblind Mode */
.colorblind-mode {
    --primary-color: #00aaff;
    --secondary-color: #ff6600;
    --danger-color: #ff0066;
    --success-color: #00cc66;
}

/* Reduce Motion */
.reduce-motion * {
    animation-duration: 0.01s !important;
    transition-duration: 0.01s !important;
}

/* Back Button */
.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: rgba(99, 102, 241, 0.3);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    color: var(--primary-color);
    font-size: 28px;
    line-height: 44px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}
.back-btn-content {
    pointer-events: none;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: rgba(99, 102, 241, 0.5);
    border-color: var(--secondary-color);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* Animations */
@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 0, 0.6);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* HUD - Plus compact sur tablette */
    #top-hud {
        gap: 12px;
        padding: 8px 12px;
        top: 10px;
    }
    
    .hud-label {
        font-size: 10px;
    }
    
    .hud-value {
        font-size: 15px;
    }
    
    /* Centre */
    #planet-name {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    #timing-feedback {
        font-size: 36px;
    }
    
    /* Combo - Plus haut pour ne pas gêner */
    #combo-display {
        top: 90px;
        padding: 10px 20px;
    }
    
    #combo-text {
        font-size: 18px;
    }
    
    /* Instabilité - Plus visible */
    #instability-container {
        bottom: 180px;
        width: 92%;
    }
    
    .instability-label {
        font-size: 13px;
    }
    
    #instability-bar-bg {
        height: 18px;
    }
    
    /* Loot - Plus compact */
    #loot-display {
        bottom: 110px;
        gap: 15px;
    }
    
    .loot-item {
        padding: 10px 16px;
    }
    
    .loot-icon {
        font-size: 20px;
    }
    
    .loot-label {
        font-size: 10px;
    }
    
    .loot-value {
        font-size: 16px;
    }
    
    /* Boutons d'action - Plus gros pour le tactile */
    #action-buttons {
        bottom: 20px;
        gap: 12px;
    }
    
    .action-btn {
        padding: 14px 24px;
        font-size: 16px;
        min-height: 50px;
    }
    
    .btn-icon {
        font-size: 20px;
    }
    
    /* Menu */
    .game-title {
        font-size: 36px;
    }
    
    .menu-logo {
        max-width: 85%;
        margin-bottom: 20px;
    }
    
    #menu-content {
        padding: 30px 20px;
    }
    
    #menu-stats {
        gap: 30px;
        margin-bottom: 25px;
    }
    
    .menu-btn {
        padding: 16px;
        font-size: 16px;
    }
    
    .btn-title {
        font-size: 16px;
    }
    
    .btn-description {
        font-size: 12px;
    }
    
    /* Événements */
    #event-display {
        width: 92%;
        padding: 25px 20px;
    }
    
    #event-title {
        font-size: 20px;
    }
    
    #event-description {
        font-size: 15px;
    }
    
    .event-choice-btn {
        font-size: 15px;
        padding: 14px;
    }
    
    /* Game Over */
    #gameover-content {
        width: 92%;
        padding: 25px 20px;
        max-height: 90vh;
    }
    
    #gameover-title {
        font-size: 28px;
    }
    
    #gameover-stats {
        margin: 20px 0;
        line-height: 1.6;
    }
    
    .stat-line {
        font-size: 15px;
        padding: 6px 0;
    }
    
    /* Succès */
    #achievements-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    #achievements-panel {
        padding: 25px 20px;
    }
    
    /* Modal Comment jouer */
    #howtoplay-content {
        padding: 30px 20px;
        max-height: 90vh;
        width: 92%;
    }
    
    #howtoplay-content h2 {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .instruction-section {
        padding: 10px;
        margin: 8px 0;
    }
    
    .instruction-title {
        font-size: 14px;
    }
    
    /* Settings */
    #settings-panel {
        width: 92%;
        padding: 25px 20px;
    }
}

@media (max-width: 480px) {
    /* HUD - Ultra compact pour petit écran */
    #top-hud {
        gap: 8px;
        padding: 6px 10px;
        top: 5px;
        font-size: 12px;
    }
    
    .hud-item {
        min-width: 60px;
    }
    
    .hud-label {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .hud-value {
        font-size: 14px;
    }
    
    /* Centre - Adapté au petit écran */
    #planet-name {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    #timing-feedback {
        font-size: 28px;
    }
    
    /* Combo - Repositionné */
    #combo-display {
        top: 70px;
        padding: 8px 16px;
    }
    
    #combo-text {
        font-size: 16px;
    }
    
    #combo-bar-bg {
        width: 120px;
    }
    
    /* Instabilité - Optimisé mobile */
    #instability-container {
        bottom: 160px;
        width: 94%;
    }
    
    .instability-label {
        font-size: 11px;
    }
    
    #instability-bar-bg {
        height: 16px;
    }
    
    #danger-warning {
        font-size: 12px;
        margin-top: 5px;
    }
    
    /* Loot - Très compact */
    #loot-display {
        bottom: 100px;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        width: 94%;
    }
    
    .loot-item {
        padding: 8px 14px;
        flex: 0 1 auto;
    }
    
    .loot-icon {
        font-size: 18px;
    }
    
    .loot-label {
        font-size: 9px;
    }
    
    .loot-value {
        font-size: 14px;
    }
    
    /* Boutons d'action - GROS pour tactile */
    #action-buttons {
        bottom: 15px;
        gap: 10px;
        width: 94%;
    }
    
    .action-btn {
        padding: 16px 20px;
        font-size: 15px;
        min-height: 56px;
        flex: 1;
        justify-content: center;
    }
    
    .btn-icon {
        font-size: 20px;
    }
    
    .btn-text {
        font-size: 14px;
    }
    
    .btn-uses {
        font-size: 11px;
    }
    
    /* Menu - Optimisé mobile */
    .game-title {
        font-size: 28px;
        margin-bottom: 20px;
    }
    
    .menu-logo {
        max-width: 80%;
        margin-bottom: 15px;
    }
    
    #menu-content {
        padding: 20px 15px;
    }
    
    #menu-stats {
        gap: 20px;
        margin-bottom: 20px;
        flex-wrap: wrap;
    }
    
    .menu-stat {
        min-width: 120px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    #menu-buttons {
        gap: 12px;
    }
    
    .menu-btn {
        padding: 14px;
        font-size: 15px;
        gap: 10px;
    }
    
    .menu-btn.mode-btn {
        padding: 16px;
    }
    
    .btn-header {
        gap: 10px;
    }
    
    .btn-title {
        font-size: 15px;
    }
    
    .btn-description {
        font-size: 11px;
    }
    
    .btn-icon {
        font-size: 18px;
    }
    
    /* Événements - Mobile friendly */
    #event-display {
        width: 94%;
        padding: 20px 16px;
    }
    
    #event-title {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    #event-description {
        font-size: 14px;
        margin-bottom: 16px;
    }
    
    .event-choice-btn {
        font-size: 14px;
        padding: 16px;
        min-height: 50px;
    }
    
    /* Game Over - Adapté */
    #gameover-screen {
        padding: 10px;
        align-items: flex-start;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    #gameover-content {
        width: 94%;
        padding: 20px 16px;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        margin-top: 10px;
    }
    
    #gameover-title {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    #gameover-stats {
        font-size: 13px;
        margin: 15px 0;
        line-height: 1.4;
    }
    
    .stat-line {
        font-size: 14px;
        margin: 6px 0;
        padding: 5px 0;
    }
    
    .stat-highlight {
        font-size: 15px;
    }
    
    .new-achievements {
        margin-top: 12px;
        padding: 10px;
    }
    
    .new-achievements h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .new-achievement {
        padding: 6px;
        margin: 4px 0;
        font-size: 13px;
    }
    
    /* Succès - Liste verticale */
    #achievements-panel {
        width: 94%;
        padding: 20px 15px;
        max-height: 85vh;
    }
    
    #achievements-content h2 {
        font-size: 22px;
    }
    
    #achievements-list {
        gap: 10px;
    }
    
    .achievement-item {
        padding: 12px;
    }
    
    .achievement-icon {
        font-size: 28px;
    }
    
    .achievement-name {
        font-size: 14px;
    }
    
    .achievement-description {
        font-size: 12px;
    }
    
    /* Tutorial */
    #tutorial-content {
        padding: 25px 16px;
        width: 94%;
    }
    
    #tutorial-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    #tutorial-text {
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* Modal Comment jouer */
    #howtoplay-content {
        padding: 20px 15px;
        width: 94%;
        max-height: 88vh;
    }
    
    #howtoplay-content h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .howtoplay-section {
        margin-bottom: 20px;
    }
    
    .instruction-section {
        padding: 10px;
        margin: 6px 0;
    }
    
    .instruction-title {
        font-size: 13px;
    }
    
    .instruction-section p {
        font-size: 13px;
        line-height: 1.4;
    }
    
    #howtoplay-start-btn {
        padding: 16px;
        font-size: 16px;
        min-height: 52px;
    }
    
    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
        top: 10px;
        right: 10px;
    }
    
    /* Settings */
    #settings-panel {
        width: 94%;
        padding: 20px 16px;
    }
    
    #settings-content h2 {
        font-size: 22px;
    }
    
    .setting-group {
        margin-bottom: 16px;
    }
    
    .setting-group label {
        font-size: 13px;
    }
    
    /* Bouton retour */
    .back-btn {
        font-size: 24px;
        width: 40px;
        height: 40px;
    }
}

/* Orientation paysage sur mobile */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    /* HUD compact en mode paysage */
    #top-hud {
        gap: 8px;
        padding: 5px 10px;
        top: 5px;
        flex-wrap: wrap;
    }
    
    .hud-label {
        font-size: 8px;
    }
    
    .hud-value {
        font-size: 12px;
    }
    
    /* Centre repositionné */
    #planet-name {
        font-size: 18px;
        margin-bottom: 5px;
    }
    
    #timing-feedback {
        font-size: 24px;
    }
    
    /* Combo très compact */
    #combo-display {
        top: 50px;
        padding: 6px 12px;
    }
    
    #combo-text {
        font-size: 14px;
    }
    
    /* Instabilité repositionnée */
    #instability-container {
        bottom: 90px;
        width: 50%;
        left: 25%;
    }
    
    .instability-label {
        font-size: 10px;
    }
    
    #instability-bar-bg {
        height: 14px;
    }
    
    /* Loot sur les côtés */
    #loot-display {
        bottom: 50px;
        gap: 8px;
    }
    
    .loot-item {
        padding: 6px 10px;
    }
    
    .loot-icon {
        font-size: 16px;
    }
    
    .loot-label {
        font-size: 8px;
    }
    
    .loot-value {
        font-size: 12px;
    }
    
    /* Boutons d'action compacts */
    #action-buttons {
        bottom: 8px;
        gap: 8px;
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 42px;
    }
    
    .btn-icon {
        font-size: 16px;
    }
    
    /* Modals adaptés */
    #event-display,
    #gameover-content,
    #howtoplay-content,
    #tutorial-content,
    #achievements-panel,
    #settings-panel {
        max-height: 85vh;
        overflow-y: auto;
    }
}

/* Améliorations tactiles universelles */
button, .action-btn, .menu-btn, .event-choice-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Feedback tactile visuel */
@media (hover: none) {
    .action-btn:active:not(:disabled),
    .menu-btn:active,
    .event-choice-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
    
    .action-btn.primary:active:not(:disabled) {
        box-shadow: 0 2px 10px rgba(0, 255, 255, 0.3);
    }
}

/* Zone tactile minimale pour les boutons */
@media (pointer: coarse) {
    .action-btn,
    .menu-btn,
    .event-choice-btn,
    .back-btn,
    .close-btn {
        min-height: 48px;
        min-width: 48px;
    }
}

/* High instability screen shake */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, 2px); }
    20% { transform: translate(2px, -2px); }
    30% { transform: translate(-2px, -2px); }
    40% { transform: translate(2px, 2px); }
    50% { transform: translate(-2px, 2px); }
    60% { transform: translate(2px, -2px); }
    70% { transform: translate(-2px, -2px); }
    80% { transform: translate(2px, 2px); }
    90% { transform: translate(-2px, -2px); }
}

.danger-shake {
    animation: screenShake 0.3s infinite;
}

