* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}
@keyframes gradient-slide {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.header {
    text-align: center;
    margin-bottom: 28px;
    padding: 20px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8, #6366f1);
    background-size: 300% 300%;
    animation: gradient-slide 6s ease infinite, fadeInDown 1s ease-out;
    border-radius: 15px;
    color: white;
    font-size: 1.3em;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}
.header::after {
    content: '';
    position: absolute;
    top: 0; left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0.1) 100%);
    transform: skewX(-25deg);
    animation: shine 4s ease-in-out infinite;
}
.typing-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
}



.typing-input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* input tidak terlihat */
    z-index: 2;
    font-size: 1.3em;
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.8;
    border: none;
    resize: none;
    overflow: hidden;
}

.typing-input-overlay:focus {
    outline: none;
}
.current {
    background-color: #a2cdf0;
    color: #1565c0;
    border-right: 2px solid #1565c0;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    from, to { border-color: transparent }
    50% { border-color: #1565c0; }
}

@keyframes shine {
  0% { left: -75%; }
  100% { left: 125%; }
}

.typing-title {
    font-size: 3rem; /* Ukuran besar di desktop */
    text-align: center;
    font-weight: bold;
    color: white;
    margin-bottom: 10px;
}

/* Responsive: ukuran lebih kecil di mobile */
@media (max-width: 768px) {
    .typing-title {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .typing-title {
        font-size: 1.5rem;
    }
}


/* Keyframes untuk animasi gradien */
@keyframes gradient-animation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.user-info {
    text-align: center;
    margin-top: 10px;
}

.main-content {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.typing-area {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    width: 100%;
    max-width: 800px;
}

.text-display {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    font-size: 1.5em;
    word-spacing: 8px;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    height: calc(1.8em * 2 + 60px); /* 2 baris + padding */
    overflow-y: auto;
     scroll-behavior: smooth;
    position: relative;
}

.typing-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.3em;
    line-height: 1.8;
    resize: vertical;
    min-height: 120px;
    font-family: 'JetBrains Mono', 'Inter', 'Segoe UI', sans-serif;
}
/* Styling untuk loading spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 150px; /* Memastikan spinner memiliki ruang */
    color: #555;
    font-size: 1.2em;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1); /* Warna dasar spinner */
  border-left-color: #4CAF50; /* Warna bagian yang berputar (hijau) */
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite; /* Animasi berputar */
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Animasi untuk text-display saat teks dimuat */
.text-display-animated {
    animation: fadeInScale 0.8s ease-out forwards; /* Animasi fade-in dan scale */
    opacity: 0; /* Mulai tidak terlihat */
    transform: scale(0.95); /* Mulai sedikit diperkecil */
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
.typing-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #4CAF50;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.controls {
    text-align: center;
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    margin: 0 10px;
    transition: all 0.3s;
}

.btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.btn.secondary {
    background: #2196F3;
}

.btn.secondary:hover {
    background: #1976D2;
}

.chat-messages {
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 5px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.rank {
    font-weight: bold;
    color: #4CAF50;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.form-group input:focus {
    outline: none;
    border-color: #4CAF50;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.correct {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.incorrect {
    background-color: #ffcdd2;
    color: #c62828;
}

.current {
    background-color: #a2cdf0;
    color: #1565c0;
}

@media (max-width: 768px) {
    .main-content {
        padding: 10px;
    }
    .typing-area {
        padding: 15px;
    }
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    .btn {
        flex: 1;
        min-width: 120px;
    }
}

modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 25px;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.result-item {
  font-size: 1.2em;
  margin: 10px 0;
  color: #333;
  font-weight: bold;
}

.btn {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 10px 16px;
  margin: 10px 5px;
  border-radius: 6px;
  cursor: pointer;
}



@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 15px 5px rgba(245, 158, 11, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.btn-running {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: white;
    cursor: not-allowed;
    font-weight: bold;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
    animation: pulse 2s ease-in-out infinite;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#startBtn {
    display: none;
}

footer {
    margin-top: 60px;
    padding: 25px 20px;
    color: #444;
    text-align: center;
    font-size: 0.95em;
    border-top: 2px solid #ddd;
    border-radius: 12px 12px 0 0;
    transition: all 0.3s ease-in-out;
}

footer a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

footer a:hover {
    color: #388e3c;
    text-decoration: underline;
}

.progress-container {
    width: 100%;
    height: 6px;
    background-color: #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    transition: width 0.4s ease;
    border-radius: 8px;
}

#chatMessagesModal {
    max-height: 300px; /* atau sesuai kebutuhan */
    overflow-y: auto;
    scroll-behavior: smooth;
}


