:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #22d3ee;
    --glass: rgba(30, 41, 59, 0.7);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(34, 211, 238, 0.15), transparent 40%);
    z-index: -1;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Search Form */
.search-container {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out;
}

.search-form {
    display: flex;
    gap: 1rem;
}

input[type="text"] {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

button:active {
    transform: translateY(0);
}

/* Search Result Links */
.player-card-link {
    display: block;
    margin-bottom: 1rem;
    transition: transform 0.2s ease;
}

.player-card-link:hover {
    transform: scale(1.02);
}

.view-btn {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Player Profile Styles */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-link:hover {
    color: var(--primary);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: var(--bg-dark);
}

.refresh-btn:hover {
    background: #06b6d4;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}

/* Stats Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 20px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    display: block;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Lists and Tables */
.data-section {
    margin-bottom: 3rem;
}

.data-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #fff;
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
}

.table-container {
    background: var(--bg-card);
    border-radius: 16px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 2rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.data-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Specific column widths and truncation for better distribution */
.data-table td:nth-child(1) {
    width: 140px;
}

/* Date */

.data-table td:nth-child(2) {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mode */

.data-table td:nth-child(3) {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Map */

.data-table td:nth-child(4) {
    width: 100px;
    text-align: center;
}

/* Duration */
.data-table td:nth-child(5) {
    width: 80px;
    text-align: center;
}

/* ELO */
.data-table td:nth-child(6) {
    width: 100px;
    text-align: center;
}

/* Result */
.data-table td:nth-child(7) {
    width: 120px;
    text-align: right;
}

/* Civ */

/* Cursor hint for truncated text */
.data-table td:nth-child(2),
.data-table td:nth-child(3) {
    cursor: help;
}

.win {
    color: #10b981;
}

.loss {
    color: #ef4444;
}

.match-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.civ-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
}

/* Results Area */
#results {
    margin-top: 2rem;
}

.player-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out backwards;
}

.player-card:hover {
    transform: translateX(10px);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

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

.player-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.player-id {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent);
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading Spinner */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

/* Improved Stats Layouts */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.data-card {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 20px;
}

.data-card h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
}

.stat-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-name {
    font-weight: 600;
    color: #fff;
    flex: 1;
}

.stat-progress-bg {
    flex: 2;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 0 1rem;
    overflow: hidden;
    position: relative;
}

.stat-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
}

.stat-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 60px;
    text-align: right;
}

.stat-percent {
    font-weight: 700;
    color: var(--accent);
    width: 50px;
    text-align: right;
}

/* Tilt Stats */
.psychology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.psych-card {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
}

.psych-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.psych-value {
    font-size: 1.25rem;
    font-weight: 800;
}

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

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

.spinning {
    animation: rotation 1s linear infinite;
}

footer {
    margin-top: auto;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}