/* ==========================================================================
   PREMIUM STOPWATCH CSS - ENHANCED WITH LEAF ANIMATION
   ========================================================================== */

/* Base Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #B27162;
    --secondary-color: #ffffff;
    --accent-gold: #ffd700;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    
    --gradient-primary: linear-gradient(135deg, #B27162 0%, #8B4B61 100%);
    --gradient-secondary: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --gradient-gold: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    --gradient-success: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    
    --shadow-soft: 0 8px 32px rgba(178, 113, 98, 0.1);
    --shadow-medium: 0 12px 48px rgba(178, 113, 98, 0.15);
    --shadow-strong: 0 20px 60px rgba(178, 113, 98, 0.25);
    
    --border-radius: 20px;
    --border-radius-small: 12px;
    --border-radius-large: 28px;
    
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gradient-secondary);
    min-height: 100vh;
    color: var(--primary-color);
    overflow-x: hidden;
    position: relative;
}

/* ==========================================================================
   BACKGROUND IMAGE LAYOUT - NATURAL SWAYING ANIMATION
   ========================================================================== */
.background-image {
    position: fixed;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background: url("background1.png") no-repeat center center;
    background-size: cover;
    z-index: -2;
    filter: brightness(0.9);
    animation: backgroundSway 15s ease-in-out infinite;
    transform-origin: center center;
}

/* Animasi natural seperti pohon tertiup angin */
@keyframes backgroundSway {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(1%, -0.5%) scale(1.02);
    }
    50% {
        transform: translate(-1%, 0.5%) scale(1.01);
    }
    75% {
        transform: translate(0.5%, -0.3%) scale(1.015);
    }
}

/* ==========================================================================
   ANIMATED BACKGROUND SYSTEM (Enhanced)
   ========================================================================== */
.animated-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.geometric-shape {
    position: absolute;
    background: var(--gradient-primary);
    opacity: 0.06;
    animation: shapeFloat 20s infinite ease-in-out;
}

.shape-1 {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    top: 20%;
    left: 5%;
    animation-delay: 0s;
}

.shape-2 {
    width: 60px;
    height: 60px;
    top: 70%;
    right: 10%;
    animation-delay: 5s;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.shape-3 {
    width: 100px;
    height: 100px;
    top: 40%;
    right: 20%;
    animation-delay: 10s;
    border-radius: var(--border-radius);
    transform: rotate(45deg);
}

.shape-4 {
    width: 50px;
    height: 50px;
    bottom: 30%;
    left: 15%;
    animation-delay: 15s;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

@keyframes shapeFloat {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg) scale(1); 
    }
    25% { 
        transform: translateY(-30px) rotate(90deg) scale(1.1); 
    }
    50% { 
        transform: translateY(-60px) rotate(180deg) scale(1); 
    }
    75% { 
        transform: translateY(-30px) rotate(270deg) scale(0.9); 
    }
}

.particle-container {
    position: absolute;
    width: 100%;
    height: 100%;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.2;
    animation: particleFloat 8s infinite linear;
}

.particle-1 { top: 10%; left: 20%; animation-delay: 0s; }
.particle-2 { top: 30%; left: 80%; animation-delay: 1.3s; }
.particle-3 { top: 60%; left: 10%; animation-delay: 2.6s; }
.particle-4 { top: 80%; left: 70%; animation-delay: 4s; }
.particle-5 { top: 20%; left: 60%; animation-delay: 5.3s; }
.particle-6 { top: 50%; left: 40%; animation-delay: 6.6s; }

@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.2;
    }
    90% {
        opacity: 0.2;
    }
    100% {
        transform: translateY(-100vh) translateX(100px) scale(0);
        opacity: 0;
    }
}

/* ==========================================================================
   MAIN LAYOUT & CONTAINER
   ========================================================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.7),
        rgba(178, 113, 98, 0.5)
    );
    z-index: -1;
}

/* ==========================================================================
   PREMIUM HEADER & LOGO SYSTEM
   ========================================================================== */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.logo-img {
    max-width: 350px;
    height: auto;
    display: block;
}

/* ==========================================================================
   MAIN CONTENT GRID
   ========================================================================== */
.main-content {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* ==========================================================================
   STOPWATCH SECTION
   ========================================================================== */
.stopwatch-section {
    position: relative;
}

.stopwatch-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-large);
    padding: 3rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(178, 113, 98, 0.1);
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.stopwatch-card.active {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--success-color);
    box-shadow: 0 0 30px rgba(40, 167, 69, 0.2);
}

.stopwatch-card.danger-zone {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--danger-color);
    animation: dangerPulse 0.5s infinite;
}

@keyframes dangerPulse {
    0%, 100% { box-shadow: 0 0 30px rgba(220, 53, 69, 0.3); }
    50% { box-shadow: 0 0 50px rgba(220, 53, 69, 0.5); }
}

.stopwatch-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
    transition: var(--transition-smooth);
}

.stopwatch-card.active::before {
    background: var(--gradient-success);
}

.stopwatch-card.danger-zone::before {
    background: linear-gradient(135deg, var(--danger-color), #e74c3c);
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Timer Display */
.timer-container {
    position: relative;
    margin: 2rem 0 3rem 0;
    text-align: center;
}

.timer-display {
    font-size: 8rem;
    font-weight: 900;
    font-family: 'Courier New', monospace;
    color: #333;
    letter-spacing: 0.05em;
    position: relative;
    z-index: 2;
    transition: var(--transition-smooth);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.timer-display.active {
    color: var(--success-color);
    text-shadow: 0 0 20px rgba(40, 167, 69, 0.3);
}

.timer-display.danger-zone {
    animation: timerPulse 0.3s infinite;
    color: var(--danger-color);
    text-shadow: 0 0 30px rgba(220, 53, 69, 0.5);
}

.timer-display.perfect-score {
    color: var(--accent-gold);
    animation: perfectGlow 1s infinite;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes perfectGlow {
    0%, 100% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.7)); }
    50% { filter: drop-shadow(0 0 40px rgba(255, 215, 0, 1)); }
}

/* Control Panel */
.control-panel {
    margin-top: 2rem;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.btn {
    position: relative;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.6s ease;
    z-index: 1;
}

.btn:hover::before {
    width: 200px;
    height: 200px;
}

.btn-icon {
    position: relative;
    z-index: 2;
    margin-bottom: 0.3rem;
}

.btn-text {
    position: relative;
    z-index: 2;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

.btn-start, .btn-reset {
    width: 90px;
    height: 90px;
    font-size: 1.4rem;
}

.btn-pause {
    width: 130px;
    height: 130px;
    font-size: 2.2rem;
}

.btn-start {
    background: var(--gradient-success);
}

.btn-pause {
    background: linear-gradient(135deg, var(--danger-color), #e74c3c);
}

.btn-reset {
    background: linear-gradient(135deg, #6c757d, #495057);
}

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

.btn:hover:not(:disabled) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-strong);
}

.btn:active:not(:disabled) {
    transform: translateY(-2px) scale(0.98);
}

.btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

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

/* Player Input */
.player-input {
    margin-bottom: 1.5rem;
}

.input-container {
    position: relative;
    margin-bottom: 1rem;
}

.input-container input {
    width: 100%;
    padding: 1.2rem 1.5rem;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid transparent;
    border-radius: var(--border-radius-small);
    color: var(--primary-color);
    transition: var(--transition-smooth);
    outline: none;
}

.input-container input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(178, 113, 98, 0.1);
    background: white;
}

.input-container label {
    position: absolute;
    top: 1.2rem;
    left: 1.5rem;
    font-size: 1.2rem;
    color: rgba(178, 113, 98, 0.6);
    transition: var(--transition-smooth);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-container input:focus + label,
.input-container input:not(:placeholder-shown) + label {
    top: -12px;
    left: 1rem;
    font-size: 0.9rem;
    color: var(--primary-color);
    background: white;
    padding: 0 0.5rem;
}

/* ==========================================================================
   LEADERBOARD SECTION
   ========================================================================== */
.leaderboard-section {
    position: relative;
}

.leaderboard-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-large);
    padding: 1rem;
    box-shadow: 0 4px 16px rgba(178, 113, 98, 0.05);
    height: fit-content;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.leaderboard-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(178, 113, 98, 0.1);
}

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

.trophy-icon {
    position: relative;
    width: 40px;
    height: 40px;
    background: var(--gradient-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary-color);
    animation: trophyFloat 3s ease-in-out infinite;
}

.trophy-glow {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: var(--gradient-gold);
    border-radius: 50%;
    opacity: 0.3;
    z-index: -1;
    animation: trophyGlow 2s ease-in-out infinite;
}

@keyframes trophyFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-3px) rotate(3deg); }
}

@keyframes trophyGlow {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.1; }
}

.leaderboard-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.leaderboard-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.3rem;
    max-height: 600px;
}

.leaderboard-content::-webkit-scrollbar {
    width: 4px;
}

.leaderboard-content::-webkit-scrollbar-track {
    background: rgba(178, 113, 98, 0.1);
    border-radius: 2px;
}

.leaderboard-content::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: rgba(178, 113, 98, 0.6);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(178, 113, 98, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-state p {
    font-size: 0.9rem;
}

/* Leaderboard Items */
.champion-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--border-radius-small);
    border-left: 3px solid var(--primary-color);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.champion-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateX(3px);
    box-shadow: var(--shadow-medium);
}

.champion-item:nth-child(1) { 
    border-left-color: var(--accent-gold);
}

.champion-item:nth-child(2) { 
    border-left-color: #c0c0c0;
}

.champion-item:nth-child(3) { 
    border-left-color: #cd7f32;
}

.rank-badge {
    position: relative;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    margin-right: 0.8rem;
}

.rank-1 .rank-badge { background: none; color: inherit; }
.rank-2 .rank-badge { background: none; color: inherit; }
.rank-3 .rank-badge { background: none; color: inherit; }

.champion-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.champion-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.champion-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.7rem;
    color: rgba(178, 113, 98, 0.7);
}

.time-info {
    text-align: right;
}

.champion-time {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.champion-diff {
    font-size: 0.7rem;
    color: rgba(178, 113, 98, 0.6);
    font-weight: 600;
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: var(--gradient-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-small);
    box-shadow: var(--shadow-strong);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    max-width: 300px;
    transform: translateX(400px);
    opacity: 0;
    transition: var(--transition-smooth);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    background: var(--gradient-success);
}

.toast.error {
    background: linear-gradient(135deg, var(--danger-color), #e74c3c);
}

.toast.warning {
    background: linear-gradient(135deg, var(--warning-color), #ffed4e);
    color: var(--primary-color);
}

.toast i {
    font-size: 1.1rem;
}

.toast-message {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ==========================================================================
   SHORTCUTS GUIDE
   ========================================================================== */
.shortcuts-guide {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(178, 113, 98, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8rem;
    z-index: 100;
    opacity: 0;
    transform: translateY(20px);
    animation: shortcutFade 6s ease-in-out;
}

@keyframes shortcutFade {
    0%, 90% { opacity: 0; transform: translateY(20px); }
    10%, 80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(20px); }
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--primary-color);
}

kbd {
    background: var(--gradient-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(178, 113, 98, 0.2);
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM
   ========================================================================== */
@media (max-width: 1200px) {
    .main-content {
        gap: 1.5rem;
    }
    .timer-display {
        font-size: 6rem;
    }
    .logo-img {
        max-width: 300px;
    }
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .timer-display {
        font-size: 5rem;
    }
    .stopwatch-card {
        padding: 2rem;
    }
    .leaderboard-card {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    .timer-display {
        font-size: 4rem;
    }
    .btn-pause {
        width: 100px;
        height: 100px;
        font-size: 1.8rem;
    }
    .btn-start,
    .btn-reset {
        width: 70px;
        height: 70px;
        font-size: 1.2rem;
    }
    .controls {
        gap: 1.5rem;
    }
    .shortcuts-guide {
        display: none;
    }
}

@media (max-width: 480px) {
    .timer-display {
        font-size: 3rem;
    }
    .stopwatch-card,
    .leaderboard-card {
        padding: 1.2rem;
    }
    .controls {
        flex-wrap: wrap;
        gap: 1rem;
    }
    .btn-pause {
        width: 80px;
        height: 80px;
        font-size: 1.5rem;
    }
    .btn-start,
    .btn-reset {
        width: 60px;
        height: 60px;
        font-size: 1rem;
    }
    .champion-item {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
        padding: 1rem;
    }
    .rank-badge {
        margin: 0;
    }
    .time-info {
        text-align: center;
    }
    .toast-container {
        left: 1rem;
        right: 1rem;
        top: 1rem;
    }
    .toast {
        max-width: none;
    }
}

/* ==========================================================================
   SPECIAL EFFECTS
   ========================================================================== */
.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    background: var(--accent-gold);
    animation: confetti 3s ease-out forwards;
    z-index: 1000;
}

@keyframes confetti {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Focus Styles for Accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn:focus {
    outline-color: white;
}

/* Fullscreen Button */
.fullscreen-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: var(--transition-fast);
    backdrop-filter: blur(5px);
    z-index: 100;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.fullscreen-btn:active {
    transform: scale(0.95);
}

/* Fullscreen Mode */
body.fullscreen-mode {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 2rem;
    box-sizing: border-box;
    overflow-y: auto;
    min-height: 100vh;
}

body.fullscreen-mode .container {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.fullscreen-mode .main-content {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 1000px;
    height: auto;
    gap: 2rem;
}

body.fullscreen-mode .stopwatch-section,
body.fullscreen-mode .leaderboard-section {
    width: 100%;
    max-width: 100%;
}

body.fullscreen-mode .stopwatch-card {
    border-radius: var(--border-radius-large);
    padding: 3rem;
    width: 100%;
    height: auto;
    display: block;
}

body.fullscreen-mode .timer-display {
    font-size: 8rem;
}

body.fullscreen-mode .control-panel {
    margin-top: 2rem;
}

body.fullscreen-mode .player-input {
    width: 80%;
    max-width: 500px;
    margin: 0 auto;
}

body.fullscreen-mode .leaderboard-card {
    width: 100%;
    height: auto;
    max-height: 100%;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    body.fullscreen-mode .timer-display {
        font-size: 5rem;
    }
    body.fullscreen-mode .stopwatch-card {
        padding: 2rem;
    }
}