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

:root {
    --cosmic-bg: #03030a;
    --glass-bg: rgba(15, 20, 35, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(255, 255, 255, 0.28);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --gold-primary: #ffd700;
    --gold-glow: rgba(255, 215, 0, 0.4);
    --text-main: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.35);
}

body {
    overflow: hidden;
    background: var(--cosmic-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, system-ui, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

#canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    contain: strict;
}

/* ==================== GLASSMORPHISM HUD ==================== */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: max(14px, env(safe-area-inset-top, 14px)) 20px 14px 20px;
    pointer-events: none;
    gap: 12px;
    transform: translateZ(0);
}

.hud-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: var(--glass-shadow);
    color: var(--text-main);
    pointer-events: auto;
}

/* --- Left: Score Box --- */
#score-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 16px;
    min-width: 115px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#score-box:hover {
    border-color: var(--glass-border-hover);
}

.score-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.hud-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.hud-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    text-shadow: 0 0 12px var(--gold-glow);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.hud-value-sub {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold-primary);
    font-variant-numeric: tabular-nums;
}

/* --- Center: Combo Badge --- */
#combo-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 18px 8px 18px;
    min-width: 130px;
    opacity: 0;
    transform: translateY(-10px) scale(0.92);
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.28s ease,
                border-color 0.28s ease;
    border-color: rgba(255, 215, 0, 0.3);
}

#combo-badge.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    border-color: rgba(255, 215, 0, 0.55);
    box-shadow: 0 0 24px rgba(255, 200, 0, 0.25), var(--glass-shadow);
}

.combo-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.combo-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #ffca28;
    text-shadow: 0 0 8px rgba(255, 202, 40, 0.6);
}

.combo-multiplier {
    font-size: 20px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.85);
    font-variant-numeric: tabular-nums;
}

.combo-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 4px;
}

#combo-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff9100, #ffd700);
    border-radius: 99px;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    transform-origin: left center;
    transform: scaleX(0);
    will-change: transform;
}

/* --- Right: Action Buttons --- */
.hud-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.hud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.2s ease,
                border-color 0.2s ease,
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease;
    outline: none;
    box-shadow: var(--glass-shadow);
}

.hud-btn:hover {
    background: rgba(25, 35, 60, 0.8);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.hud-btn:active {
    transform: scale(0.94);
    background: rgba(20, 28, 50, 0.95);
}

.hud-btn-codex {
    padding: 0 14px;
}

.hud-btn-lang {
    padding: 0 10px;
}

.btn-icon {
    font-size: 15px;
    line-height: 1;
}

.btn-text {
    font-size: 13px;
    letter-spacing: 0.5px;
}

.badge-count {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    background: rgba(255, 215, 0, 0.16);
    color: var(--gold-primary);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.35);
    font-variant-numeric: tabular-nums;
}

/* ==================== COLOR CODEX MODAL ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 6, 16, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 920px;
    max-height: 86vh;
    background: rgba(12, 17, 32, 0.88);
    backdrop-filter: blur(24px) saturate(190%);
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7),
                0 0 45px rgba(90, 130, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(18px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.025);
    gap: 16px;
}

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-title {
    font-family: 'Noto Serif SC', -apple-system, serif;
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
}

.modal-subtitle {
    font-size: 11px;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.modal-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.modal-progress {
    font-size: 12px;
    font-weight: 600;
    color: var(--gold-primary);
    padding: 4px 10px;
    background: rgba(255, 215, 0, 0.12);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.28);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg) scale(1.05);
}

.modal-close-btn:active {
    transform: rotate(90deg) scale(0.92);
}

.modal-body {
    padding: 20px 24px 28px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
}

/* Custom Sleek Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 6px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* --- Codex Grid & Cards --- */
.codex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.codex-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

/* Unlocked Card */
.codex-card.unlocked {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid hsla(var(--card-hue, 200), 75%, 60%, 0.38);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35),
                inset 0 0 20px hsla(var(--card-hue, 200), 80%, 50%, 0.08);
}

.codex-card.unlocked:hover {
    transform: translateY(-3px);
    border-color: hsla(var(--card-hue, 200), 85%, 65%, 0.65);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5),
                0 0 24px hsla(var(--card-hue, 200), 85%, 55%, 0.3);
}

/* Locked Card */
.codex-card.locked {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    opacity: 0.68;
}

.codex-card.locked:hover {
    opacity: 0.85;
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(255, 255, 255, 0.22);
}

.card-orb-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-orb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.25s ease;
}

.codex-card.unlocked:hover .card-orb {
    transform: scale(1.08);
}

.locked-orb {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--text-muted);
}

.card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.card-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.locked-name {
    color: var(--text-dim);
}

.card-range {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.locked-range {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-desc {
    font-family: 'Noto Serif SC', -apple-system, serif;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.locked-desc {
    color: var(--text-muted);
    font-style: italic;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}

.card-status {
    font-size: 10px;
    font-weight: 600;
}

.status-unlocked {
    color: var(--gold-primary);
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

.status-locked {
    color: var(--text-muted);
}

/* ==================== TUTORIAL PROMPT ==================== */
.tutorial-prompt {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    pointer-events: none;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 1;
}

.tutorial-prompt.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.tutorial-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 22px;
    background: rgba(12, 17, 34, 0.78);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 215, 0, 0.28);
    border-radius: 99px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.15);
    animation: promptFloat 3s ease-in-out infinite;
}

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

.tutorial-icon {
    font-size: 16px;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.tutorial-text {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.tutorial-sub {
    font-size: 11px;
    color: var(--gold-primary);
    opacity: 0.85;
}

/* ==================== STARDUST OVERDRIVE ==================== */
.overdrive-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    box-shadow: inset 0 0 100px rgba(255, 180, 0, 0.45);
    transition: opacity 0.5s ease;
}

.overdrive-overlay.active {
    opacity: 1;
    animation: overdriveVignettePulse 1.8s ease-in-out infinite alternate;
}

@keyframes overdriveVignettePulse {
    0% { box-shadow: inset 0 0 70px rgba(255, 160, 0, 0.35); }
    100% { box-shadow: inset 0 0 140px rgba(255, 215, 0, 0.65); }
}

.overdrive-banner {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px) scale(0.92);
    z-index: 96;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.35s;
}

.overdrive-banner.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

.overdrive-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 22px 10px 18px;
    background: rgba(35, 20, 10, 0.88);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
    border: 1px solid rgba(255, 215, 0, 0.6);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 200, 0, 0.35);
    overflow: hidden;
}

.overdrive-icon {
    font-size: 22px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.9));
    animation: iconPulse 1.2s ease-in-out infinite;
}

.overdrive-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.overdrive-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff275;
    letter-spacing: 0.6px;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.7);
}

.overdrive-desc {
    font-size: 11px;
    color: rgba(255, 240, 200, 0.9);
}

.overdrive-timer-track {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
}

.overdrive-timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff9100, #ffd700, #ff5252);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.9);
    transform-origin: left center;
    transform: scaleX(1);
    will-change: transform;
}

/* ==================== COSMIC EVENT BANNER ==================== */
.event-banner {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px) scale(0.92);
    z-index: 95;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.35s;
}

.event-banner.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

.event-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px 10px 18px;
    background: rgba(18, 22, 45, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(130, 180, 255, 0.4);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(100, 160, 255, 0.25);
    overflow: hidden;
}

.event-icon {
    font-size: 22px;
    filter: drop-shadow(0 0 8px rgba(130, 180, 255, 0.8));
    animation: iconPulse 2s ease-in-out infinite;
}

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

.event-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.event-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(130, 200, 255, 0.6);
}

.event-desc {
    font-size: 11px;
    color: rgba(220, 235, 255, 0.82);
}

.event-timer-track {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
}

.event-timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4fc3f7, #ba68c8, #ffd54f);
    box-shadow: 0 0 8px rgba(130, 200, 255, 0.8);
    transform-origin: left center;
    transform: scaleX(1);
    will-change: transform;
}

/* ==================== ACHIEVEMENT TOAST ==================== */
.toast-container {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 180;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.achievement-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: rgba(16, 22, 42, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 215, 0, 0.3);
    color: #ffffff;
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) 3.6s forwards;
    pointer-events: auto;
    max-width: 320px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(60px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.92);
    }
}

.toast-icon {
    font-size: 26px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-tag {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--gold-primary);
    text-transform: uppercase;
}

.toast-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

.toast-desc {
    font-size: 11px;
    color: var(--text-dim);
}

/* ==================== MODAL TABS & CONTENT ==================== */
.modal-tab-nav {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 3px;
    gap: 4px;
}

.tab-nav-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.tab-nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.tab-nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tab-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.tab-panel.active {
    display: flex;
}

.panel-header-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.5;
}

.note-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* ==================== ACHIEVEMENTS GRID & CARDS ==================== */
.achieve-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.achieve-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.achieve-card.unlocked {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.35);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), inset 0 0 20px rgba(255, 215, 0, 0.06);
}

.achieve-card.unlocked:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 215, 0, 0.65);
    background: rgba(255, 215, 0, 0.08);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 24px rgba(255, 215, 0, 0.25);
}

.achieve-card.locked {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    opacity: 0.65;
}

.achieve-card.locked:hover {
    opacity: 0.82;
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(255, 255, 255, 0.22);
}

.achieve-icon-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.achieve-card.unlocked .achieve-icon-wrap {
    background: radial-gradient(circle at 35% 35%, #ffe082, #ffb300, #ff8f00);
    box-shadow: 0 0 16px rgba(255, 179, 0, 0.6);
}

.achieve-card.locked .achieve-icon-wrap {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    filter: grayscale(1);
    opacity: 0.6;
}

.achieve-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.achieve-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.achieve-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.achieve-card.locked .achieve-title {
    color: var(--text-dim);
}

.achieve-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

.achieve-card.locked .achieve-desc {
    color: var(--text-muted);
}

.achieve-status {
    font-size: 10px;
    font-weight: 600;
    margin-top: 2px;
}

.status-achieved {
    color: var(--gold-primary);
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 680px) {
    #hud {
        padding: max(10px, env(safe-area-inset-top, 10px)) 12px 10px 12px;
        gap: 6px;
    }

    #score-box {
        padding: 6px 10px;
        min-width: 90px;
    }

    .hud-value {
        font-size: 16px;
    }

    .hud-value-sub {
        font-size: 11px;
    }

    #combo-badge {
        padding: 4px 10px 6px 10px;
        min-width: 95px;
    }

    .combo-multiplier {
        font-size: 16px;
    }

    .hud-btn {
        min-width: 38px;
        height: 38px;
        padding: 0 8px;
        font-size: 13px;
    }

    .hud-btn-codex {
        padding: 0 10px;
    }

    .btn-text {
        display: none;
    }

    .tutorial-prompt {
        bottom: 20px;
        width: calc(100% - 32px);
    }

    .tutorial-inner {
        padding: 8px 16px;
        text-align: center;
    }

    .tutorial-text {
        font-size: 12px;
    }

    .tutorial-sub {
        font-size: 10px;
    }

    .event-banner {
        top: 60px;
        width: calc(100% - 24px);
    }

    .event-content {
        padding: 6px 14px 8px 14px;
        gap: 10px;
    }

    .event-title {
        font-size: 12px;
    }

    .event-desc {
        font-size: 10px;
    }

    .toast-container {
        top: 64px;
        right: 12px;
        left: 12px;
    }

    .achievement-toast {
        max-width: 100%;
        padding: 10px 14px;
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal-card {
        max-height: 90vh;
        border-radius: 18px;
    }

    .modal-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .modal-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .modal-tab-nav {
        flex: 1;
    }

    .tab-nav-btn {
        padding: 5px 8px;
        font-size: 11px;
        flex: 1;
        text-align: center;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-subtitle {
        display: none;
    }

    .modal-body {
        padding: 14px 14px 20px 14px;
    }

    .codex-grid, .achieve-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}
