/* ===========================
   RESET & FOUNDATION
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===========================
   ANIMATED GRADIENT BACKGROUND
   =========================== */
.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    z-index: -1;
}

@keyframes gradientShift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* ===========================
   LANDING PAGE STYLES
   =========================== */
.landing-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.landing-container {
    width: 100%;
    max-width: 480px;
    animation: fadeInUp 0.8s ease-out;
}

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

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

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 40px;
}

.logo-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.logo-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid #FFD700;
    border-radius: 50%;
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {

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

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

.logo-emoji {
    font-size: 64px;
    line-height: 120px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.hero-title {
    font-size: 48px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
}

.title-line {
    display: block;
}

.gradient-text {
    background: linear-gradient(135deg, #FF8C00 0%, #FFD700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    max-width: 360px;
    margin: 0 auto 32px;
}

/* Stats Row */
.stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 8px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #FF8C00;
}

.stat-label {
    font-size: 12px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
}

/* Main Card */
.main-card {
    position: relative;
    padding: 40px 32px;
    margin-bottom: 24px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.05);
}

.card-glow {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #FFD700, #FF8C00);
    border-radius: 24px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
}

.main-card:hover .card-glow {
    opacity: 0.2;
}

.card-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: #1f2937;
    margin-bottom: 24px;
}

/* Input Group */
.input-group {
    margin-bottom: 32px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.input-wrapper input {
    width: 100%;
    padding: 16px 16px 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s;
}

.input-wrapper input:focus {
    background: white;
    border-color: #FFD700;
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.1);
}

.floating-label {
    position: absolute;
    left: 16px;
    top: 16px;
    font-size: 16px;
    color: #9ca3af;
    pointer-events: none;
    transition: all 0.3s;
}

.input-wrapper input:focus+.floating-label,
.input-wrapper input:not(:placeholder-shown)+.floating-label {
    top: 6px;
    font-size: 12px;
    color: #FF8C00;
    font-weight: 600;
}

.input-underline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #FF8C00, #FFD700);
    transition: width 0.3s;
    border-radius: 2px;
}

.input-wrapper input:focus~.input-underline {
    width: 100%;
}

.input-hint {
    font-size: 13px;
    color: #9ca3af;
    padding-left: 4px;
}

.input-hint.success {
    color: #10b981;
}

.input-hint.error {
    color: #ef4444;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    position: relative;
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid #FFD700;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(255, 140, 0, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 140, 0, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: white;
    color: #333;
}

.btn-secondary:hover {
    background: #fffdf0;
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 20px;
}

.btn-shine {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

.pulse-on-ready:not(:disabled) {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(255, 140, 0, 0.3);
    }

    50% {
        box-shadow: 0 4px 24px rgba(255, 140, 0, 0.5);
    }
}

/* Landing Footer */
.landing-footer {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 14px;
}

/* ===========================
   LEADERBOARD PAGE STYLES
   =========================== */
.leaderboard-page {
    min-height: 100vh;
    padding: 20px;
}

.leaderboard-wrapper {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out;
}

/* Leaderboard Header */
.leaderboard-header {
    position: relative;
    margin-bottom: 32px;
}

.back-button {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.back-button:hover {
    background: white;
    border-color: #FFD700;
    transform: translateX(-4px);
}

.back-arrow {
    font-size: 18px;
}

.header-content {
    text-align: center;
    padding-top: 60px;
}

.trophy-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.page-title {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 18px;
    color: #6b7280;
}

/* Leaderboard Card */
.leaderboard-card {
    position: relative;
    padding: 32px;
    margin-bottom: 24px;
    min-height: 400px;
}

/* Leaderboard Table */
.leaderboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.leaderboard-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    color: #6b7280;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.leaderboard-table tbody tr {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    transition: all 0.3s;
    animation: slideIn 0.5s ease-out backwards;
}

.leaderboard-table tbody tr:nth-child(1) {
    animation-delay: 0.1s;
}

.leaderboard-table tbody tr:nth-child(2) {
    animation-delay: 0.2s;
}

.leaderboard-table tbody tr:nth-child(3) {
    animation-delay: 0.3s;
}

.leaderboard-table tbody tr:nth-child(4) {
    animation-delay: 0.4s;
}

.leaderboard-table tbody tr:nth-child(5) {
    animation-delay: 0.5s;
}

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

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

.leaderboard-table tbody tr:hover {
    background: white;
    transform: translateX(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaderboard-table tbody tr.gold {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.15));
}

.leaderboard-table tbody tr.silver {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.15));
}

.leaderboard-table tbody tr.bronze {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.15));
}

.leaderboard-table td {
    padding: 20px 16px;
}

.leaderboard-table td:first-child {
    border-radius: 12px 0 0 12px;
}

.leaderboard-table td:last-child {
    border-radius: 0 12px 12px 0;
}

.rank-cell {
    font-size: 28px;
    font-weight: 700;
    width: 80px;
    text-align: center;
}

.player-cell {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.score-cell {
    font-size: 20px;
    font-weight: 700;
    color: #FF8C00;
    text-align: right;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 24px;
    opacity: 0.6;
}

.empty-state h2 {
    font-size: 28px;
    color: #1f2937;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 16px;
    color: #6b7280;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 80px 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Leaderboard Actions */
.leaderboard-actions {
    display: flex;
    justify-content: center;
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: white;
    border: 2px solid #ef4444;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: #fef2f2;
    transform: translateY(-2px);
}

/* ===========================
   GAME PAGE STYLES (From Previous)
   =========================== */
.game-page {
    overflow: hidden;
}

#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-layer {
    position: relative;
    z-index: 10;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.ui-card,
button,
img,
input {
    pointer-events: auto;
}

.ui-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#game-header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    align-items: center;
    padding: 12px 24px;
    min-width: 300px;
    justify-content: space-between;
}

#player-name {
    font-weight: 600;
    color: #1d1d1f;
}

#round-info {
    font-weight: 600;
    color: #86868b;
    background: rgba(134, 134, 139, 0.1);
    padding: 4px 12px;
    border-radius: 6px;
}

#image-card {
    position: absolute;
    top: 90px;
    left: 20px;
    width: 320px;
}

#image-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

#location-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #f5f5f7;
}

#score-card {
    position: absolute;
    top: 90px;
    right: 20px;
    text-align: center;
    padding: 20px 30px;
}

.score-label {
    font-size: 12px;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.score-value {
    font-size: 36px;
    font-weight: 700;
    color: #1d1d1f;
}

#submit-guess {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #FFD700, #FF8C00);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

#submit-guess:disabled {
    opacity: 0.5;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    padding: 32px;
}

.modal-content h1,
.modal-content h2 {
    margin-bottom: 16px;
}

.final-score {
    font-size: 56px;
    font-weight: 700;
    color: #FF8C00;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid #FFD700;
    border-radius: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 36px;
    }

    .stats-row {
        gap: 16px;
    }

    .main-card {
        padding: 32px 24px;
    }

    .page-title {
        font-size: 36px;
    }

    .leaderboard-card {
        padding: 20px;
    }

    .leaderboard-table td {
        padding: 16px 12px;
    }

    .rank-cell {
        font-size: 24px;
        width: 60px;
    }

    .player-cell {
        font-size: 16px;
    }

    .score-cell {
        font-size: 18px;
    }

    #image-card {
        width: calc(100% - 40px);
    }

    #score-card {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Result Modal Styling */
.result-location {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 140, 0, 0.15));
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 2px solid #FFD700;
}

.result-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #FF8C00;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.result-location-name {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.modal-content p {
    font-size: 16px;
    color: #6b7280;
    margin: 8px 0;
}

/* ===========================
   STORAGE SELECTION (LANDING)
   =========================== */
.storage-selection {
    margin-bottom: 32px;
    text-align: center;
}

.selection-label {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.storage-toggle {
    display: flex;
    position: relative;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 12px;
    width: 200px;
    margin: 0 auto 12px;
}

.storage-toggle input {
    display: none;
}

.storage-toggle label {
    flex: 1;
    padding: 8px;
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    transition: color 0.3s;
}

.toggle-icon {
    font-size: 14px;
}

.toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#storage-local:checked~.toggle-slider {
    transform: translateX(0);
}

#storage-global:checked~.toggle-slider {
    transform: translateX(100%);
}

#storage-local:checked~label[for="storage-local"],
#storage-global:checked~label[for="storage-global"] {
    color: #1f2937;
}

.selection-hint {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* ===========================
   VIEW TOGGLE (LEADERBOARD)
   =========================== */
.view-toggle-container {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.view-toggle {
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 14px;
    display: inline-flex;
    gap: 4px;
}

.toggle-btn {
    padding: 8px 24px;
    border-radius: 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-btn.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

/* ===========================
   ADMIN CONTROLS
   =========================== */
.admin-controls-footer {
    margin-top: 32px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 24px;
}

.admin-link {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s;
}

.admin-link:hover {
    color: #6b7280;
}

.login-modal {
    max-width: 400px;
    width: 90%;
    padding: 32px;
    text-align: left;
}

.login-modal h2 {
    margin-bottom: 8px;
    font-size: 24px;
}

.login-modal p {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 24px;
}

.error-text {
    color: #ef4444;
    font-size: 13px;
    margin-top: -16px;
    margin-bottom: 16px;
    padding-left: 4px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.delete-btn {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    color: #ef4444;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 12px;
}

.delete-btn:hover {
    background: #fee2e2;
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* ===========================
   TOP AUTH CONTAINER
   =========================== */
.top-auth-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.auth-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.auth-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: #FFD700;
}

.auth-btn.logged-in {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
    color: #065f46;
}

.auth-btn .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
}

.auth-btn.logged-in .status-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

@media (max-width: 768px) {
    .top-auth-container {
        top: 10px;
        right: 10px;
    }

    .auth-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}