/* 
    PWA Score Tracker - Modern Dark Theme
    Utilizing Inter Font and sleek Glassmorphism / neumorphism cues 
*/

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

:root {
    /* Default Dark Mode */
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --surface-elevated: #2C2C2C;
    --primary-color: #3b82f6;
    /* Blue */
    --primary-hover: #2563eb;
    --hit-color: #10b981;
    /* Emerald Green */
    --miss-color: #ef4444;
    /* Red */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #3f3f46;
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --transition-speed: 0.2s;
    --glass-bg: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #f3f4f6;
        --surface-color: #ffffff;
        --surface-elevated: #e5e7eb;
        --primary-color: #2563eb;
        --primary-hover: #1d4ed8;
        --hit-color: #059669;
        --miss-color: #dc2626;
        --text-main: #111827;
        --text-muted: #4b5563;
        --border-color: #d1d5db;
        --glass-bg: rgba(255, 255, 255, 0.8);
        --glass-border: rgba(0, 0, 0, 0.05);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    /* Remove mobile tap highlight */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 30px;
    /* buffer for scrolling */
    overflow-x: hidden;
}

/* 
    SPLASH SCREEN 
*/
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.splash-screen img {
    max-width: 200px;
    margin-bottom: 2rem;
    animation: pulse 2s infinite ease-in-out;
    background-color: white;
    /* Ensure visible on transparent dark backgrounds */
    border-radius: 20px;
    padding: 10px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--surface-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.8;
        transform: scale(0.95);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 0.8;
        transform: scale(0.95);
    }
}

/* 
    LAYOUT & CONTAINERS 
*/
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: white;
    /* Give icon a white background explicitly */
    padding: 2px;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.app-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--glass-border);
}

/* 
    TYPOGRAPHY & HEADERS 
*/
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    text-align: center;
}

.target-name-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    color: var(--text-main);
    border: none;
    border-bottom: 2px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-align-last: center;
    /* Center text in select for some browsers */
    font-family: inherit;
    transition: border-bottom-color var(--transition-speed);
}

.target-name-select:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

/* 
    BUTTONS & INPUTS 
*/
.btn {
    appearance: none;
    border: none;
    background: var(--surface-elevated);
    color: var(--text-main);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:active {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:active {
    background-color: var(--border-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-speed);
}

.icon-button:active {
    background-color: var(--surface-elevated);
}

.icon-button svg {
    width: 24px;
    height: 24px;
}

.text-input {
    width: 100%;
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 1rem;
    transition: border-color var(--transition-speed);
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 
    SHOOTER TABS 
*/
.shooter-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    /* Firefox */
}

.shooter-tabs::-webkit-scrollbar {
    display: none;
    /* Safari and Chrome */
}

.shooter-tab {
    background-color: var(--surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-speed);
}

.shooter-tab.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

/* 
    SCOREBOARD 
*/
.score-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.hits .stat-value {
    color: var(--hit-color);
}

.misses .stat-value {
    color: var(--miss-color);
}

.hit-ratio-bar {
    height: 6px;
    background-color: var(--surface-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--hit-color);
    transition: width 0.3s ease-out;
}

/* 
    STATION SELECTION 
*/
.station-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.station-selector-wrapper {
    flex: 1;
    position: relative;
}

.station-select {
    width: 100%;
    appearance: none;
    background-color: var(--surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.station-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 
    SHOT CONTROLS 
*/
.control-row {
    margin-bottom: 1.25rem;
}

.single-shots {
    display: flex;
    gap: 1rem;
}

.shot-selector {
    flex: 1;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid var(--glass-border);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    flex: 1;
    padding: 1rem 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.btn-hit {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--hit-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-miss {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--miss-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pair-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.pair-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    line-height: 1;
}

.btn-hit-both {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--hit-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
    flex-direction: column;
    gap: 0.2rem;
}

.btn-miss-both {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--miss-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    flex-direction: column;
    gap: 0.2rem;
}

.btn-mixed {
    background-color: var(--surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    flex-direction: column;
    gap: 0.2rem;
}

.btn-action::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.4;
    }

    100% {
        transform: scale(50, 50);
        opacity: 0;
    }
}

.btn-action:focus:not(:active)::after {
    animation: ripple 0.6s ease-out;
}

/* 
    ACTIVITY LOG 
*/
.activity-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.activity-list::-webkit-scrollbar {
    width: 4px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.activity-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.activity-item:last-child {
    border-bottom: none;
}

.log-hit {
    color: var(--hit-color);
}

.log-miss {
    color: var(--miss-color);
}

.log-mixed {
    color: var(--text-main);
}

/*
    SUMMARY LIST
*/
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.summary-table th,
.summary-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.summary-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.summary-table td.hits-col {
    color: var(--hit-color);
    font-weight: 600;
    text-align: center;
}

.summary-table td.misses-col {
    color: var(--miss-color);
    font-weight: 600;
    text-align: center;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

/* 
    HIT SEQUENCES
*/
.hit-sequence {
    display: flex;
    gap: 1px;
    justify-content: center;
    margin-top: 4px;
    flex-wrap: wrap;
    max-width: 80px;
    margin-left: auto;
    margin-right: auto;
}

.seq-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--surface-color);
}

.seq-hit {
    background-color: var(--hit-color);
}

.seq-miss {
    background-color: var(--miss-color);
}

.seq-pair {
    display: flex;
}

.seq-pair .seq-dot:nth-child(2) {
    margin-left: -4px;
}

/* 
    MODALS & TOASTS 
*/
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 400px;
    transform: translateY(20px);
    transition: transform var(--transition-speed);
    border: 1px solid var(--glass-border);
}

.modal-fullscreen {
    background-color: var(--bg-color);
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none !important;
    border-radius: 0;
    border: none;
    padding: 1.5rem 1rem;
    transform: translateY(100%);
    transition: transform var(--transition-speed);
}

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

.modal-overlay.active .modal-fullscreen {
    transform: translateY(0);
}

.modal h2,
.modal-fullscreen h2 {
    margin-bottom: 1rem;
    color: var(--text-main);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--surface-elevated);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}