/* ============================================
   Mushroom Survivor — Professional Style
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

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

body {
    background: #060610;
    overflow: hidden;
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
    color: #c8d0dc;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

/* ---- UI Overlay ---- */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 3, 12, 0.92);
    backdrop-filter: blur(12px);
    pointer-events: all;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
}

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

.screen-content {
    text-align: center;
    max-width: 640px;
    padding: 48px 40px;
}

/* ---- Start Screen ---- */
.game-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 3.6rem;
    font-weight: 700;
    color: #e8ecf2;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 6px;
    line-height: 1;
}

.subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.95rem;
    color: #4a5568;
    margin-bottom: 36px;
    letter-spacing: 5px;
    text-transform: uppercase;
}

.creature-preview {
    width: 72px;
    height: 72px;
    margin: 0 auto 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #c0392b, #7b241c);
    box-shadow: 0 0 40px rgba(192, 57, 43, 0.25), 0 0 80px rgba(192, 57, 43, 0.08);
    animation: pulse 3s ease-in-out infinite;
    border: 2px solid rgba(192, 57, 43, 0.3);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(192, 57, 43, 0.25); }
    50% { transform: scale(1.06); box-shadow: 0 0 60px rgba(192, 57, 43, 0.35); }
}

.instructions {
    font-size: 0.88rem;
    line-height: 2;
    color: #5a6577;
    margin-bottom: 36px;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.5px;
}

.btn-primary {
    padding: 14px 44px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    border: 1px solid rgba(200, 210, 225, 0.2);
    border-radius: 2px;
    cursor: pointer;
    background: transparent;
    color: #e8ecf2;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(200, 210, 225, 0.06), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover {
    border-color: rgba(200, 210, 225, 0.5);
    box-shadow: 0 0 20px rgba(200, 210, 225, 0.08);
}

.btn-primary:hover::before {
    left: 100%;
}

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

/* ---- Mutation Screen ---- */
.wave-cleared {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #e8ecf2;
    margin-bottom: 4px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.mutation-prompt {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 28px;
    letter-spacing: 1px;
}

.mutation-grid {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.mutation-card {
    width: 176px;
    padding: 22px 16px 18px;
    background: rgba(12, 12, 28, 0.95);
    border: 1px solid rgba(60, 65, 80, 0.4);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.mutation-card:hover {
    border-color: rgba(200, 210, 225, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.mutation-icon {
    margin-bottom: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mutation-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #d0d8e4;
    margin-bottom: 6px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.mutation-desc {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #5a6577;
    line-height: 1.5;
}

/* Rarity borders */
.mutation-card.rarity-common { border-color: rgba(120, 140, 120, 0.35); }
.mutation-card.rarity-rare { border-color: rgba(80, 120, 180, 0.35); }
.mutation-card.rarity-epic { border-color: rgba(140, 80, 180, 0.35); }
.mutation-card.rarity-legendary { border-color: rgba(200, 160, 60, 0.35); }

.mutation-card.rarity-common:hover { border-color: rgba(120, 140, 120, 0.7); box-shadow: 0 8px 30px rgba(120, 140, 120, 0.08); }
.mutation-card.rarity-rare:hover { border-color: rgba(80, 120, 180, 0.7); box-shadow: 0 8px 30px rgba(80, 120, 180, 0.08); }
.mutation-card.rarity-epic:hover { border-color: rgba(140, 80, 180, 0.7); box-shadow: 0 8px 30px rgba(140, 80, 180, 0.08); }
.mutation-card.rarity-legendary:hover { border-color: rgba(200, 160, 60, 0.7); box-shadow: 0 8px 30px rgba(200, 160, 60, 0.08); }

/* ---- Game Over Screen ---- */
.game-over-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #c0392b;
    margin-bottom: 28px;
    letter-spacing: 8px;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-item {
    background: rgba(12, 12, 28, 0.9);
    padding: 16px;
    border-radius: 3px;
    border: 1px solid rgba(60, 65, 80, 0.25);
}

.stat-item.total {
    grid-column: span 2;
    border-color: rgba(200, 210, 225, 0.2);
}

.stat-label {
    display: block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    color: #4a5568;
    letter-spacing: 2px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.stat-value {
    display: block;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #e8ecf2;
}

.stat-item.total .stat-value {
    color: #e8ecf2;
    font-size: 2.2rem;
}

.mutations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 24px;
}

.mutations-list .mutation-badge {
    background: rgba(12, 12, 28, 0.9);
    border-radius: 3px;
    padding: 4px;
    border: 1px solid rgba(60, 65, 80, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mutations-list .mutation-badge canvas {
    display: block;
}

/* ---- HUD ---- */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 14px 24px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(3, 3, 12, 0.8), transparent);
}

#hud.visible {
    display: flex;
}

#hud-left {
    display: flex;
    gap: 28px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.55rem;
    color: #3a4250;
    letter-spacing: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

.hud-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #d0d8e4;
}

#hud-center {
    flex: 1;
    max-width: 240px;
    margin: 0 24px;
}

#hp-bar-container {
    position: relative;
    width: 100%;
    height: 18px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid rgba(60, 65, 80, 0.3);
}

#hp-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2d6a4f, #40916c);
    border-radius: 1px;
    transition: width 0.3s ease, background 0.3s ease;
}

#hp-bar.low {
    background: linear-gradient(90deg, #c0392b, #e74c3c);
}

#hp-bar.medium {
    background: linear-gradient(90deg, #d4880f, #e09f3e);
}

#hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

#hud-right {
    display: flex;
    gap: 4px;
}

#mutation-icons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 220px;
}

#mutation-icons .m-icon {
    background: rgba(12, 12, 28, 0.9);
    border-radius: 3px;
    padding: 2px;
    border: 1px solid rgba(60, 65, 80, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Wave Announcement ---- */
#wave-announce {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 8;
    pointer-events: none;
}

#wave-announce.hidden {
    display: none;
}

#wave-announce-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: rgba(200, 210, 225, 0.9);
    text-shadow: 0 0 40px rgba(200, 210, 225, 0.15);
    letter-spacing: 10px;
    text-transform: uppercase;
    animation: announceIn 2.5s ease forwards;
}

@keyframes announceIn {
    0% { opacity: 0; transform: scale(0.7); letter-spacing: 20px; }
    15% { opacity: 1; transform: scale(1.02); }
    35% { transform: scale(1); letter-spacing: 10px; }
    70% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.05); letter-spacing: 14px; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .game-title { font-size: 2.2rem; letter-spacing: 4px; }
    .subtitle { font-size: 0.8rem; }
    .mutation-grid { flex-direction: column; align-items: center; }
    .mutation-card { width: 90%; max-width: 260px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-item.total { grid-column: span 1; }
    .screen-content { padding: 24px 20px; }
    #wave-announce-text { font-size: 1.8rem; }
}


/* ---- Game Logo ---- */
.game-logo {
    display: block;
    margin: 0 auto 28px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(192, 57, 43, 0.25), 0 0 80px rgba(192, 57, 43, 0.08);
    animation: pulse 3s ease-in-out infinite;
    border: 2px solid rgba(192, 57, 43, 0.3);
}

/* ---- Game Logo ---- */
.game-logo {
    display: block;
    margin: 0 auto 28px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(192, 57, 43, 0.25), 0 0 80px rgba(192, 57, 43, 0.08);
    border: 2px solid rgba(192, 57, 43, 0.3);
}
