/* ==========================================================================
   Arrow Crash - Modern Casual Mobile Stylesheet
   ========================================================================== */

:root {
    --bg-dark: #0B0F19;
    --bg-card: #1E293B;
    --border-color: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --accent-blue: #3B82F6;
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --accent-yellow: #F59E0B;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #030712;
    color: var(--text-primary);
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    max-width: 440px;
    height: 100%;
    max-height: 920px;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

/* ==========================================================================
   Top HUD
   ========================================================================== */

#hud-top {
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

.hud-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-info {
    display: flex;
    flex-direction: column;
}

#hud-level-num {
    font-size: 11px;
    font-weight: 800;
    color: var(--accent-blue);
    letter-spacing: 1px;
}

#hud-level-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.build-badge {
    font-size: 10px;
    font-weight: 700;
    color: #64748B;
    background: rgba(30, 41, 59, 0.7);
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: -0.2px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn:active {
    transform: scale(0.92);
    background: #334155;
}

.icon-btn.highlight {
    background: #2563EB;
    border-color: #3B82F6;
}

.icon-btn.highlight:active {
    background: #1D4ED8;
}

/* ==========================================================================
   Sub Guide Bar
   ========================================================================== */

#sub-guide {
    padding: 8px 16px;
    background: rgba(30, 41, 59, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #CBD5E1;
    font-weight: 500;
    line-height: 1.4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.phase-badge {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #FFF;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
    white-space: nowrap;
}

.phase-badge.hidden {
    display: none !important;
}

/* ==========================================================================
   Main Game Viewport
   ========================================================================== */

#game-container {
    flex: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* ==========================================================================
   Bottom HUD
   ========================================================================== */

#hud-bottom {
    min-height: 48px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    gap: 8px;
}

.fgt-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fgt-btn {
    background: #1E293B;
    border: 1px solid #334155;
    color: #94A3B8;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.fgt-btn:active {
    transform: scale(0.95);
    background: #334155;
}

.fgt-btn.text-danger {
    color: #F87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.tip-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tip-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.modal-footer-fgt {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 8px;
    width: 100%;
}

.fgt-btn-large {
    flex: 1;
    padding: 10px 8px;
    border-radius: 12px;
    background: #334155;
    border: 1px solid #475569;
    color: #F8FAFC;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fgt-btn-large:active {
    transform: scale(0.96);
    background: #475569;
}

.fgt-btn-large.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #FCA5A5;
}

.fgt-btn-large.danger:active {
    background: rgba(239, 68, 68, 0.3);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #3B82F6;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    color: #60A5FA;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 20px;
    z-index: 999;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 15px);
    display: none !important;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 7, 18, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 24px;
    padding: 28px 24px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal-card h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
    word-break: keep-all;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary {
    width: 100%;
    height: 52px;
    background: linear-gradient(135deg, #2563EB, #3B82F6);
    color: #FFFFFF;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
    transition: transform 0.15s ease;
}

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

.btn-primary.retry {
    background: linear-gradient(135deg, #DC2626, #EF4444);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
}

/* 레벨 선택 모달 */
.level-list-modal {
    max-height: 80%;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 18px;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
    max-height: min(62vh, 480px);
}

.level-pill {
    background: #0F172A;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.level-pill strong {
    font-size: 14px;
    color: var(--accent-blue);
}

.level-pill span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.level-pill.active {
    border-color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.15);
}

.level-pill.mega-pill {
    border-color: #F59E0B;
    background: rgba(245, 158, 11, 0.12);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.level-pill.mega-pill strong {
    color: #F59E0B;
}

.chapter-section-title {
    grid-column: 1 / -1;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-secondary);
    padding: 8px 4px 4px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chapter-section-title.boss-section {
    color: #F59E0B;
    border-color: rgba(245, 158, 11, 0.25);
    margin-top: 6px;
}

.badge-boss {
    background: #F59E0B;
    color: #0F172A;
    font-size: 9px;
    font-weight: 900;
    padding: 2px 5px;
    border-radius: 4px;
    margin-right: 4px;
    display: inline-block;
}

.level-pill:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}
