/* ==========================================================================
   Design Tokens & Modern Dark Mode Base
   ========================================================================== */

:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Color System */
    --bg-base: #090a0f;
    --bg-surface: #12141c;
    --bg-surface-elevated: #1a1d29;
    --bg-surface-hover: rgba(255, 255, 255, 0.04);

    /* Brand & Accents */
    --primary: #ffaa00;
    --primary-hover: #e69900;
    --primary-glow: rgba(255, 170, 0, 0.25);

    --search-btn-bg: #3b82f6;
    --search-btn-hover: #2563eb;

    /* Typography */
    --text-main: #ffffff;
    --text-muted: #94a3b8;

    /* Borders & UI Elements */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(255, 170, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);

    --transition: 0.2s ease;
}

/* ==========================================================================
   Base Resets & Global Styles
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.homepage {
    padding: 0 1rem !important; /* Keep constrained for standard view */
}

/* Accessibility Utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h1.sitename {
    font-family: monospace;
}

h2 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

a {
    color: inherit;
    transition: color var(--transition);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header {
    position: sticky; /* Fixed missing property for top: 0 */
    top: 0;
    z-index: 100;
    background: rgba(18, 20, 28, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.header_container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.nav_bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo_link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    width: 2.75rem;
    height: 2.75rem;
    transition: transform var(--transition);
    filter: drop-shadow(0 2px 8px var(--primary-glow));
}

.logo_link:hover .logo {
    transform: scale(1.08) rotate(-2deg);
}

/* ==========================================================================
   Search Container & Box
   ========================================================================== */

.search_container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0 2.5rem 0;
    width: 100%;
    padding: 2rem 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.search_box {
    width: 100%;
    max-width: 480px;
    position: relative;
}

#search_form {
    display: flex;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition), border-radius var(--transition);
}

#search_form:has(input:focus) {
    border-color: var(--search-btn-hover);
}

.search_box:has(.recent_searches_dropdown[style*="display: block"]) #search_form {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

#player_search {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    outline: none;
    width: 100%;
}

#player_search::placeholder {
    color: var(--text-muted);
}

#search_form input[type="submit"] {
    background: var(--search-btn-bg);
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--transition);
}

#search_form input[type="submit"]:hover {
    background: var(--search-btn-hover);
}

/* Recent Searches Dropdown */
.recent_searches_dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface-elevated); /* Replaced hardcoded hex */
    border: 1px solid var(--border-subtle);       /* Replaced hardcoded hex */
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    list-style: none;
    z-index: 10;
    display: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.recent_searches_dropdown li {
    padding: 0.75rem 1rem;
    color: var(--text-muted); /* Replaced hardcoded hex */
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color var(--transition), color var(--transition);
}

.recent_searches_dropdown li:hover {
    background-color: var(--bg-surface-hover); /* Replaced hardcoded hex */
    color: var(--text-main);
}

.recent_searches_dropdown li:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.search_box:has(input:focus) .recent_searches_dropdown {
    border-color: var(--search-btn-hover);
    clip-path: inset(0 -2px -2px -2px); /* Cleaner shadow clipping */
}

/* ==========================================================================
   Views & Structural Components
   ========================================================================== */

.view { display: none; }
.view.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.card_signature {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 2rem;
}

.player_header_title {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.player_header_title .rank {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.player_details, .leaderboard_header {
    padding: 1.5rem;
    text-align: center;
}

.last_updated {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Loading States */
.player_info_prompt,
.leaderboard_prompt,
.skills_prompt,
.activities_prompt {
    display: grid;
    place-content: center;
    min-height: 180px;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* ==========================================================================
   Tables & Data Presentation
   ========================================================================== */

.table_container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data_table, .player_stats_table {
    width: 100%;
    border-collapse: collapse;
}

.data_table { text-align: center; }

th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

tr:last-child td { border-bottom: none; }
tr { transition: background-color var(--transition); }
tr:hover td { background-color: var(--bg-surface-hover); }

.name-cell a:hover { color: var(--primary-hover); }

/* Specific Player Stat Alignment */
.player_stats_table td.stat_name {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
}

.player_stats_table td.stat_val {
    text-align: right;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs_container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tabs {
    display: flex;
    background: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

.tab_button {
    flex: 1;
    padding: 1rem;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
    position: relative;
}

.tab_button:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-hover);
}

.tab_button.active { color: var(--primary); }

.tab_button.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 -2px 8px var(--primary-glow);
}

.tab_content { display: none; }
.tab_content.active { display: block; }

/* ==========================================================================
   Game Mode Selector
   ========================================================================== */

.selector-container {
    width: 100%;
    margin: 2rem auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 1rem 0;
    display: grid;
    grid-template-columns: 1fr max-content 1fr;
}

.selector-title {
    grid-column: 1 / -1;
    justify-self: center;
    text-align: center;
    padding: 1rem 1.5rem;
    display: none;
}

.mode-category, .mode-list {
    grid-column: 2;
    width: 100%;
    text-align: left;
}

.fullscreen-menu .selector-title {
    display: block;
    margin-top: 2rem;
}

.fullscreen-menu .selector-container {
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    background: transparent;
    padding: 2rem 0;
}

/* Categories & Lists Details */
.mode-category {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1.5rem 1.5rem 0.5rem;
}

.mode-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.mode-item a {
    display: block;
    padding: 0.875rem 1.5rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color var(--transition), color var(--transition);
}

.mode-list:last-child .mode-item:last-child a {
    border-bottom: none;
}

.mode-item a:hover {
    background-color: var(--bg-surface-hover);
    color: var(--primary);
}

/* ==========================================================================
   Hamburger & Full-Screen Menu
   ========================================================================== */

.hamburger {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.75rem;
    cursor: pointer;
    margin-left: auto;
    transition: color var(--transition);
}

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

.fullscreen-menu {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-base);
    z-index: 9999;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.fullscreen-menu.open {
    opacity: 1;
    pointer-events: all;
}

.menu-close {
    position: absolute;
    top: 1.5rem; right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 2rem;
    cursor: pointer;
    transition: transform var(--transition), color var(--transition);
}

.menu-close:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    padding: 2rem 1rem;
    text-align: center;
}

.madeby {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 1rem 0;
}

.madeby a {
    color: var(--text-muted);
}

.copyright_disclaimer {
    max-width: 600px;
    margin: 0 auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.75;
}

/* Player Page Specifics */
.back_link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

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

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 600px) {
    body { font-size: 1rem; }

    .logo {
        width: 2.25rem;
        height: 2.25rem;
    }

    #player_search { font-size: 0.875rem; }
    #search_form input[type="submit"] { font-size: 0.75rem; }

    /* Tables */
    .table_container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 0.65rem 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .data_table th { letter-spacing: 0; }
}

/* ==========================================================================
   Homepage Specific Styles
   ========================================================================== */

.home-hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.home-title {
    font-family: monospace;
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.home-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 500px;
    margin: 0 auto;
}

.home-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 3rem 0;
}

.home-section-title {
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.mode-card {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition);
}

.mode-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-surface-elevated);
}