/* ===============================
   📜 MAFİYA QAYDALARI - PREMIUM STYLES
   OPTİMİZƏ EDİLMİŞ - PC / TABLET / MOBİL / PWA READY
   =============================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', sans-serif;
}

/* ===== DƏYİŞKƏNLƏR ===== */
:root {
    --primary: #c41e3a;
    --primary-dark: #8b0000;
    --secondary: #0a0c0f;
    --accent: #ffd700;
    --dark: #030405;
    --darker: #010101;
    --light: #e5e5e5;
    --gray: #2a2a2a;
    --gray-light: #3a3a3a;
    --glass: rgba(10, 10, 15, 0.7);
    --glass-border: rgba(196, 30, 58, 0.2);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    --glow: 0 0 30px rgba(196, 30, 58, 0.3);
    --text-glow: 0 0 10px rgba(196, 30, 58, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Rol rəngləri */
    --mafia-color: #c41e3a;
    --mafia-glow: 0 0 20px rgba(196, 30, 58, 0.5);
    --terrorist-color: #ff8c00;
    --terrorist-glow: 0 0 20px rgba(255, 140, 0, 0.5);
    --special-color: #4a90e2;
    --special-glow: 0 0 20px rgba(74, 144, 226, 0.5);
    --citizen-color: #2ecc71;
    --citizen-glow: 0 0 20px rgba(46, 204, 113, 0.5);
}

/* ===== PERFORMANS OPTİMİZASİYASI ===== */
.role-card, .back-button, .nav-btn, .section-header, .rule-item, .win-condition {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, opacity;
}

/* Scroll zamanı animasiyaları dayandır */
body.is-scrolling * {
    animation-play-state: paused !important;
    transition: none !important;
}

body.is-scrolling .bg-particles {
    opacity: 0.2 !important;
}

/* ===== GLOBAL RESET ===== */
html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--darker);
    color: var(--light);
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: relative;
    background: radial-gradient(circle at 50% 0%, var(--primary-dark) 0%, var(--darker) 100%);
}

/* ===== BACKGROUND SYSTEM ===== */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, rgba(196,30,58,0.15) 0%, transparent 70%),
                radial-gradient(ellipse at bottom, rgba(0,0,0,0.8) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 10px 10px, rgba(196,30,58,0.4) 1px, transparent 0),
        radial-gradient(2px 2px at 30px 70px, rgba(255,215,0,0.3) 1px, transparent 0),
        radial-gradient(3px 3px at 90px 40px, rgba(255,255,255,0.2) 1px, transparent 0);
    background-size: 500px 500px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
    will-change: transform, opacity;
}

.bg-noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJmIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjc0IiBudW1PY3RhdmVzPSIzIiAvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNmKSIgb3BhY2l0eT0iMC4wNCIgLz48L3N2Zz4=');
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
}

/* ===== MAIN CONTAINER ===== */
.rules-container {
    position: relative;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 100px 24px;
    min-height: 100vh;
    z-index: 2;
}

/* ===== HEADER ===== */
.rules-header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeIn 0.8s ease-out;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 30px;
    float: left;
}

.back-button:hover {
    transform: translateX(-5px);
    border-color: var(--primary);
    box-shadow: var(--glow);
}

.back-button i {
    color: var(--primary);
}

.title-section {
    clear: both;
    margin-bottom: 30px;
}

h1 {
    font-size: clamp(2.5rem, 10vw, 4.5rem);
    font-weight: 900;
    text-transform: uppercase;
    color: transparent;
    -webkit-text-stroke: 2px var(--primary);
    text-shadow: 0 0 30px rgba(196,30,58,0.5);
    letter-spacing: 4px;
    margin-bottom: 20px;
    animation: titleGlow 2s infinite alternate;
}

.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    animation: glitchLeft 0.3s infinite linear alternate-reverse;
    color: #00ffff;
    -webkit-text-stroke: 2px #00ffff;
    z-index: -1;
}

.glitch::after {
    animation: glitchRight 0.3s infinite linear alternate-reverse;
    color: #ff00ff;
    -webkit-text-stroke: 2px #ff00ff;
    z-index: -2;
}

.title-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.badge-line {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.badge-text {
    font-size: 0.9rem;
    letter-spacing: 3px;
    color: var(--accent);
    font-weight: 600;
}

.warning-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    color: var(--primary);
    font-size: 0.9rem;
    letter-spacing: 2px;
    opacity: 0.8;
}

.warning-icon i {
    font-size: 1.2rem;
    animation: warningPulse 2s infinite;
}

/* ===== SECTIONS ===== */
.role-section {
    margin-bottom: 60px;
    animation: slideUp 0.5s ease-out;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    position: relative;
    cursor: pointer;
}

.section-icon {
    width: 50px;
    height: 50px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
}

.section-header h2 {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 1px;
}

.section-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), transparent);
}

/* ===== ROLES GRID ===== */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.single-role {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto;
}

/* ===== ROLE CARDS ===== */
.role-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 25px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: cardAppear 0.5s ease-out backwards;
}

.role-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--glow);
}

/* Rol xüsusi rəngləri */
.don-card { border-left: 4px solid var(--mafia-color); }
.mafia-card { border-left: 4px solid var(--mafia-color); }
.aferist-card { border-left: 4px solid var(--mafia-color); }
.vekil-card { border-left: 4px solid var(--mafia-color); }
.terrorist-card { border-left: 4px solid var(--terrorist-color); }
.komissar-card { border-left: 4px solid var(--special-color); }
.doktor-card { border-left: 4px solid var(--special-color); }
.cavus-card { border-left: 4px solid var(--special-color); }
.maq-card { border-left: 4px solid var(--special-color); }
.bomj-card { border-left: 4px solid var(--special-color); }
.citizen-card { border-left: 4px solid var(--citizen-color); }

.role-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.role-icon i {
    font-size: 2rem;
    color: var(--light);
}

.role-title h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.role-sub {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
    font-weight: 400;
    margin-left: 10px;
}

.role-quote {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    font-style: italic;
}

.role-quote i {
    color: var(--primary);
    font-size: 0.8rem;
    opacity: 0.7;
}

.role-quote p {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
}

.role-abilities {
    margin: 15px 0;
}

.ability {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.ability i {
    width: 20px;
    color: var(--primary);
}

.ability.night i { color: #4a90e2; }
.ability.day i { color: #f1c40f; }
.ability.special i { color: #9b59b6; }
.ability.warning i { color: #e74c3c; }

.ability span {
    font-size: 0.9rem;
    line-height: 1.4;
}

.role-quote-end {
    margin-top: 15px;
    text-align: right;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ===== SPECIAL RULES ===== */
.special-rules, .game-rules, .game-end {
    margin: 60px 0;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.rule-item {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    gap: 15px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.rule-item:hover {
    transform: translateX(5px);
    border-color: var(--primary);
}

.rule-icon {
    min-width: 60px;
    height: 60px;
    background: rgba(196,30,58,0.1);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 1.2rem;
}

.rule-icon i:first-child { color: var(--primary); }
.rule-icon i:last-child { color: var(--accent); }

.rule-text h4 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.rule-text p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    line-height: 1.5;
}

/* ===== TIMELINE ===== */
.timeline {
    max-width: 500px;
    margin: 30px auto;
}

.timeline-item {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 25px;
}

.timeline-item.night { border-left: 4px solid #4a90e2; }
.timeline-item.day { border-left: 4px solid #f1c40f; }

.timeline-time {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.timeline-time i { font-size: 1.5rem; }
.timeline-item.night .timeline-time i { color: #4a90e2; }
.timeline-item.day .timeline-time i { color: #f1c40f; }

.timeline-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    font-size: 0.9rem;
}

.action.special { background: rgba(196,30,58,0.1); }

.role-tag {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.role-tag.mafia { background: var(--mafia-color); }
.role-tag.komissar { background: var(--special-color); }
.role-tag.doktor { background: #27ae60; }
.role-tag.vekil { background: #8e44ad; }
.role-tag.aferist { background: #7f8c8d; }
.role-tag.bomj { background: #d35400; }
.role-tag.maq { background: #9b59b6; }

.timeline-arrow {
    text-align: center;
    margin: 10px 0;
    color: var(--primary);
    animation: bounce 2s infinite;
}

/* ===== WIN CONDITIONS ===== */
.win-conditions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.win-condition {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s ease;
}

.win-condition:hover {
    transform: scale(1.02);
}

.win-condition i {
    font-size: 2rem;
}

.win-condition.mafia-win i { color: var(--mafia-color); }
.win-condition.citizen-win i { color: var(--citizen-color); }
.win-condition.terrorist-win i { color: var(--terrorist-color); }

.win-condition h4 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.win-condition p {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 20px 30px;
    background: linear-gradient(to top, var(--dark), transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 100px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease, background 0.2s ease;
    font-size: 0.8rem;
}

.nav-btn i {
    font-size: 1.5rem;
}

.nav-btn.active {
    color: var(--primary);
    background: rgba(196,30,58,0.1);
    transform: translateY(-8px);
}

.nav-btn:hover {
    color: var(--light);
}

/* ===== TOAST SYSTEM ===== */
.toast-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    z-index: 1000;
}

.toast {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 12px 24px;
    color: var(--light);
    font-size: 0.9rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast-show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { border-left: 4px solid #2ecc71; }
.toast-error { border-left: 4px solid #e74c3c; }
.toast-warning { border-left: 4px solid #f39c12; }
.toast-info { border-left: 4px solid var(--primary); }

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== TELEFON OPTİMİZASİYASI ===== */
@media (max-width: 768px) {
    /* Glass effektini yüngülləşdir */
    .back-button, .role-card, .rule-item, .win-condition, .bottom-nav, .section-icon {
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
    }
    
    /* Hover effektlərini telefon üçün uyğunlaşdır */
    .role-card:hover {
        transform: translateY(-3px);
    }
    
    .role-card:active {
        transform: scale(0.98);
    }
    
    .rule-item:hover {
        transform: translateX(3px);
    }
    
    .win-condition:hover {
        transform: scale(1.01);
    }
    
    /* Particle-ları azaldırıq */
    .bg-particles {
        background-image: 
            radial-gradient(2px 2px at 10px 10px, rgba(196,30,58,0.2) 1px, transparent 0) !important;
    }
    
    /* Bottom navigation daha yığcam */
    .bottom-nav {
        padding: 8px 16px 20px;
    }
    
    .nav-btn {
        padding: 4px 8px;
    }
    
    .nav-btn.active {
        transform: translateY(-4px);
    }
    
    /* Axtarış inputu */
    .search-container input {
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
    }
    
    /* Animasiyaları yavaşlat */
    .glitch::before,
    .glitch::after {
        animation-duration: 0.5s !important;
    }
    
    .timeline-arrow {
        animation-duration: 1.5s !important;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes particleFloat {
    0% { background-position: 0 0; }
    100% { background-position: 500px 500px; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes titleGlow {
    from {
        text-shadow: 0 0 30px rgba(196,30,58,0.3);
    }
    to {
        text-shadow: 0 0 50px rgba(196,30,58,0.8);
    }
}

@keyframes glitchLeft {
    0% { transform: translate(0); }
    20% { transform: translate(-3px, 2px); }
    40% { transform: translate(-3px, -2px); }
    60% { transform: translate(3px, 2px); }
    80% { transform: translate(3px, -2px); }
    100% { transform: translate(0); }
}

@keyframes glitchRight {
    0% { transform: translate(0); }
    20% { transform: translate(3px, -2px); }
    40% { transform: translate(3px, 2px); }
    60% { transform: translate(-3px, -2px); }
    80% { transform: translate(-3px, 2px); }
    100% { transform: translate(0); }
}

@keyframes warningPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

/* ===== RESPONSIVE DESIGN ===== */

/* PC Large */
@media screen and (min-width: 1440px) {
    .rules-container { padding: 30px 40px 120px 40px; }
    .roles-grid { gap: 35px; }
}

/* PC Medium */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    .roles-grid { gap: 25px; }
}

/* Tablet */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .roles-grid { grid-template-columns: repeat(2, 1fr); }
    .single-role { grid-template-columns: 1fr; }
}

/* Mobile Landscape */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .roles-grid { grid-template-columns: repeat(2, 1fr); }
    .role-card { padding: 20px; }
}

/* Mobile Portrait */
@media screen and (max-width: 767px) and (orientation: portrait) {
    .rules-container { padding: 12px 16px 90px 16px; }
    
    .back-button { float: none; display: inline-flex; margin-bottom: 20px; }
    
    h1 {
        font-size: clamp(2rem, 8vw, 2.5rem);
        -webkit-text-stroke: 1px var(--primary);
        letter-spacing: 2px;
    }
    
    .title-badge { gap: 10px; }
    .badge-line { width: 30px; }
    .badge-text { font-size: 0.7rem; letter-spacing: 2px; }
    
    .section-header { flex-wrap: wrap; }
    .section-icon { width: 40px; height: 40px; font-size: 1.2rem; }
    .section-header h2 { font-size: 1.2rem; }
    
    .roles-grid { grid-template-columns: 1fr; gap: 16px; }
    
    .role-card { padding: 20px; }
    .role-icon { width: 50px; height: 50px; }
    .role-icon i { font-size: 1.5rem; }
    .role-title h3 { font-size: 1.3rem; }
    .role-sub { display: block; margin-left: 0; margin-top: 5px; }
    
    .ability { flex-direction: column; gap: 5px; }
    .ability i { width: auto; }
    
    .rules-grid { grid-template-columns: 1fr; }
    .rule-item { flex-direction: column; }
    
    .win-conditions { grid-template-columns: 1fr; }
    
    .bottom-nav { padding: 8px 12px 20px; }
    .nav-btn { padding: 6px 12px; }
    .nav-btn i { font-size: 1.2rem; }
}

/* Small Phones */
@media screen and (max-width: 375px) {
    .role-title h3 { font-size: 1.2rem; }
    .role-quote p { font-size: 0.85rem; }
    .ability span { font-size: 0.8rem; }
    
    .nav-btn { font-size: 0.7rem; }
    .nav-btn i { font-size: 1rem; }
}

/* PWA Support */
@media (display-mode: standalone) {
    .bottom-nav { padding-bottom: 20px; }
}

/* Touch Optimization */
@media (hover: none) and (pointer: coarse) {
    .role-card:hover { transform: none; }
    .role-card:active { transform: scale(0.98); }
    .nav-btn { min-height: 44px; min-width: 44px; }
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s infinite linear;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
    .bg-gradient,
    .bg-particles,
    .bg-noise,
    .bottom-nav {
        display: none;
    }
    
    .rules-container {
        background: white;
        color: black;
    }
}