@font-face {
    font-family: 'Vazir';
    src: url('../files/Vazir.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazir', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button, input, textarea, select {
    font-family: inherit;
}

body {
    background: #1a100a;
    color: #fff;
    overflow: hidden;
    direction: rtl;
    overscroll-behavior-y: contain;
}

.app-splash {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    background: #1a100a;
    padding: 20px;
}
.app-splash.active { display: flex; }
.app-splash.hidden { opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
.app-splash-card {
    width: min(92vw, 420px);
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 8px 16px;
    text-align: center;
    box-shadow: none;
    backdrop-filter: none;
}
.app-splash-logo {
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-splash-title { font-size: 26px; color: #f4d7ae; margin-bottom: 8px; }
.app-splash-text { color: #cdb392; font-size: 13px; line-height: 1.8; margin-bottom: 18px; }
.app-splash-progress {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.app-splash-progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #b8874b, #f1d4a8);
    box-shadow: 0 0 20px rgba(241, 212, 168, 0.35);
    transition: width 0.25s ease;
}
.app-splash-status {
    margin-top: 12px;
    font-size: 12px;
    color: #e8c89c;
    min-height: 1.5em;
}

#landscape-warning {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #1a100a;
    color: #fff;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-direction: column;
}

@media screen and (orientation: portrait) {
    #landscape-warning { display: flex; }
    #app { display: none !important; }
}

#app {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    position: relative;
}

body.in-game .floating-top-ui, 
body.in-game .bottom-bar,
body.matchmaking-active .floating-top-ui,
body.matchmaking-active .bottom-bar {
    display: none !important;
}

.floating-top-ui {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
    pointer-events: none;
}

.floating-top-ui > * {
    pointer-events: auto;
}

.user-info-top {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: rgba(45, 24, 11, 0.85);
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid #5c3216;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.avatar {
    width: 52px;
    height: 52px;
    background: #e8c89c;
    border-radius: 50%;
    border: 2px solid #dcb584;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    color: #4a2f1d;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar.has-image { background-color: #2d180b; }
.avatar-lg { width: 80px; height: 80px; font-size: 32px; }

.user-details {
    display: flex;
    flex-direction: column;
}

.username { font-weight: bold; font-size: 13px; }
.level { font-size: 10px; color: #dcb584; }
.xp-bar {
    width: 70px; height: 5px; background: #221; border-radius: 3px; margin-top: 2px;
    overflow: hidden; border: 1px solid #4a2f1d;
}
.xp-fill { height: 100%; background: #dcb584; width: 50%; }

.coins-top {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(45, 24, 11, 0.85);
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid #5c3216;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}
.coin-count { font-weight: bold; color: #ffd700; font-size: 13px; }
.btn-buy {
    background: linear-gradient(to bottom, #28a745, #1e7e34);
    border: none; color: #fff; padding: 4px 10px; border-radius: 12px;
    cursor: pointer; font-size: 11px; font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.btn-buy:active {
    transform: scale(0.95);
}

.top-left-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-left-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tutorial-entry {
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(45, 24, 11, 0.85);
    border-radius: 50%;
    border: 1px solid #5c3216;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    color: #e8c89c;
    flex-shrink: 0;
    padding: 8px;
}

.tutorial-entry:hover {
    transform: scale(1.1);
}

.tutorial-entry:active {
    transform: scale(0.95);
}

.tutorial-entry svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tutorial-container {
    padding: 20px;
    width: 100%;
    height: 97%;
    margin: 0 auto;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
    scrollbar-width: thin;
    scrollbar-color: #5c3216 transparent;
}

.tutorial-section {
    background: rgba(45, 24, 11, 0.85);
    border: 1px solid #5c3216;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

.tutorial-section-title {
    color: #f4d7ae;
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: bold;
}

.tutorial-text {
    color: #cdb392;
    font-size: 13px;
    line-height: 1.8;
    text-align: justify;
}

.lucky-wheel-entry {
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.lucky-wheel-entry img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.lucky-wheel-entry:hover {
    transform: scale(1.1);
}

.lucky-wheel-content {
    max-width: 360px !important;
    max-height: 98vh;
    overflow-y: auto;
    text-align: center;
    background: linear-gradient(135deg, #3d2311 0%, #2d180b 100%) !important;
    border: 2px solid #7a4623; border-radius: 15px;
    padding: 15px !important;
}

.lucky-wheel-status-msg {
    margin-bottom: 10px;
    font-size: 13px;
    color: #e8c89c;
    min-height: 1.2em;
}

.wheel-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 15px;
}

.wheel-pointer {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 32px;
    background: #ffc107;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    z-index: 10;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

.wheel-canvas-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.5);
    overflow: hidden;
    transition: transform 4s cubic-bezier(0.15, 0, 0.15, 1);
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.spin-btn {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    font-weight: bold;
}

.spin-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

@media (max-height: 450px) {
    .lucky-wheel-content {
        padding: 10px !important;
    }
    .modal-title {
        margin-bottom: 10px;
        padding-bottom: 5px;
        font-size: 16px;
    }
    .lucky-wheel-status-msg {
        margin-bottom: 5px;
        font-size: 12px;
    }
    .wheel-wrapper {
        width: 180px;
        height: 180px;
        margin-bottom: 10px;
    }
    .wheel-pointer {
        width: 18px;
        height: 24px;
        top: -3px;
    }
    .spin-btn {
        padding: 8px;
        font-size: 14px;
    }
}

@media (max-width: 400px) and (min-height: 451px) {
    .wheel-wrapper {
        width: 240px;
        height: 240px;
    }
}

.main-content {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(232, 200, 156, 0.2);
    gap: 10px;
}
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    color: #cdb392;
    font-weight: bold;
    transition: all 0.3s;
    border-radius: 8px 8px 0 0;
}
.auth-tab.active {
    color: #e8c89c;
    background: rgba(232, 200, 156, 0.1);
    border-bottom: 3px solid #e8c89c;
}
.auth-modal-content {
    max-width: 350px !important;
}

.view { 
    display: none; 
    width: 100%; 
    height: 100%; 
    min-height: 0;
    justify-content: center;
    align-items: center;
    position: relative; 
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.view.active { display: flex; }

#view-matchmaking.matchmaking-view {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top, rgba(232,200,156,0.14), transparent 40%), linear-gradient(135deg, #1d0e06 0%, #2e1708 100%);
    padding: 0;
}

#view-matchmaking.matchmaking-view .matchmaking-card {
display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    text-align: center;
}

#view-matchmaking.matchmaking-view h2 {
    margin: 0;
    font-size: clamp(24px, 4vw, 32px);
    color: #f4e3b7;
}

#view-matchmaking.matchmaking-view p {
    color: #d7cab0;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 420px;
}

#view-matchmaking.matchmaking-view .matchmaking-graphic {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(232, 200, 156, 0.08);
    box-shadow: inset 0 0 36px rgba(232, 200, 156, 0.14);
}

#view-matchmaking.matchmaking-view .spinner {
    width: 64px;
    height: 64px;
    border: 12px solid rgba(255,255,255,0.12);
    border-top-color: #e8c89c;
    border-radius: 50%;
    animation: spin 1.1s linear infinite;
}

#view-matchmaking.matchmaking-view .btn-cancel {
    width: 70%;
    max-width: 240px;
    padding: 16px 18px;
}

#view-matchmaking.matchmaking-view .matchmaking-card .btn-cancel {
    margin-top: 0;
}

#view-settings.view.active {
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #5c3216 transparent;
}

.menu-buttons {
    display: flex;
    gap: 30px;
    flex-wrap: wrap; 
    justify-content: center;
    padding: 20px 0;
}
.menu-btn {
    width: clamp(120px, 25vw, 150px);
    height: clamp(120px, 25vw, 150px);
    background: linear-gradient(135deg, #5c3216, #3a1f0d);
    border: 3px solid #7a4623;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0,0,0,0.6), inset 0 0 15px rgba(0,0,0,0.8);
    transition: transform 0.2s, filter 0.2s;
    color: #e8c89c;
    text-shadow: 1px 1px 2px #000;
}
.menu-btn:hover { transform: scale(1.05); filter: brightness(1.2); }
.menu-btn h2 { font-size: clamp(14px, 3vw, 20px); margin-bottom: 10px; }
.menu-btn span { font-size: clamp(10px, 2vw, 12px); color: #b08d6a; }

.bottom-bar {
    height: 70px;
    background: rgba(45, 24, 11, 0.95);
    border-top: 2px solid #5c3216;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    z-index: 100;
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center;
    color: #b08d6a; font-size: 12px; cursor: pointer; gap: 5px;
    transition: color 0.2s;
}
.nav-btn:hover { color: #fff; }
.nav-btn .icon { font-size: 24px; }
.nav-btn.play-btn {
    transform: translateY(-15px);
    background: linear-gradient(to bottom, #7a4623, #4a2f1d);
    width: 75px; height: 75px; border-radius: 50%;
    justify-content: center; border: 3px solid #2d180b;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.5);
    color: #e8c89c;
}

.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); z-index: 2000;
    justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: linear-gradient(135deg, #4a2f1d, #2d180b);
    border: 2px solid #7a4623; border-radius: 15px;
    padding: 20px; width: 400px; max-width: 90%;
    max-height: 95vh; overflow-y: auto;
    box-shadow: 0 15px 30px rgba(0,0,0,0.8);
    position: relative; text-align: center;
}
.modal-close {
    position: absolute; top: 10px; right: 10px; cursor: pointer;
    font-size: 20px; color: #e8c89c; background: none; border: none;
}
.modal-title { color: #e8c89c; margin-bottom: 20px; font-size: 20px; border-bottom: 1px solid #5c3216; padding-bottom: 10px; }

input {
    width: 100%; padding: 10px; margin-bottom: 15px;
    background: rgba(0,0,0,0.5); border: 1px solid #5c3216;
    color: #fff; border-radius: 5px; text-align: center;
}
input:focus { outline: none; border-color: #e8c89c; }
.btn-primary {
    background: linear-gradient(to bottom, #7a4623, #4a2f1d);
    color: #e8c89c; border: 1px solid #5c3216; padding: 10px 20px;
    border-radius: 5px; cursor: pointer; width: 100%; font-size: 16px; font-weight: bold;
}
.btn-primary:hover { filter: brightness(1.2); }
.btn-secondary-surface {
    background: rgba(255,255,255,0.08);
    border-color: rgba(232, 200, 156, 0.28);
}

.stats-list { text-align: right; }
.stats-list div { display: flex; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px dashed #5c3216; padding-bottom: 5px; }

.landscape-icon { font-size: 48px; display: block; margin-bottom: 20px; transform: rotate(90deg); }

.nav-svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
.nav-svg svg { width: 24px; height: 24px; display: block; }

.store-package-btn {
    width: 120px;
    height: 120px;
    cursor: pointer;
}

.friends-container {
    width: min(100%);
    height: 100%;
    display: block;              
    overflow-y: auto;            
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    scrollbar-width: thin;
    scrollbar-color: #5c3216 transparent;
}
.search-box { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 25px; 
    margin-top: 10px; 
    width: 100%;
}
.search-box input { 
    margin: 0; 
    flex: 1; 
    text-align: right; 
    padding: 12px 15px;
    background: rgba(0,0,0,0.6);
    border: 1px solid #7a4623;
}
.search-box button { 
    width: auto; 
    padding: 0 25px; 
    white-space: nowrap;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.friends-list {
}
.friend-item { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.1); padding: 10px; border-radius: 10px; margin-bottom: 10px; }
.top-tabs { display: flex; gap: 6px; margin-bottom: 15px; direction: rtl; }
.top-tab { flex: 1; padding: 8px 0; border: 1px solid #5c3216; background: rgba(255,255,255,0.05); color: #a08060; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.2s; text-align: center; font-family: inherit; }
.top-tab.active { background: #e8c89c; color: #1a100a; border-color: #e8c89c; font-weight: bold; }
.top-tab:hover:not(.active) { background: rgba(255,255,255,0.1); color: #cdb392; }
@keyframes skeleton-pulse { 0% { opacity: 0.4; } 50% { opacity: 0.8; } 100% { opacity: 0.4; } }
.skeleton-item { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.08); padding: 10px; border-radius: 10px; margin-bottom: 10px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton-line { height: 12px; border-radius: 4px; background: rgba(255,255,255,0.15); }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w55 { width: 55%; }
.skeleton-line.w65 { width: 65%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w30 { width: 30%; }
.skeleton-line.w35 { width: 35%; }
.skeleton-line.w25 { width: 25%; }
.skeleton-line.w20 { width: 20%; }
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding: 4px;
    align-content: start;
    overflow-y: visible;  
}

.store-packages {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
}

.support-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

.support-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@media (max-width: 768px) {
    .floating-top-ui {
        top: 6px;
        left: 6px;
        right: 6px;
    }
    .user-info-top, .coins-top {
        padding: 4px 10px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    }
    .avatar { width: 34px; height: 34px; font-size: 18px; }
    .username { font-size: 11px; }
    .level { font-size: 9px; }
    .xp-bar { width: 50px; }
    .coin-count { font-size: 11px; }
    .btn-buy { padding: 3px 8px; font-size: 10px; }

    .main-content {
        padding-top: 0;
    }

    .friends-container, .settings-container {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        padding: 10px;
    }
    
    .view {
        padding: 0;
    }

    .bottom-bar {
        height: 60px;
    }
    .nav-btn { font-size: 10px; }
    .nav-btn .icon svg { width: 20px; height: 20px; }
    .nav-btn.play-btn {
        width: 64px;
        height: 64px;
        transform: translateY(-12px);
    }
    .nav-btn.play-btn .nav-dice-icon svg { width: 24px; height: 24px; }
}
.friend-card {
    aspect-ratio: 1;
    background: rgba(255,255,255,0.08);
    border: 2px solid #5c3216;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    gap: 6px;
}
.friend-card .friend-avatar {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 2px solid #dcb584;
    background: #e8c89c;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.friend-card .friend-avatar.has-image { background-color: #2d180b; }
.friend-card .friend-name {
    font-weight: bold;
    font-size: 12px;
    color: #fff;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.friend-card .friend-level { font-size: 11px; color: #b08d6a; }
.friend-card .btn-invite {
    width: 100%;
    padding: 6px 4px;
    font-size: 11px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(to bottom, #7a4623, #4a2f1d);
    color: #fff;
    font-weight: bold;
}
.friend-card .btn-invite:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: #555;
}

.invite-player-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
}
.invite-info {
    text-align: right;
}
.invite-from-name {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #e8c89c;
}
.invite-from-level {
    margin: 5px 0 0 0;
    font-size: 14px;
    color: #b08d6a;
}

@media (max-width: 768px) {
    #invite-from-avatar {
        width: 80px !important;
        height: 80px !important;
        font-size: 38px !important;
        min-width: 80px;
    }
    .invite-player-preview {
        gap: 20px;
    }
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.game-container {
    display: flex; align-items: center; gap: 10px;
    width: 100%; max-width: 1100px;
    height: 100%; max-height: 100%;
    justify-content: center;
}
.board-wrapper {
    flex: 1;
    aspect-ratio: 1.6 / 1;
    max-width: 800px;
    max-height: 100vh;

    background-image:
        linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.35)),
        url('../files/wood.jpg');

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    border-radius: 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.8);

    padding: 2%;
    display: flex;
    gap: 2%;
    position: relative;
    transition: transform 0.05s ease-out;
}
.board-wrapper.board-shake {
    animation: none;
}
.doubles-screen-flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 120;
    opacity: 0;
    background: rgba(255, 180, 60, 0.15);
}
.doubles-screen-flash.active {
    animation: screenFlash 0.65s ease-out forwards;
}
@keyframes screenFlash {
    0% { opacity: 0; }
    20% { opacity: 1; }
    100% { opacity: 0; }
}
.dice-container.doubles-fire {
    animation: diceFirePulse 0.55s ease-out;
}
.dice-container.doubles-fire::before {
    content: '';
    position: absolute;
    inset: -25%;
    border-radius: 50%;
    pointer-events: none;
    background: rgba(255, 180, 60, 0.25);
    animation: simpleRing 0.55s ease-out forwards;
}
@keyframes simpleRing {
    0% { opacity: 0.4; transform: scale(0.6); }
    100% { opacity: 0; transform: scale(1.15); }
}
@keyframes diceFirePulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    30% { transform: translate(-50%, -50%) scale(1.06); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
.dice-container.doubles-flash::after { display: none; }
.bar-top, .bar-bottom { position: relative; overflow: visible; }
.checker.bar-stacked { position: relative; width: clamp(18px, 4vw, 38px); height: clamp(18px, 4vw, 38px); flex-shrink: 0; }
.auto-confirm-hint {
    font-size: 11px;
    color: #ccc;
    white-space: nowrap;
    text-align: center;
    display: block;
    line-height: 1.3;
}
.half-board {
    flex: 1;

    background: url("../files/board.jpg") center/cover no-repeat;

    border-radius: 5px;
    box-shadow: inset 0 0 40px rgba(100, 50, 0, 0.6);

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    position: relative;
    overflow: hidden;
    padding: 0 1%;
}

.half-board::after {
    content: '';
    position: absolute;
    top: 25%;
    left: 25%;
    right: 25%;
    bottom: 25%;
    background: url('../files/center.png') center/contain no-repeat;
    pointer-events: none;
    opacity: 0.5;
}
.row { display: flex; width: 100%; height: 42%; }
.point-container {
    flex: 1; position: relative; display: flex; justify-content: center; margin: 0 1px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}
.point-container .checker { pointer-events: none; }
.point-container.highlight .point-top, .point-container.highlight .point-bottom { background: #75c983 !important; }
.point-container.highlight-strong .point-top, .point-container.highlight-strong .point-bottom { background: #3a7d44 !important; }
.tray-slot.highlight { background: rgba(117, 201, 131, 0.4) !important; }
.tray-slot.highlight-strong { background: rgba(58, 125, 68, 0.7) !important; }
.point-top, .point-bottom { width: 100%; height: 100%; position: absolute; }
.point-top { clip-path: polygon(0 0, 100% 0, 50% 100%); top: 0; }
.point-bottom { clip-path: polygon(50% 0, 100% 100%, 0 100%); bottom: 0; }

.p-dark .point-top,
.p-dark .point-bottom {
    background: rgba(122, 74, 34, 0.65);
    mix-blend-mode: multiply;
}

.p-light .point-top,
.p-light .point-bottom {
    background: rgba(216, 165, 106, 0.65);
    mix-blend-mode: multiply;
}

.checkers-top, .checkers-bottom {
    position: absolute; display: flex; flex-direction: column; align-items: center; width: 100%; z-index: 5;
}
.checkers-top { top: 2%; }
.checkers-bottom { bottom: 2%; flex-direction: column-reverse; }

.checker {
    width: clamp(18px, 4.2vw, 38px);
    height: clamp(18px, 4.2vw, 38px);
    border-radius: 50%; 
    margin-bottom: -30%; 
    position: relative;
    box-shadow: 0 6px 10px rgba(0,0,0,0.6), inset 0 2px 5px rgba(255,255,255,0.4), inset 0 -4px 5px rgba(0,0,0,0.5);
    transition: transform 0.3s;
}
.checker.movable-checker-highlight {
box-shadow:
    0 0 8px 2px rgba(20, 90, 30, 0.6),
    0 0 16px 4px rgba(20, 90, 30, 0.25),
    inset 0 0 6px 2px rgba(20, 90, 30, 0.35) !important;
    outline: none;
}
.checkers-bottom .checker { margin-bottom: 0; margin-top: -30%; }
@media (max-width: 480px) {
    .checker {
        margin-bottom: -38%;
    }
    .checkers-bottom .checker {
        margin-top: -38%;
    }
}
@media (min-width: 1024px) {
    .checker {
        margin-bottom: -10%; 
    }
    .checkers-bottom .checker {
        margin-top: -10%;
    }
}

.c-white {
    background: url('../files/wm.png') center/cover;
    background-color: #e8c89c; 
box-shadow:
    inset 0 0 0 1px rgba(255, 235, 210, 0.05);}

.c-black {
    background: url('../files/bm.png') center/cover;
    background-color: #3a1f0d; 
box-shadow: inset 0 0 0 1px rgba(26, 10, 0, 0.3);}

.checker-with-count {
    background: #b47a3b !important;
    color: #fff;
    font-weight: bold;
    font-size: clamp(14px, 3vw, 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    box-shadow: 0 0 0 2px #2d180b, 0 4px 8px rgba(0,0,0,0.3);
}
.c-white.checker-with-count {
    background:
        linear-gradient(rgba(160, 101, 42, 0.5), rgba(160, 101, 42, 0.5)),
        url('../files/wm.png') center/cover no-repeat !important;
    color: #2d180b;
}

.c-black.checker-with-count {
    background:
        linear-gradient(rgba(180, 122, 59, 0.5), rgba(180, 122, 59, 0.5)),
        url('../files/bm.png') center/cover no-repeat !important;
    color: #fff0c0;
}
.bar {
    width: clamp(20px, 4vw, 30px);
    background: linear-gradient(90deg, #3a1f0d, #5c3216, #3a1f0d);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.9); border-radius: 2px;
    display: flex; flex-direction: column; justify-content: space-between; padding: 2% 0;
    position: relative;
}
.bar-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    pointer-events: auto;
    background: rgba(68, 34, 34, 0.95);
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #5c3216;
    box-shadow: 0 3px 10px rgba(0,0,0,0.5);
    min-width: 52px;
}
.btn-undo {
    background: #442222;
    color: #e8c89c;
    border: 1px solid #5c3216;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    flex-shrink: 0;
}
.btn-undo svg {
    width: 20px;
    height: 20px;
    display: block;
    transform: scaleX(-1);
}
.bar-controls .auto-confirm-hint {
    font-size: 10px;
    color: #e8c89c;
    white-space: nowrap;
    text-align: center;
    line-height: 1.3;
    writing-mode: horizontal-tb;
}
.bar-top, .bar-bottom { display: flex; flex-direction: column; align-items: center; min-height: 40px; }
.bar-bottom { flex-direction: column-reverse; }

.side-tray {
    width: clamp(30px, 7.5vw, 60px);
    height: 100%;
    max-height: 500px;

    background-image:
        linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0.2)),
        url('../files/wood.jpg');

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);

    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px 0;
}
.tray-slot {
    width: 100%; height: 45%; background: rgba(0,0,0,0.5); box-shadow: inset 0 5px 10px rgba(0,0,0,0.8);
    display: flex; flex-direction: column; align-items: center; padding: 5px 0; cursor: pointer;
}

.dice-container {
    position: absolute; top: 50%; transform: translate(-50%, -50%);
    display: flex; gap: clamp(5px, 2vw, 15px); z-index: 50; cursor: pointer; perspective: 1200px;
    transition: left 0.5s ease-in-out;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.dice-container.rolled { pointer-events: none !important; }
.bar-top, .bar-bottom, .tray-slot {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}
.player-tag .timer { min-width: 1.5em; display: inline-block; text-align: center; }
.dice-container.center-side { left: 50%; }
.dice-container.right-side { left: 75%; }
.dice-container.left-side { left: 25%; }

.die-wrapper { width: clamp(24px, 4vw, 36px); height: clamp(24px, 4vw, 36px); transform-style: preserve-3d; }
.cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; }

.dice-container:not(.rolled) .die-w-1 { transform: scale(1.2) translate3d(-10px, -15px, 30px); filter: none; }
.dice-container:not(.rolled) .die-w-2 { transform: scale(1.2) translate3d(10px, 15px, 30px); filter: none; }
.dice-container:not(.rolled) .cube-1 { animation: spin1 3.5s infinite linear; }
.dice-container:not(.rolled) .cube-2 { animation: spin2 3s infinite linear reverse; }

@keyframes spin1 { 100% { transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg); } }
@keyframes spin2 { 100% { transform: rotateX(720deg) rotateY(360deg) rotateZ(360deg); } }

.shield {
    position: absolute;
    inset: -0.3px;
    background: #dde0e8;
    border-radius: 17%;
    transform: translateZ(-0.5px); 
    pointer-events: none;
}

.face {
    position: absolute; width: 100%; height: 100%; inset: 0;
    background: radial-gradient(125% 125% at 27% 22%, #ffffff 0%, #f3f4f7 44%, #dde0e8 100%);
    border-radius: 17%;
    transform-style: preserve-3d;
    
    box-shadow:
        inset -2px -2px 4px rgba(0, 0, 0, 0.25),   
        inset 0 0 0 1px rgba(255, 255, 255, 0.85),
        inset 0 0 14px rgba(58, 68, 96, 0.12),
        inset 7px 9px 20px rgba(58, 68, 96, 0.09),
        inset -5px -6px 16px rgba(58, 68, 96, 0.06);
        
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
    padding: 14%; box-sizing: border-box; backface-visibility: hidden;
}

.front  { transform: rotateY(0deg)   translateZ(clamp(12px, 2vw, 18px)); }
.back   { transform: rotateY(180deg) translateZ(clamp(12px, 2vw, 18px)); }
.right  { transform: rotateY(90deg)  translateZ(clamp(12px, 2vw, 18px)); }
.left   { transform: rotateY(-90deg) translateZ(clamp(12px, 2vw, 18px)); }
.top    { transform: rotateX(90deg)  translateZ(clamp(12px, 2vw, 18px)); }
.bottom { transform: rotateX(-90deg) translateZ(clamp(12px, 2vw, 18px)); }

.pip {
    place-self: center;
    background: radial-gradient(circle at 36% 30%, #565b67 0%, #2a2d35 42%, #0a0c11 100%); 
    border-radius: 50%; 
    width: 66%; 
    height: 66%; 
    margin: auto;
    box-shadow: 
        inset 0 2px 3px rgba(0, 0, 0, 0.9),
        inset 0 -1px 2px rgba(255, 255, 255, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.6);
}

.dice-container.rolled .die-w-1 { animation: drop1 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.dice-container.rolled .die-w-2 { animation: drop2 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards; }

.dice-container.starter-mode.rolled .die-w-1 { animation: drop1_starter 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.dice-container.starter-mode.rolled .die-w-2 { animation: drop2_starter 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards; }

@keyframes drop1 {
    0% { transform: scale(1.2) translate3d(-10px, -15px, 30px); filter: none; }
    100% { transform: scale(1) translate3d(0, 0, 0); filter: none; }
}
@keyframes drop2 {
    0% { transform: scale(1.2) translate3d(10px, 15px, 30px); filter: none; }
    100% { transform: scale(1) translate3d(0, 0, 0); filter: none; }
}

@keyframes drop1_starter {
    0% { transform: scale(1.2) translate3d(-10px, -15px, 30px); filter: none; }
    100% { transform: scale(1) translate3d(-20vw, 0, 0); filter: none; }
}
@keyframes drop2_starter {
    0% { transform: scale(1.2) translate3d(10px, 15px, 30px); filter: none; }
    100% { transform: scale(1) translate3d(20vw, 0, 0); filter: none; }
}

#view-game.view.active {
    position: relative;
}
.game-exit-btn {
    position: absolute;
    top: 8px;
    right: 8px;     
    z-index: 600;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #5c3216;
background: rgba(120, 20, 20, 0.92);
color: #e8c89c;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    pointer-events: auto;
}
.game-exit-btn:hover { filter: brightness(1.15); }
.game-ui-overlay {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 7px;
    height: auto;
    max-height: calc(100vh - 40px);
    align-self: center;
    box-sizing: border-box;
    pointer-events: none;
    margin-right: 2%;
    width: clamp(140px, 18vw, 220px);
    padding: 4px 0;
    flex-shrink: 0;
}
body.three-rounds-mode .player-card .p-status-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.round-score-box {
    display: none;
    position: absolute !important;
    bottom: 4px;
    left: 4px;
    top: auto !important;
    transform: none !important;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: linear-gradient(to bottom, #7a4623, #4a2f1d);
    border: 1px solid #dcb584;
    color: #ffd700;
    font-weight: bold;
    font-size: 11px;
    line-height: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    margin: 0;
    z-index: 5;
}
body.three-rounds-mode .round-score-box { display: flex; }

.player-card {
    position: relative;
    background: rgba(20, 10, 5, 0.88);
    border: 2px solid #5c3216;
    border-radius: 10px;
    padding: clamp(5px, 1vw, 8px);
    transition: border-color 0.3s, box-shadow 0.3s;
    pointer-events: auto;
    flex-shrink: 0;
    overflow: hidden;
}
.player-card.active {
    border-color: #28a745;
    box-shadow: 0 0 14px rgba(40, 167, 69, 0.45);
}
.player-card-body {
    display: flex;
    align-items: flex-start;
    gap: clamp(4px, 0.8vw, 6px);
}
.player-avatar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.player-info-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
    justify-content: flex-start;
}
.player-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.avatar-md {
    width: clamp(60px, 12vw, 90px);
    height: clamp(60px, 12vw, 90px);
    border-radius: 12px;
    border: 2px solid #dcb584;
    background: #e8c89c;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a2f1d;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.avatar-md.has-image { background-color: #2d180b; }
.player-avatar-wrap .timer {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: #dc3545;
    color: #fff;
    font-size: clamp(8px, 1.6vw, 10px);
    font-weight: bold;
    min-width: 1.5em;
    text-align: center;
    padding: 1px 4px;
    border-radius: 6px;
    border: 1px solid #fff;
    line-height: 1.2;
}
.player-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
}
.p-name {
    font-weight: bold;
    font-size: clamp(10px, 1.8vw, 13px);
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
    line-height: 1.2;
}
.p-level-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: clamp(9px, 1.7vw, 11px);
    color: #b08d6a;
}
.p-level { color: #b08d6a; font-size: clamp(8px, 1.6vw, 10px); }
.p-color-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #ccc;
    font-size: clamp(8px, 1.6vw, 10px);
}
.checker-mini {
    width: clamp(12px, 2.5vw, 16px);
    height: clamp(12px, 2.5vw, 16px);
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.p-status-row {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed rgba(92, 50, 22, 0.6);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 28px;
}
.p-inline-msg {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.92);
    border: 2px solid #e8c89c;
    border-radius: 70px;
    padding: 12px 28px;
    font-size: 20px;
    font-weight: bold;
    color: #e8c89c;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    font-family: 'Vazir', sans-serif;
    text-align: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#p1-msg {
    border-color: #28a745;
    background: rgba(0, 0, 0, 0.95);
    top: 85px;  
}

#p2-msg {
    border-color: #dcb584;
    top: 20px; 
}

@media (max-width: 768px) {
    .p-inline-msg {
        font-size: 22px;         
        padding: 10px 20px;    
        border-radius: 60px;
        white-space: normal;
        width: auto;
        min-width: 150px;       
        max-width: 65vw;    
        top: auto;
        bottom: auto;
    }
    #p1-msg {
        top: 65px;
    }
    #p2-msg {
        top: 35px;
    }
}
.p-inline-msg.visible {
    opacity: 1;
}

.p-inline-msg.visible { opacity: 1; }
.p-misses {
    display: flex;
    gap: 2px;
    align-items: center;
    color: #ff4444;
    margin: 0;
    justify-content: flex-end;
    white-space: nowrap;
    flex-wrap: nowrap;
    overflow: hidden;
}
.miss-mark {
    font-weight: bold;
    font-size: 1.4em;
    line-height: 1;
}
.game-chat-panel {
    flex: 1 1 auto;             
    min-height: 130px;         
    max-height: 230px;         
    pointer-events: auto;
    background: rgba(0,0,0,0.45);
    border: 1px solid #5c3216;
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;          
    scrollbar-width: thin;
    scrollbar-color: #5c3216 transparent;
}
.chat-msg-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
}
.chat-msg-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(92, 50, 22, 0.6);
    color: #e8c89c;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: clamp(8px, 1.6vw, 10px);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.chat-msg-btn:hover { background: rgba(122, 70, 35, 0.5); }

@media (max-width: 700px), (max-height: 420px) {
    .board-wrapper {
        aspect-ratio: auto;
        height: 97%;
        max-height: 97vh;
    }
    .game-ui-overlay {
        width: clamp(100px, 22vw, 145px);
        gap: 4px;
        max-height: 100%;
    }
    .player-card { padding: 4px; border-radius: 8px; }
    .avatar-md {
        width: clamp(48px, 12vw, 65px);
        height: clamp(48px, 12vw, 65px);
        border-radius: 10px;
    }
    .player-card-body { gap: 3px; }
    .p-name { font-size: 9px; }
    .p-level-row { font-size: 8px; gap: 2px 4px; }
    .round-score-box { min-width: 20px; height: 18px; font-size: 9px; padding: 0 4px; line-height: 16px; }
    .p-inline-msg { font-size: 10px; padding: 3px 4px; }
    .game-chat-panel { max-height: 80px; padding: 3px; }
    .chat-msg-btn { padding: 3px 4px; font-size: 8px; }
    .game-exit-btn { width: 34px; height: 34px; top: 4px; right: 4px; }
    .bar-controls { padding: 4px 6px; min-width: 46px; }
    .btn-undo { width: 32px; height: 32px; }
    .btn-undo svg { width: 18px; height: 18px; }
    .bar-controls .auto-confirm-hint { font-size: 8px; }
}
.nav-dice-icon svg {
    width: clamp(28px, 5vw, 36px);
    height: clamp(28px, 5vw, 36px);
    display: block;
}
.nav-btn.play-btn .nav-dice-icon { color: #e8c89c; }

.btn-game {
    pointer-events: auto;
    background: linear-gradient(to bottom, #7a4623, #4a2f1d);
    color: #e8c89c; border: 1px solid #5c3216; padding: 5px 15px;
    border-radius: 5px; cursor: pointer;
}

#matchmaking { flex-direction: column; color: #fff; text-align: center; }
.spinner {
    border: 4px solid rgba(255,255,255,0.3); border-top: 4px solid #e8c89c;
    border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px;
    border-radius: 10px; border: 1px solid #e8c89c; z-index: 2000;
    transition: opacity 0.3s; pointer-events: none;
}

.settings-container {
    width: min(100%);
    height: 100%;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.settings-header {
    display: flex;
    justify-content: flex-start;
    flex-shrink: 0;
}
.btn-save-settings {
    background: linear-gradient(to bottom, #28a745, #1e7e34);
    color: #fff;
    border: 1px solid #1e7e34;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);

    display: block;
    margin: 0 auto;
}
.btn-save-settings:hover { filter: brightness(1.15); }
.settings-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.username-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    justify-content: center;
    margin-top: 10px;
}
.username-row p {
    margin: 0;
}
.settings-preview-label { font-size: 12px; color: #b08d6a; }
.settings-section {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 12px 15px;
    flex-shrink: 0;
}
.settings-section-avatars {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.settings-section-title {
    color: #e8c89c;
    font-size: 15px;
    margin-bottom: 12px;
    border-bottom: 1px dashed #5c3216;
    padding-bottom: 8px;
}
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(92,50,22,0.4);
    font-size: 14px;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #442222;
    border-radius: 26px;
    transition: 0.25s;
    border: 1px solid #5c3216;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: #b08d6a;
    border-radius: 50%;
    transition: 0.25s;
}
.toggle-switch input:checked + .toggle-slider { background: #28a745; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); background: #fff; }
.avatar-grid-wrap {
    overflow: visible;
    padding: 5px;
    margin-top: 4px;
}
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 10px;
}
.avatar-option {
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    overflow: hidden;
    background: #2d180b;
    transition: border-color 0.2s, transform 0.15s;
}
.avatar-option:hover { transform: scale(1.06); }
.avatar-option.selected { border-color: #28a745; box-shadow: 0 0 10px rgba(40,167,69,0.5); }
.avatar-option img { width: 100%; height: 100%; object-fit: cover; display: block; }

.icon-coin { display: inline-flex; align-items: center; vertical-align: middle; color: #ffd700; }
.icon-coin svg { width: 18px; height: 18px; display: block; }
.coin-count { display: inline-flex; align-items: center; gap: 4px; }

.store-view { text-align: center; width: 100%;}
.store-package-btn { cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.store-coin-icon .icon-coin svg { width: 32px; height: 32px; }
.store-coin-icon { margin-bottom: 4px; }

.support-view { display: flex; flex-direction: column; height: 100%; width: 100%; }
.support-chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; text-align: right; }
.support-messages {
    flex: 1; overflow-y: auto; background: rgba(0,0,0,0.35);
    border: 1px solid #5c3216; border-radius: 10px; padding: 10px; margin-bottom: 10px;
    min-height: 0;
}
.support-bubble { max-width: 85%; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; }
.support-user { background: rgba(122,70,35,0.5); margin-right: auto; margin-left: 0; }
.support-admin { background: rgba(40,167,69,0.25); border: 1px solid rgba(40,167,69,0.4); margin-left: auto; }
.support-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.support-time { font-size: 10px; color: #b08d6a; margin-top: 4px; }
.support-empty { text-align: center; color: #b08d6a; padding: 20px; }
.support-compose { display: flex; gap: 8px; align-items: flex-end; }
.support-compose textarea {
    flex: 1; resize: none; border: 1px solid #5c3216; border-radius: 8px;
    background: rgba(0,0,0,0.4); color: #fff; padding: 8px; font-family: inherit; font-size: 13px;
}
.support-compose .btn-primary { width: auto; flex-shrink: 0; padding: 10px 16px; }

.settings-pwa-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.settings-action-btn {
    width: auto;
    min-width: 160px;
}
.settings-name-change {
    display: flex;
    gap: 10px;
    align-items: center;

    margin-top: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.settings-name-change input {
    flex: 1;
    margin: 0;
}

.settings-name-change button {
    width: auto;
    padding: 0 25px;
    white-space: nowrap;
    height: 46px;
}
.settings-helper-text {
    margin-top: 10px;
    color: #b08d6a;
    font-size: 12px;
    line-height: 1.7;
}

.nav-support-btn { position: relative; }
.nav-badge {
    position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
    background: #dc3545; color: #fff; font-size: 9px; font-weight: bold;
    border-radius: 8px; display: none; align-items: center; justify-content: center;
    padding: 0 4px; z-index: 5; border: 1px solid #fff;
}

.ad-modal-content { max-width: 360px; text-align: center; }
.ad-modal-img { max-width: 100%; max-height: 180px; border-radius: 8px; margin: 8px 0; }
.ad-modal-dismiss-btn {
    margin-top: 10px;
    background: transparent;
    color: #cdb392;
    border: none;
    font-size: 12px;
    cursor: pointer;
}

@media (max-width: 768px) {
    #top-avatar {
        width: 42px !important;
        height: 42px !important;
        font-size: 22px !important;
    }
}

@media (max-width: 768px) {
    #settings-avatar-preview {
        width: 80px !important;
        height: 80px !important;
        }
}