/* ============================================================
   Arabic Memory Game — Full-width gaming-themed RTL layout
   ============================================================ */

.ar-memory-page { direction: rtl; }

/* ---- Main container ---- */
.arm-main {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 80px 24px 40px;
    min-height: calc(100vh - 80px);
}
.admin-bar .arm-main { padding-top: 112px; }

/* ---- Title ---- */
.arm-title-wrap { text-align: center; margin-bottom: 20px; }

.arm-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 900;
    margin: 0 0 6px;
    background: linear-gradient(135deg, #ffe600, #ff6b00, #ff0066);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: armTitlePulse 3s ease-in-out infinite;
}
@keyframes armTitlePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.25); }
}

.arm-subtitle {
    color: rgba(255,255,255,0.65);
    font-size: 1.05rem;
    margin: 0;
}

/* ---- Controls bar ---- */
.arm-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 20px;
}

.arm-ctrl-group label {
    display: block;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 5px;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.arm-diff-btns, .arm-pair-btns {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 3px;
}

.arm-diff-btn, .arm-pair-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.arm-diff-btn.active, .arm-pair-btn.active {
    background: linear-gradient(135deg, #00f0ff, #b400ff);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0,240,255,0.3);
}

.arm-diff-btn:hover:not(.active),
.arm-pair-btn:hover:not(.active) {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.arm-new-game-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #00ff88, #00f0ff);
    color: #0a0a1a;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s;
    font-family: inherit;
    letter-spacing: 0.5px;
}
.arm-new-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,255,136,0.35);
}
.arm-new-game-btn:active { transform: scale(0.97); }

/* ---- Stats bar ---- */
.arm-stats {
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 12px 20px;
    background: rgba(255,255,255,0.04);
    border-radius: 14px;
    border: 1px solid rgba(0,240,255,0.1);
}

.arm-stat {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    font-weight: 600;
}
.arm-stat-icon { font-size: 1.15em; margin-left: 4px; }

/* ---- Loading ---- */
.arm-loading {
    text-align: center;
    padding: 80px 20px;
    animation: armFadeIn 0.3s;
}
.arm-loading p {
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    margin-top: 20px;
}

.arm-loader-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #00f0ff;
    border-radius: 50%;
    animation: armSpin 0.8s linear infinite;
}
@keyframes armSpin { to { transform: rotate(360deg); } }

/* ---- Card Grid ---- */
.arm-grid {
    display: grid;
    gap: 14px;
    justify-content: center;
    margin: 0 auto;
    perspective: 1200px;
}

/* Responsive grid columns */
.arm-grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); max-width: 680px; }
.arm-grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); max-width: 900px; }
.arm-grid[data-cols="5"] { grid-template-columns: repeat(5, 1fr); max-width: 1100px; }
.arm-grid[data-cols="6"] { grid-template-columns: repeat(6, 1fr); max-width: 1300px; }

/* ---- Card ---- */
.arm-card {
    position: relative;
    aspect-ratio: 3 / 2.2;
    min-height: 110px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.arm-card.flipped { transform: rotateY(180deg); }
.arm-card.matched {
    transform: rotateY(180deg);
    cursor: default;
}
.arm-card.matched .arm-card-front,
.arm-card.matched .arm-card-back {
    border-color: #00ff88;
    box-shadow: 0 0 20px rgba(0,255,136,0.3);
}

.arm-card.wrong .arm-card-back {
    border-color: #ff0066 !important;
    box-shadow: 0 0 18px rgba(255,0,102,0.4) !important;
    animation: armShake 0.4s;
}

@keyframes armShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.arm-card-front, .arm-card-back {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.08);
    transition: border-color 0.3s, box-shadow 0.3s;
    overflow: hidden;
}

/* Front (hidden by default — seen when not flipped) */
.arm-card-front {
    background: linear-gradient(145deg, rgba(20,20,50,0.95), rgba(30,30,70,0.95));
    flex-direction: column;
    gap: 6px;
}
.arm-card-front::before {
    content: '؟';
    font-size: 2.5rem;
    color: rgba(0,240,255,0.5);
    font-weight: 900;
}
.arm-card-front-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.arm-card-front:hover {
    border-color: rgba(0,240,255,0.3);
    box-shadow: 0 0 16px rgba(0,240,255,0.15);
}

/* Back (shown when flipped) */
.arm-card-back {
    transform: rotateY(180deg);
    padding: 14px 16px;
    text-align: center;
}

.arm-card-back.arm-side-a {
    background: linear-gradient(145deg, rgba(0,100,140,0.9), rgba(0,60,100,0.95));
    border-color: rgba(0,240,255,0.25);
}
.arm-card-back.arm-side-b {
    background: linear-gradient(145deg, rgba(100,0,140,0.9), rgba(70,0,100,0.95));
    border-color: rgba(180,0,255,0.25);
}

.arm-card-text {
    font-size: clamp(0.85rem, 1.8vw, 1.15rem);
    font-weight: 700;
    line-height: 1.6;
    color: #fff;
    direction: rtl;
    word-break: break-word;
}

.arm-card-side-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.arm-side-a .arm-card-side-badge { background: rgba(0,240,255,0.25); color: #00f0ff; }
.arm-side-b .arm-card-side-badge { background: rgba(180,0,255,0.25); color: #d580ff; }

/* Card entrance animation */
.arm-card { animation: armCardIn 0.4s ease backwards; }
.arm-card:nth-child(1)  { animation-delay: 0.02s; }
.arm-card:nth-child(2)  { animation-delay: 0.04s; }
.arm-card:nth-child(3)  { animation-delay: 0.06s; }
.arm-card:nth-child(4)  { animation-delay: 0.08s; }
.arm-card:nth-child(5)  { animation-delay: 0.10s; }
.arm-card:nth-child(6)  { animation-delay: 0.12s; }
.arm-card:nth-child(7)  { animation-delay: 0.14s; }
.arm-card:nth-child(8)  { animation-delay: 0.16s; }
.arm-card:nth-child(9)  { animation-delay: 0.18s; }
.arm-card:nth-child(10) { animation-delay: 0.20s; }
.arm-card:nth-child(11) { animation-delay: 0.22s; }
.arm-card:nth-child(12) { animation-delay: 0.24s; }
.arm-card:nth-child(13) { animation-delay: 0.26s; }
.arm-card:nth-child(14) { animation-delay: 0.28s; }
.arm-card:nth-child(15) { animation-delay: 0.30s; }
.arm-card:nth-child(16) { animation-delay: 0.32s; }
.arm-card:nth-child(17) { animation-delay: 0.34s; }
.arm-card:nth-child(18) { animation-delay: 0.36s; }
.arm-card:nth-child(19) { animation-delay: 0.38s; }
.arm-card:nth-child(20) { animation-delay: 0.40s; }
.arm-card:nth-child(21) { animation-delay: 0.42s; }
.arm-card:nth-child(22) { animation-delay: 0.44s; }
.arm-card:nth-child(23) { animation-delay: 0.46s; }
.arm-card:nth-child(24) { animation-delay: 0.48s; }

@keyframes armCardIn {
    from { opacity: 0; transform: scale(0.7) rotateY(40deg); }
    to   { opacity: 1; transform: scale(1) rotateY(0); }
}

/* Match celebration */
.arm-card.matched { animation: armMatchPop 0.5s ease; }
@keyframes armMatchPop {
    0%   { transform: rotateY(180deg) scale(1); }
    40%  { transform: rotateY(180deg) scale(1.08); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* ---- Welcome Screen ---- */
.arm-welcome {
    text-align: center;
    padding: 60px 20px;
    animation: armFadeIn 0.5s;
}
.arm-welcome-icon { font-size: 4rem; margin-bottom: 16px; }
.arm-welcome h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #00f0ff, #b400ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 12px;
}
.arm-welcome p {
    color: rgba(255,255,255,0.6);
    font-size: 1.05rem;
    line-height: 1.8;
    margin: 0 0 24px;
}
.arm-welcome-start { font-size: 1.15rem; padding: 16px 40px; }

/* ---- Win Screen ---- */
.arm-win {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(5,5,20,0.92);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: armFadeIn 0.4s;
    overflow-y: auto;
    padding: 30px 16px;
}
.arm-win-content {
    text-align: center;
    max-width: 700px;
    width: 100%;
}
.arm-win-trophy {
    font-size: 5rem;
    animation: armTrophyBounce 1s ease infinite;
}
@keyframes armTrophyBounce {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-16px) rotate(-5deg); }
    75% { transform: translateY(-8px) rotate(5deg); }
}
.arm-win h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffe600, #ff6b00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 10px 0;
}
.arm-win-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin: 16px 0;
}
.arm-win-stats p { color: rgba(255,255,255,0.7); font-size: 1.05rem; margin: 0; }
.arm-win-stats strong { color: #00f0ff; }

.arm-win-pairs-title {
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
    margin: 24px 0 10px;
}
.arm-win-pairs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding: 0 10px;
}
.arm-win-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    direction: rtl;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.85);
}
.arm-win-pair .arm-wp-a { color: #00f0ff; font-weight: 700; }
.arm-win-pair .arm-wp-arrow { color: rgba(255,255,255,0.3); font-size: 1.2rem; }
.arm-win-pair .arm-wp-b { color: #d580ff; font-weight: 700; }

@keyframes armFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .arm-main { padding: 70px 10px 30px; }
    .arm-grid { gap: 8px; }
    .arm-card { min-height: 90px; }
    .arm-controls { gap: 10px; }
    .arm-diff-btn, .arm-pair-btn { padding: 6px 12px; font-size: 0.82rem; }
    .arm-stats { gap: 14px; font-size: 0.88rem; }
    .arm-card-text { font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .arm-grid[data-cols="4"] { grid-template-columns: repeat(3, 1fr); }
    .arm-grid[data-cols="5"] { grid-template-columns: repeat(3, 1fr); }
    .arm-grid[data-cols="6"] { grid-template-columns: repeat(3, 1fr); }
    .arm-card { min-height: 80px; }
    .arm-card-text { font-size: 0.75rem; }
    .arm-card-side-badge { font-size: 0.55rem; padding: 2px 5px; }
}
