/* @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap'); */

:root {
    --bg-dark: #0d0d0f;
    --bg-card: #16161a;
    --accent-red: #c41e3a;
    --accent-red-dim: #8b1528;
    --accent-gold: #c9a227;
    --accent-gold-dim: #8a7019;
    --text-primary: #f0e6e0;
    --text-muted: #9a8f88;
    --border: rgba(196, 30, 58, 0.35);
    --shadow-glow: 0 0 30px rgba(196, 30, 58, 0.2);
    --radius: 12px;
    /* نقش‌ها */
    --role-liberal: #2563eb;
    --role-liberal-dim: #1d4ed8;
    --role-fascist: #722f37;
    --role-fascist-dim: #5a252b;
    --role-hitler: #722f37;
    --role-communist: #6b4423;
    --role-communist-dim: #52341a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'arial','Vazirmatn', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background-image:
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(196, 30, 58, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 80% 50% at 50% 100%, rgba(201, 162, 39, 0.08) 0%, transparent 50%);
}

/* صفحات – فقط یکی فعال */
.screen {
    display: none;
    width: 100%;
    max-width: 22rem;
}
.screen.screen-active {
    display: block;
}
.screen .page {
    max-width: none;
}

/* صفحه نقش: عرض برای چیدمان عکس/متن */
#screen-role.screen-role {
    max-width: min(96vw, 36rem);
    width: 100%;
}
#screen-role.screen-role.screen-active {
    display: block;
}

/* تیتر حبابی نامنظم */
.bubble-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem 0.65rem;
    margin: 0 0 1.25rem;
    padding: 0 0.15rem;
    line-height: 1.35;
}
.bubble-title__blob {
    display: inline-block;
    padding: 0.4em 0.82em;
    font-size: clamp(1.08rem, 4.5vw, 1.42rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.bubble-title__blob--a {
    color: #e0f2fe;
    background: rgba(59, 130, 246, 0.42);
    border: 2px solid rgba(147, 197, 253, 0.55);
    border-radius: 68% 32% 44% 56% / 46% 38% 62% 54%;
    transform: rotate(-2deg);
}
.bubble-title__blob--b {
    color: #fff7ed;
    background: rgba(244, 63, 124, 0.35);
    border: 2px solid rgba(253, 186, 228, 0.45);
    border-radius: 38% 62% 58% 42% / 52% 44% 56% 48%;
    transform: rotate(2.5deg);
}

/* نقش: ۶۰٪ عکس، ۴۰٪ ساید + نام شخصیت */
.screen-role .role-display {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    margin-bottom: 1.35rem;
    text-align: center;
    min-height: 10.5rem;
    overflow: hidden;
}
.role-display__photo {
    flex: 0 0 60%;
    width: 60%;
    max-width: 60%;
    min-height: 10rem;
    overflow: hidden;
    border-inline-end: 2px solid rgba(255, 255, 255, 0.12);
}
.screen-role .role-display.role-liberal .role-display__photo {
    border-color: rgba(147, 197, 253, 0.35);
}
.screen-role .role-display.role-fascist .role-display__photo,
.screen-role .role-display.role-hitler .role-display__photo {
    border-color: rgba(232, 180, 184, 0.35);
}
.screen-role .role-display.role-communist .role-display__photo,
.screen-role .role-display.role-astalin .role-display__photo {
    border-color: rgba(212, 165, 116, 0.4);
}
.role-character-img {
    width: 100%;
    height: 100%;
    min-height: 10rem;
    object-fit: cover;
    object-position: center top;
    display: block;
}
.role-character-img[hidden] {
    display: none !important;
}
.role-display__text {
    flex: 0 0 40%;
    width: 40%;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 0.65rem;
}
.role-side-label {
    font-weight: 700;
    font-size: clamp(0.88rem, 3vw, 1.05rem);
    line-height: 1.35;
    margin: 0;
    opacity: 0.92;
}
.role-character-label {
    font-weight: 800;
    font-size: clamp(1.1rem, 3.8vw, 1.35rem);
    line-height: 1.35;
    margin: 0;
}
.role-faction-extra {
    margin: 0;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    font-size: clamp(0.8rem, 3vw, 0.93rem);
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
}
.role-faction-extra[hidden] {
    display: none !important;
}
.role-display.role-hitler .role-faction-extra:not([hidden]) {
    background: rgba(251, 191, 36, 0.16);
    border: 1px solid rgba(250, 204, 21, 0.55);
    color: #fde68a;
}
.screen-role .role-display.role-hitler {
    border-color: rgba(250, 204, 21, 0.55);
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.2), 0 0 28px rgba(250, 204, 21, 0.12);
}

@media (max-width: 420px) {
    .screen-role .role-display {
        flex-direction: column;
    }
    .role-display__photo,
    .role-display__text {
        flex: none;
        width: 100%;
        max-width: 100%;
    }
    .role-display__photo {
        border-inline-end: none;
        border-bottom: 2px solid rgba(255, 255, 255, 0.12);
        min-height: 12rem;
    }
    .role-character-img {
        min-height: 12rem;
    }
}

/* صفحه خالی */
.empty-content {
    text-align: center;
}
.empty-content .btn-play {
    min-width: 14rem;
}

/* صفحه نقش */
.role-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    box-shadow: var(--shadow-glow);
}
.role-content .field {
    margin-bottom: 1.25rem;
}
.role-display {
    padding: 1.25rem 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    border: 2px solid transparent;
}
.role-display.role-liberal {
    background: rgba(37, 99, 235, 0.25);
    border-color: var(--role-liberal);
    color: #93c5fd;
}
.role-display.role-fascist,
.role-display.role-hitler {
    background: rgba(114, 47, 55, 0.35);
    border-color: var(--role-fascist);
    color: #e8b4b8;
}
.role-display.role-communist {
    background: rgba(107, 68, 35, 0.35);
    border-color: var(--role-communist);
    color: #d4a574;
}
.role-display.role-astalin {
    background: rgba(107, 68, 35, 0.35);
    border-color: var(--role-communist);
    color: #d4a574;
}
.role-display .role-unknown,
.modal-role-result.role-unknown {
    color: var(--text-muted);
}

/* صفحه راهبر بازی */
.screen-title {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}
.game-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.game-actions .btn-play {
    width: 100%;
}
.btn-secondary {
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
    box-shadow: 0 4px 0 #1f2937, 0 6px 20px rgba(0, 0, 0, 0.4);
}
.btn-secondary:hover {
    box-shadow: 0 5px 0 #1f2937, 0 8px 24px rgba(55, 65, 81, 0.35);
}
.btn-secondary:active {
    box-shadow: 0 2px 0 #1f2937, 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* مودال */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal.modal-open {
    opacity: 1;
    visibility: visible;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}
.modal-box {
    position: relative;
    width: 100%;
    max-width: 22rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}
.modal-box .field {
    margin-bottom: 1rem;
}
.modal-box .btn-play {
    width: 100%;
    margin-top: 0.5rem;
}
.modal-role-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
}
.modal-role-team {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    opacity: 0.92;
}
.modal-role-character {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.35;
}
.modal-role-result.role-unknown .modal-role-team,
.modal-role-result.role-unknown .modal-role-character {
    display: none;
}
.modal-role-result.role-liberal {
    background: rgba(37, 99, 235, 0.25);
    border: 2px solid var(--role-liberal);
    color: #93c5fd;
}
.modal-role-result.role-fascist,
.modal-role-result.role-hitler {
    background: rgba(114, 47, 55, 0.35);
    border: 2px solid var(--role-fascist);
    color: #e8b4b8;
}
.modal-role-result.role-communist {
    background: rgba(107, 68, 35, 0.35);
    border: 2px solid var(--role-communist);
    color: #d4a574;
}
.modal-role-result.role-astalin {
    background: rgba(107, 68, 35, 0.35);
    border: 2px solid var(--role-communist);
    color: #d4a574;
}
.hidden {
    display: none !important;
}

.page {
    width: 100%;
    max-width: 22rem;
}

/* تایتل */
.title {
    font-family: 'Amiri', serif;
    font-size: clamp(1.75rem, 6vw, 2.25rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
    text-shadow:
        0 0 20px rgba(196, 30, 58, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.02em;
}

/* فرم */
.setup-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.field {
    margin-bottom: 1.25rem;
}

.field:last-of-type {
    margin-bottom: 1.5rem;
}

.field label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.field input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    -webkit-appearance: none;
    appearance: none;
}

.field input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.25);
}

.field input::placeholder {
    color: var(--text-muted);
}

/* دکمه بازی */
.btn-play {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--bg-dark);
    background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-gold-dim) 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow:
        0 4px 0 var(--accent-gold-dim),
        0 6px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-play:hover {
    transform: translateY(-1px);
    box-shadow:
        0 5px 0 var(--accent-gold-dim),
        0 8px 24px rgba(201, 162, 39, 0.35);
}

.btn-play:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 var(--accent-gold-dim),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

/* تبلت و بالاتر */
@media (min-width: 480px) {
    .page {
        max-width: 26rem;
    }

    .setup-form {
        padding: 2rem 1.5rem;
    }

    .title {
        margin-bottom: 2.5rem;
    }
}

@media (min-width: 768px) {
    body {
        padding: 2rem;
    }

    .page {
        max-width: 28rem;
    }

    .title {
        font-size: 2.5rem;
        margin-bottom: 2.75rem;
    }

    .setup-form {
        padding: 2.25rem 2rem;
        border-radius: 16px;
    }

    .btn-play {
        padding: 1.15rem 1.5rem;
        font-size: 1.2rem;
    }
}
