/* styles.css - Capybara & Duck Feeding Frenzy (Top 10 Tournament & Avatar Selector) */

:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fef3c7;
    --secondary: #10b981;
    --accent: #38bdf8;
    --bg-main: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #14532d;
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: #15803d;
}

/* =========================================
   TOP HEADER HUD & TIMER & AVATAR BADGE
   ========================================= */
.sanctuary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 18px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid #f59e0b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 50;
    height: 62px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 28px;
    animation: gentle-wobble 2.5s infinite ease-in-out;
}

@keyframes gentle-wobble {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(8deg) scale(1.1); }
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 900;
    background: linear-gradient(135deg, #b45309, #d97706, #15803d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* User Avatar Customizer Badge */
.avatar-badge-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    padding: 5px 14px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.2);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.avatar-badge-btn:hover {
    transform: scale(1.06);
    border-color: #d97706;
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.35);
}

.badge-avatar-icon {
    font-size: 22px;
}

.badge-avatar-text {
    font-size: 0.85rem;
    font-weight: 800;
    color: #78350f;
}

.badge-edit-hint {
    font-size: 0.72rem;
    font-weight: 700;
    color: #b45309;
    background: #fffbeb;
    padding: 2px 8px;
    border-radius: 8px;
    border: 1px solid #fed7aa;
}

.match-timer-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    padding: 4px 16px;
    border-radius: 999px;
    font-size: 1.15rem;
    font-weight: 900;
    color: #78350f;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

.header-action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================
   MAIN VIEWPORT & TOP 10 LEADERBOARD
   ========================================= */
.sanctuary-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #65a30d;
}

#sanctuary-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Live Top 10 Tournament Leaderboard Overlay */
.live-leaderboard-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 250px;
    max-height: 82vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 2.5px solid #f59e0b;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 40;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #fffbeb;
    border-bottom: 2px solid #fde68a;
    font-weight: 800;
    font-size: 0.85rem;
    color: #78350f;
}

.lb-sub {
    font-size: 0.72rem;
    color: #92400e;
    font-weight: 700;
}

.lb-body {
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    max-height: calc(82vh - 36px);
}

.lb-player-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lb-player-row.is-user-row {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
    font-weight: 800;
}

.lb-rank {
    font-weight: 900;
    font-size: 0.78rem;
    color: #64748b;
    width: 22px;
}

.is-user-row .lb-rank {
    color: #b45309;
}

.lb-avatar {
    font-size: 17px;
}

.lb-info {
    flex: 1;
    overflow: hidden;
}

.lb-name {
    font-weight: 800;
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-stats {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

.lb-score {
    font-weight: 900;
    font-size: 0.9rem;
    color: #0f172a;
}

/* =========================================
   BOTTOM DRAG-AND-DROP FEEDING TRAY
   ========================================= */
.feeding-station-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 16px 12px 16px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 3px solid #f59e0b;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.1);
    z-index: 50;
}

.tray-instructions {
    font-size: 0.85rem;
    font-weight: 700;
    color: #78350f;
    margin-bottom: 6px;
}

.food-drag-tray {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 820px;
}

.food-item-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 16px;
    background: #ffffff;
    border: 2.5px solid #fed7aa;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    flex: 1;
    max-width: 110px;
    touch-action: none;
}

.food-item-btn:hover {
    transform: translateY(-4px) scale(1.06);
    border-color: #f59e0b;
    box-shadow: 0 8px 18px rgba(245, 158, 11, 0.25);
    background: #fffbeb;
}

.food-item-btn:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.food-item-btn .f-emoji {
    font-size: 30px;
    margin-bottom: 2px;
}

.food-item-btn .f-name {
    font-weight: 800;
    font-size: 0.82rem;
    color: #78350f;
}

.food-item-btn .f-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* =========================================
   AVATAR PICKER MODAL
   ========================================= */
.avatar-picker-modal {
    padding: 10px 0;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.avatar-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px;
    border-radius: 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.avatar-choice-btn:hover {
    border-color: #f59e0b;
    background: #fef3c7;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.2);
}

.avatar-choice-btn.selected {
    border-color: #d97706;
    background: #fde68a;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.avatar-choice-btn .av-icon {
    font-size: 38px;
    margin-bottom: 6px;
}

.avatar-choice-btn .av-label {
    font-weight: 800;
    font-size: 0.8rem;
    color: #78350f;
}

/* =========================================
   BUTTONS & GENERAL UI
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #cbd5e1;
}

.btn-accent {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 10px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    font-size: 1rem;
    background: #ffffff;
    border: 1.5px solid #fed7aa;
    color: #78350f;
}

.btn-icon:hover {
    transform: scale(1.08);
    background: #fff7ed;
    border-color: #f59e0b;
}

/* =========================================
   PODIUM RESULTS MODAL
   ========================================= */
.podium-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 10px;
}

.podium-header-banner h2 {
    font-size: 1.3rem;
    font-weight: 900;
    color: #78350f;
    text-align: center;
    margin-bottom: 18px;
}

.podium-stages {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    width: 100%;
    margin-bottom: 20px;
}

.podium-pillar {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.podium-pillar .crown-icon {
    font-size: 28px;
    position: absolute;
    top: -28px;
    animation: gentle-wobble 2s infinite ease-in-out;
}

.podium-pillar .podium-avatar {
    font-size: 40px;
    margin-bottom: 4px;
}

.podium-pillar .podium-name {
    font-weight: 800;
    font-size: 0.85rem;
    color: #1e293b;
    margin-bottom: 2px;
}

.podium-pillar .podium-score {
    font-weight: 900;
    font-size: 0.82rem;
    color: #d97706;
    margin-bottom: 6px;
}

.pillar-block {
    width: 95px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1rem;
    color: white;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.block-1 { height: 120px; background: linear-gradient(180deg, #f59e0b, #d97706); }
.block-2 { height: 90px; background: linear-gradient(180deg, #94a3b8, #64748b); }
.block-3 { height: 70px; background: linear-gradient(180deg, #d97706, #78350f); }

.results-stats-card {
    background: #fffbeb;
    border: 2px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    width: 100%;
    margin-bottom: 18px;
    text-align: center;
}

.results-stats-card h4 {
    font-size: 0.9rem;
    color: #78350f;
    margin-bottom: 8px;
}

.stat-badge-row {
    display: flex;
    justify-content: space-around;
    gap: 8px;
}

.stat-badge {
    background: white;
    border: 1.5px solid #fed7aa;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: #92400e;
}

.mg-btn-row {
    display: flex;
    gap: 12px;
}

/* =========================================
   UNIVERSAL MODALS
   ========================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-window {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 3px solid #f59e0b;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #fffbeb;
    border-bottom: 2px solid #fde68a;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 900;
    color: #78350f;
}

.modal-body {
    padding: 18px;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .sanctuary-header {
        padding: 4px 10px;
    }
    .brand-title {
        font-size: 0.9rem;
    }
    .live-leaderboard-panel {
        width: 190px;
        top: 6px;
        right: 6px;
    }
    .food-drag-tray {
        gap: 6px;
    }
    .food-item-btn {
        padding: 4px 6px;
    }
    .avatar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
