/* ========================================
   BASIC ANIMATIONS
   ======================================== */

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

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

@keyframes bounceIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

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

@keyframes pulse {

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

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes warning-blink {
    0%, 100% { border-color: rgba(244, 63, 94, 0.3); box-shadow: none; }
    50% { border-color: rgba(244, 63, 94, 1); box-shadow: 0 0 15px rgba(244, 63, 94, 0.6); }
}

.warning-blink {
    animation: warning-blink 0.5s ease-in-out 3;
    border-width: 2px !important;
}

@keyframes shake {

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

    25% {
        transform: translateX(-15px) rotate(-10deg);
    }

    75% {
        transform: translateX(15px) rotate(10deg);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }

    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* ========================================
   BALLOON ANIMATIONS (Speaking Mode)
   ======================================== */

@keyframes balloonFall {
    to {
        top: calc(100% - 200px);
    }
}

@keyframes wobble {

    0%,
    100% {
        transform: translateX(0) rotate(-2deg);
    }

    50% {
        transform: translateX(10px) rotate(2deg);
    }
}

@keyframes balloonPop {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.8;
    }

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

@keyframes balloonShake {

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

    25% {
        transform: translateX(-15px) rotate(-10deg);
    }

    75% {
        transform: translateX(15px) rotate(10deg);
    }
}

/* ========================================
   NOTIFICATION ANIMATIONS
   ======================================== */

@keyframes slide-in {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

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

@keyframes slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ========================================
   MOBILE TOAST ANIMATION
   ======================================== */

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    10% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    90% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* ========================================
   SKELETON LOADING
   ======================================== */

@keyframes skeleton-loading {
    0% {
        background-color: hsl(200, 20%, 80%);
    }

    100% {
        background-color: hsl(200, 20%, 95%);
    }
}

/* ========================================
   ANIMATION CLASSES
   ======================================== */

.anim-slide-up {
    animation: slideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.anim-bounce {
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.anim-fade-in {
    animation: fadeIn 0.3s ease-in forwards;
}

.anim-fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

.skeleton {
    animation: skeleton-loading 1s linear infinite alternate;
}

/* ========================================
   SPEAKING MODE COMPONENTS
   ======================================== */

.falling-balloon {
    position: absolute;
    top: -180px;
    padding: 20px 35px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: balloonFall 12s linear forwards, wobble 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
    min-width: 120px;
    text-align: center;
    box-shadow:
        inset -10px -10px 30px rgba(0, 0, 0, 0.2),
        inset 10px 10px 30px rgba(255, 255, 255, 0.3),
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.falling-balloon::after {
    content: '';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 25px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), transparent);
}

.falling-balloon.explode {
    animation: balloonPop 0.5s ease-out forwards !important;
}

.falling-balloon.shake {
    animation: balloonShake 0.5s ease-in-out, wobble 2s ease-in-out infinite !important;
}

/* ========================================
   BALLOON COLORS
   ======================================== */

.balloon-red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.balloon-blue {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.balloon-green {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.balloon-yellow {
    background: linear-gradient(135deg, #eab308, #ca8a04);
}

.balloon-purple {
    background: linear-gradient(135deg, #a855f7, #9333ea);
}

.balloon-pink {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.balloon-orange {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.balloon-cyan {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

/* ========================================
   MICROPHONE BUTTON
   ======================================== */

.mic-button {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: 4px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-button:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 15px 60px rgba(59, 130, 246, 0.6);
}

.mic-button:active,
.mic-button.recording {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 15px 60px rgba(239, 68, 68, 0.8);
    animation: pulse 0.8s infinite;
}

/* ========================================
   FEEDBACK & TRANSCRIPT
   ======================================== */

.feedback-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    color: #10b981;
    text-shadow: 0 0 30px rgba(16, 185, 129, 0.8);
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    pointer-events: none;
}

.transcript-display {
    position: fixed;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    z-index: 5;
    max-width: 80%;
    text-align: center;
}

/* ========================================
   TRANSITION CLASSES
   ======================================== */

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-fast {
    transition-duration: 150ms;
}

.transition-normal {
    transition-duration: 300ms;
}

.transition-slow {
    transition-duration: 500ms;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Mobil optimizasyonu aktifken */
.mobile-optimized {
    font-size: 14px;
}

/* Tablo kaydırma wrapper */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

@media (max-width: 768px) {

    /* PIN Kartı */
    #mon-pin-display {
        font-size: 24px !important;
    }

    #mon-mode-display {
        font-size: 12px !important;
    }

    /* Butonlar */
    .btn-monitor {
        padding: 10px 16px !important;
        font-size: 13px !important;
    }

    /* Tablo hücreleri */
    #mon-table-body td,
    #mon-indiv-table-body td {
        padding: 6px 4px !important;
        font-size: 11px !important;
    }

    #mon-table-body th,
    #mon-indiv-table-body th {
        padding: 8px 4px !important;
        font-size: 10px !important;
    }

    /* Tablo minimum genişlikleri */
    #mon-table-body table,
    #mon-indiv-table-body table {
        min-width: 100%;
    }

    /* Badge'ler */
    .bg-gray-200,
    .bg-green-50,
    .bg-red-50,
    .bg-amber-50 {
        padding: 2px 6px !important;
        font-size: 10px !important;
    }

    /* Oyun kartları */
    .bg-slate-800 {
        margin-bottom: 12px !important;
    }

    /* Mobilde gizlenecek kolonlar */
    .hide-mobile {
        display: none !important;
    }

    /* Progress bar mobil uyumu */
    .progress-bar-mobile {
        width: 100%;
        min-width: 60px;
    }

    /* Skor gösterimi */
    .score-mobile {
        font-size: 14px !important;
    }

    /* Oyuncu isimleri */
    .player-name-mobile {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Sınıf etiketleri */
    .class-badge-mobile {
        font-size: 9px !important;
        padding: 1px 4px !important;
        display: inline-block;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Speaking Mode - Mobil */
    .falling-balloon {
        font-size: 1.4rem;
        padding: 15px 25px;
        min-width: 90px;
    }

    .mic-button {
        width: 80px;
        height: 80px;
        bottom: 30px;
    }

    .feedback-text {
        font-size: 2.5rem;
    }

    .transcript-display {
        bottom: 130px;
        font-size: 1rem;
        padding: 10px 20px;
    }
}

/* ========================================
   TABLET RESPONSIVE STYLES
   ======================================== */

@media (min-width: 768px) and (max-width: 1024px) {
    #mon-pin-display {
        font-size: 28px !important;
    }

    .btn-monitor {
        padding: 12px 20px !important;
        font-size: 14px !important;
    }

    #mon-table-body td,
    #mon-indiv-table-body td {
        padding: 8px 6px !important;
        font-size: 12px !important;
    }

    .falling-balloon {
        font-size: 1.6rem;
        padding: 18px 30px;
        min-width: 100px;
    }

    .mic-button {
        width: 100px;
        height: 100px;
        bottom: 40px;
    }
}

/* ========================================
   LANDSCAPE MODE (Mobil Yatay)
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding: 8px !important;
    }

    h1,
    h2,
    h3 {
        font-size: 0.9em !important;
    }

    /* Tablo başlıkları daha küçük */
    #mon-table-body th,
    #mon-indiv-table-body th {
        padding: 4px 2px !important;
        font-size: 9px !important;
    }

    .falling-balloon {
        font-size: 1.2rem;
        padding: 12px 20px;
    }

    .mic-button {
        width: 70px;
        height: 70px;
        bottom: 20px;
    }

    .feedback-text {
        font-size: 2rem;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {

    button,
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
    }

    /* Tablo satırları */
    #mon-table-body tr,
    #mon-indiv-table-body tr {
        min-height: 44px;
    }

    /* Copy butonları için görsel feedback */
    .copy-btn:active {
        transform: scale(0.95);
        background-color: rgba(102, 126, 234, 0.3);
    }
}

/* ========================================
   DARK MODE OPTIMIZATIONS
   ======================================== */

@media (prefers-color-scheme: dark) {
    .table-scroll-wrapper::-webkit-scrollbar-track {
        background: #2d3748;
    }

    .table-scroll-wrapper::-webkit-scrollbar-thumb {
        background: #4a5568;
    }

    .table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
        background: #718096;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* GPU hızlandırma için */
.transition-colors,
.transition-all,
.falling-balloon,
.mic-button {
    will-change: transform, opacity;
}

/* Mobilde smooth scroll */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }

    /* Overflow scroll için momentum */
    .overflow-y-auto,
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   REPORT MOBILE STYLES
   ======================================== */

@media (max-width: 768px) {
    .report-table {
        font-size: 11px !important;
    }

    .report-table th {
        padding: 6px 4px !important;
        font-size: 9px !important;
    }

    .report-table td {
        padding: 8px 4px !important;
    }

    /* Rapor başlığı */
    .report-header {
        font-size: 18px !important;
        padding: 12px 0 !important;
    }
}

/* ========================================
   ACTIVE GAMES LIST MOBILE
   ======================================== */

@media (max-width: 768px) {
    #active-games-cards {
        gap: 12px !important;
    }

    .game-card-mobile {
        padding: 12px !important;
    }

    .game-card-mobile h3 {
        font-size: 14px !important;
    }

    .game-card-mobile .text-sm {
        font-size: 11px !important;
    }
}

/* ========================================
   ERROR & LOADING STATES
   ======================================== */

@media (max-width: 768px) {
    .error-message {
        font-size: 13px !important;
        padding: 12px !important;
    }
}

/* ========================================
   BADGE RESPONSIVE SIZES
   ======================================== */

@media (max-width: 768px) {
    .badge-xs {
        padding: 2px 6px;
        font-size: 9px;
        line-height: 1.2;
    }

    .badge-sm {
        padding: 3px 8px;
        font-size: 10px;
        line-height: 1.3;
    }

    .badge-md {
        padding: 4px 10px;
        font-size: 11px;
        line-height: 1.4;
    }
}

/* ========================================
   LOBBY CONNECTED PLAYERS
   ======================================== */

@media (max-width: 768px) {
    #connected-players {
        gap: 8px !important;
    }

    #connected-players>div {
        font-size: 11px !important;
        padding: 6px 12px !important;
    }
}

/* ========================================
   QUESTION DISPLAY MOBILE
   ======================================== */

@media (max-width: 768px) {
    #mon-q-text {
        font-size: 16px !important;
        line-height: 1.4 !important;
    }

    #mon-timer {
        height: 6px !important;
    }
}

/* ========================================
   MODAL & OVERLAY MOBILE
   ======================================== */

@media (max-width: 768px) {
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px !important;
    }
}

/* ========================================
   iOS SAFE AREA (iPhone X+)
   ======================================== */

@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .safe-top {
        padding-top: env(safe-area-inset-top);
    }

    .safe-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .safe-left {
        padding-left: env(safe-area-inset-left);
    }

    .safe-right {
        padding-right: env(safe-area-inset-right);
    }
}

/* ========================================
   HIGH DPI DISPLAYS
   ======================================== */

@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .text-sm {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ========================================
   REDUCED MOTION (Accessibility)
   ======================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .falling-balloon {
        animation: none !important;
    }

    .mic-button.recording {
        animation: none !important;
    }
}

/* ========================================
   LEADERBOARD & COMBO ANIMATIONS
   ======================================== */

/* Altın Seri (5'te 5) Parlaması */
@keyframes goldGlow {
    0%, 100% { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.5)); }
    50% { filter: drop-shadow(0 0 35px rgba(255, 215, 0, 1)); transform: scale(1.05); }
}
.gold-glow {
    animation: goldGlow 1.5s infinite ease-in-out;
}

/* Sıra Kaybetme Titremesi */
@keyframes shake-red {
    0%, 100% { transform: translateX(0); filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4));}
    20%, 60% { transform: translateX(-8px) rotate(-3deg); filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.8));}
    40%, 80% { transform: translateX(8px) rotate(3deg); }
}
.shake-red {
    animation: shake-red 0.5s ease-in-out;
}

/* Sıra Yükselme Parlaması */
@keyframes pulse-green {
    0% { transform: scale(0.95); filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.4)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 30px rgba(34, 197, 94, 1)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.4)); }
}
.pulse-green {
    animation: pulse-green 1s ease-in-out;
}