/* لعبة مِهنة - Qadiyah Mihna game styles */

.qmihna {
    direction: rtl;
    font-family: "Tajawal", "Cairo", "Tahoma", sans-serif;
    color: #1c1c1c;
    --gold:    #c9a14a;
    --maroon:  #6e1f2e;
    --cream:   #f7efe1;
    --paper:   #fffdf7;
    --ink:     #1c1c1c;
    --green:   #2f7d4f;
    --red:     #b3331e;
    --shadow:  0 4px 14px rgba(0,0,0,.15);
    --radius:  14px;
    background: linear-gradient(135deg, #fef9ef 0%, #f6e9c8 100%);
    min-height: 600px;
    padding: 24px clamp(12px, 3vw, 36px);
    border-radius: 18px;
    box-shadow: inset 0 0 0 2px rgba(201,161,74,.25);
    position: relative;
    overflow: hidden;
}

/* Loading */
.qmihna__loading { text-align: center; padding: 60px 0; color: #6b5b2e; }
.qmihna__spinner {
    width: 42px; height: 42px;
    border: 4px solid rgba(110,31,46,.15);
    border-top-color: var(--maroon);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: qmihna-spin .9s linear infinite;
}
@keyframes qmihna-spin { to { transform: rotate(360deg); } }
.qmihna__noscript { padding: 16px; background: #fee; color: #800; border-radius: 8px; text-align: center; }

/* Buttons */
.qmihna-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    background: var(--maroon);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
    box-shadow: 0 3px 0 rgba(0,0,0,.2);
    font-family: inherit;
}
.qmihna-btn:hover  { transform: translateY(-1px); }
.qmihna-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.qmihna-btn:disabled { opacity: .45; cursor: not-allowed; }
.qmihna-btn--gold    { background: var(--gold); color: #2a1a05; }
.qmihna-btn--ghost   { background: transparent; color: var(--maroon); border: 2px solid var(--maroon); box-shadow: none; }
.qmihna-btn--green   { background: var(--green); }
.qmihna-btn--red     { background: var(--red); }
.qmihna-btn--lg      { padding: 14px 28px; font-size: 17px; }
.qmihna-btn--block   { display: flex; width: 100%; }

/* Headings */
.qmihna__title {
    font-size: clamp(26px, 4vw, 40px);
    font-weight: 900;
    color: var(--maroon);
    text-align: center;
    margin: 0 0 8px;
    letter-spacing: -0.5px;
}
.qmihna__subtitle { text-align: center; color: #6b5b2e; margin: 0 0 24px; font-size: 16px; }

/* ===== Setup screen ===== */
.qmihna-setup {
    max-width: 720px;
    margin: 0 auto;
    background: var(--paper);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
.qmihna-setup__count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 14px 0 22px;
}
.qmihna-setup__count button {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 2px solid var(--maroon);
    background: #fff;
    color: var(--maroon);
    font-size: 22px;
    cursor: pointer;
    font-weight: 900;
}
.qmihna-setup__count span {
    font-size: 24px; font-weight: 900;
    min-width: 38px; text-align: center;
}
.qmihna-setup__names { display: grid; gap: 10px; margin-bottom: 20px; }
.qmihna-setup__names input {
    padding: 12px 14px;
    border: 2px solid #e5d8b4;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    background: #fffdf7;
}
.qmihna-setup__names input:focus { border-color: var(--maroon); outline: none; }
.qmihna-setup__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== Pass-device screens ===== */
.qmihna-pass {
    text-align: center;
    padding: 60px 20px;
    background: var(--paper);
    border-radius: var(--radius);
    max-width: 520px;
    margin: 40px auto;
    box-shadow: var(--shadow);
}
.qmihna-pass__icon { font-size: 60px; margin-bottom: 14px; }
.qmihna-pass__name { font-size: 28px; font-weight: 900; color: var(--maroon); margin: 8px 0 22px; }
.qmihna-pass__hint { color: #6b5b2e; margin-bottom: 18px; }

/* ===== Reveal profession card ===== */
.qmihna-reveal {
    text-align: center;
    max-width: 480px;
    margin: 30px auto;
}
.qmihna-reveal__card {
    width: min(320px, 80vw);
    aspect-ratio: 3/4;
    margin: 18px auto;
    border-radius: 18px;
    background-size: cover;
    background-position: center;
    background-color: #2a1a05;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    border: 4px solid var(--gold);
}
.qmihna-reveal__name { font-size: 32px; font-weight: 900; color: var(--maroon); margin: 8px 0; }
.qmihna-reveal__warn { color: #b3331e; font-weight: 700; margin: 14px 0; }

/* ===== Game board ===== */
.qmihna-board {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
}
@media (min-width: 980px) {
    .qmihna-board {
        grid-template-columns: 280px 1fr 280px;
        align-items: start;
    }
}

.qmihna-panel {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.qmihna-panel h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--maroon);
    border-bottom: 2px dashed #e5d8b4;
    padding-bottom: 8px;
}

/* Players list */
.qmihna-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qmihna-players li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 2px solid #f0e4c6;
    font-weight: 700;
}
.qmihna-players li.is-current { border-color: var(--maroon); background: #fff7f2; }
.qmihna-players li.is-dealer  { box-shadow: 0 0 0 3px rgba(201,161,74,.4); }
.qmihna-players__meta { font-size: 13px; color: #6b5b2e; font-weight: 600; }

/* Center area */
.qmihna-center__head {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.qmihna-center__head h2 {
    margin: 0; font-size: 20px; color: var(--maroon);
}
.qmihna-stats {
    display: flex; gap: 8px; flex-wrap: wrap;
    font-size: 13px;
}
.qmihna-stats span {
    background: #fff;
    border: 2px solid #f0e4c6;
    border-radius: 999px;
    padding: 4px 12px;
    color: #6b5b2e;
    font-weight: 700;
}

/* Center cards (scene) */
.qmihna-scene {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 600px) {
    .qmihna-scene { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

.qmihna-card {
    aspect-ratio: 3/4;
    background: #fff;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: #2a1a05;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform .15s ease, border-color .15s ease;
    position: relative;
    overflow: hidden;
}
.qmihna-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.qmihna-card.is-empty {
    background: repeating-linear-gradient(45deg, #f5e9c8, #f5e9c8 8px, #efe0b4 8px, #efe0b4 16px);
    cursor: default;
    border: 2px dashed #c9a14a;
    box-shadow: none;
}
.qmihna-card.is-empty:hover { transform: none; border-color: #c9a14a; }
.qmihna-card__num {
    position: absolute;
    top: 6px; right: 6px;
    background: rgba(0,0,0,.5);
    color: #fff;
    font-weight: 900;
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}

/* Action bar */
.qmihna-actions {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed #e5d8b4;
}

/* Log */
.qmihna-log {
    list-style: none; margin: 0; padding: 0;
    max-height: 280px; overflow-y: auto;
    font-size: 13px;
}
.qmihna-log li {
    padding: 6px 8px;
    border-bottom: 1px dashed #f0e4c6;
    color: #4a3a14;
}
.qmihna-log li:last-child { border-bottom: none; }
.qmihna-log__time { color: #999; font-size: 11px; margin-left: 6px; }

/* Hand modal */
.qmihna-modal {
    position: fixed; inset: 0;
    background: rgba(28, 18, 5, .72);
    display: flex; align-items: center; justify-content: center;
    z-index: 99999;
    padding: 20px;
}
.qmihna-modal__inner {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 22px;
    width: min(900px, 95vw);
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.qmihna-modal__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.qmihna-modal__head h2 { margin: 0; color: var(--maroon); font-size: 22px; }
.qmihna-modal__close {
    background: none; border: none; font-size: 28px; cursor: pointer; color: #6b5b2e;
}

.qmihna-hand-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* Tools coverage progress per profession */
.qmihna-tools-coverage {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed #e5d8b4;
}
.qmihna-tools-coverage h4 { margin: 0 0 10px; color: var(--maroon); font-size: 15px; }
.qmihna-tools-coverage__row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}
.qmihna-tools-coverage__bar {
    flex: 1;
    height: 8px;
    background: #f0e4c6;
    border-radius: 4px;
    overflow: hidden;
}
.qmihna-tools-coverage__fill {
    height: 100%;
    background: var(--green);
    transition: width .3s ease;
}
.qmihna-tools-coverage__count { color: #6b5b2e; font-weight: 700; min-width: 36px; text-align: end; }

/* Challenge selector */
.qmihna-challenge { display: grid; gap: 14px; }
.qmihna-challenge__group { display: grid; gap: 8px; }
.qmihna-challenge__group label {
    font-weight: 700; color: var(--maroon);
}
.qmihna-challenge__opts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.qmihna-challenge__opt {
    padding: 10px;
    background: #fff;
    border: 2px solid #f0e4c6;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    font-weight: 700;
}
.qmihna-challenge__opt.is-selected {
    border-color: var(--maroon);
    background: #fff7f2;
    color: var(--maroon);
}

/* Win screen */
.qmihna-win {
    text-align: center;
    background: linear-gradient(135deg, #c9a14a 0%, #f6e9c8 100%);
    padding: 40px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.qmihna-win__crown { font-size: 80px; }
.qmihna-win__name { font-size: 36px; font-weight: 900; color: var(--maroon); margin: 8px 0; }
.qmihna-win__profession { font-size: 22px; margin: 0 0 22px; color: #2a1a05; }
.qmihna-win__tools {
    display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
    margin: 18px auto;
    max-width: 700px;
}
.qmihna-win__tools span {
    background: #fff;
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 700;
    color: #2a1a05;
    border: 2px solid var(--maroon);
}

/* Rules modal */
.qmihna-rules h3 { color: var(--maroon); margin: 16px 0 6px; }
.qmihna-rules p, .qmihna-rules li { line-height: 1.7; color: #2a1a05; }
.qmihna-rules ul, .qmihna-rules ol { padding-right: 22px; }

/* Helpers */
.qmihna-hidden { display: none !important; }
.qmihna-flex   { display: flex; }
.qmihna-center { display: flex; align-items: center; justify-content: center; }

/* Top bar */
.qmihna-topbar {
    display: flex; gap: 8px; flex-wrap: wrap;
    align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.qmihna-topbar__left  { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qmihna-topbar__right { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tool chip */
.qmihna-tool-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #4a3a14;
    border: 1px solid #e5d8b4;
    margin: 2px;
}
.qmihna-tool-chip[data-prof] { border-color: var(--gold); }
