/* Pattern Memory — Violet theme */
:root {
    --pm-accent: #8B5CF6;
    --pm-accent-light: #C4B5FD;
    --pm-accent-dark: #6D28D9;
    --pm-bg: #0A0820;
    --pm-surface: #160F2E;
    --pm-surface-light: #221A40;
    --pm-text: #ECE9FA;
    --pm-text-dim: #9C8FCC;
    --pm-cell: #1B1438;
    --pm-cell-border: #2C2050;
    --pm-success: #34D399;
    --pm-danger: #F87171;
    --pm-gold: #FACC15;
}

.pm-layout { display: flex; justify-content: center; gap: 20px; max-width: 1200px; margin: 0 auto; padding: 20px; min-height: calc(100vh - 80px); }
.ad-slot { width: 160px; flex-shrink: 0; }
.ad-slot--left, .ad-slot--right { display: flex; align-items: flex-start; }
.ad-placeholder--vertical { width: 160px; height: 600px; background: var(--pm-surface); border: 1px dashed var(--pm-text-dim); display: flex; align-items: center; justify-content: center; color: var(--pm-text-dim); font-size: 12px; border-radius: 8px; }

#patternmemory-app { flex: 1; max-width: 720px; min-width: 320px; color: var(--pm-text); }

.screen { display: none; }
.screen.active { display: block; animation: pmFade 0.3s ease; }
@keyframes pmFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.pm-header { text-align: center; padding: 36px 0 24px; }
.pm-logo { display: inline-grid; grid-template-columns: repeat(3, 22px); gap: 4px; padding: 10px; background: var(--pm-surface); border-radius: 10px; border: 1px solid var(--pm-cell-border); margin-bottom: 14px; }
.pm-cell { width: 22px; height: 22px; border-radius: 5px; background: var(--pm-cell); }
.pm-cell--on { background: var(--pm-accent); box-shadow: 0 0 14px rgba(139,92,246,0.6); animation: pmPulse 2.4s ease-in-out infinite; }
@keyframes pmPulse { 0%,100% { box-shadow: 0 0 10px rgba(139,92,246,0.45); } 50% { box-shadow: 0 0 22px rgba(139,92,246,0.85); } }
.pm-header h1 { font-family: 'Syne', sans-serif; font-size: 2.4rem; font-weight: 800; color: var(--pm-accent-light); letter-spacing: 4px; margin: 0; text-shadow: 0 0 26px rgba(139,92,246,0.5); }
.subtitle { color: var(--pm-text-dim); font-size: 1rem; margin-top: 8px; }

.card { background: var(--pm-surface); border-radius: 14px; padding: 20px; margin-bottom: 16px; border: 1px solid var(--pm-surface-light); }
.card__title { font-family: 'Syne', sans-serif; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; color: var(--pm-accent-light); margin-bottom: 14px; }

.diff-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.diff-btn { background: var(--pm-surface-light); border: 1.5px solid transparent; color: var(--pm-text); padding: 14px 8px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: 'DM Sans', sans-serif; font-size: 0.85rem; transition: transform 0.12s ease, border-color 0.12s ease; }
.diff-btn:hover { transform: translateY(-2px); border-color: var(--pm-accent); }
.diff-btn.selected { background: linear-gradient(135deg, var(--pm-accent-dark), var(--pm-accent)); border-color: var(--pm-accent-light); }
.diff-icon { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 700; color: var(--pm-accent-light); }
.diff-btn.selected .diff-icon { color: #fff; }
.diff-desc { font-size: 0.72rem; color: var(--pm-text-dim); }

.pm-rules { margin: 0; padding-left: 1.1rem; color: var(--pm-text-dim); font-size: 0.92rem; line-height: 1.6; }
.pm-rules li + li { margin-top: 6px; }

.btn { font-family: 'DM Sans', sans-serif; font-weight: 600; border-radius: 10px; border: none; cursor: pointer; padding: 12px 22px; transition: transform 0.12s ease, box-shadow 0.12s ease; font-size: 0.95rem; }
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: linear-gradient(135deg, var(--pm-accent), var(--pm-accent-light)); color: #fff; box-shadow: 0 6px 18px rgba(139,92,246,0.35); }
.btn--outline { background: transparent; border: 1.5px solid var(--pm-accent); color: var(--pm-accent-light); }
.btn--outline:hover:not(:disabled) { background: rgba(139,92,246,0.12); }
.btn--outline:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--pm-text-dim); }
.btn--ghost:hover { color: var(--pm-accent-light); }
.btn--lg { padding: 16px 36px; font-size: 1.05rem; }
.btn--sm { padding: 8px 14px; font-size: 0.85rem; }
.menu-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 18px; }

#game-hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: var(--pm-surface); padding: 14px; border-radius: 12px; border: 1px solid var(--pm-surface-light); margin-bottom: 18px; }
.hud__cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--pm-text-dim); }
.hud__value { font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; font-weight: 700; color: var(--pm-accent-light); }
#hud-lives { color: var(--pm-danger); }

.pm-board-area { display: flex; justify-content: center; padding: 16px 0; }
.pm-board { display: grid; gap: 8px; padding: 14px; background: var(--pm-surface); border-radius: 16px; border: 1px solid var(--pm-surface-light); box-shadow: 0 12px 36px rgba(0,0,0,0.45); }
.pm-tile { width: 64px; height: 64px; background: var(--pm-cell); border: 1.5px solid var(--pm-cell-border); border-radius: 12px; cursor: pointer; transition: transform 0.08s ease, background 0.2s ease, box-shadow 0.2s ease; }
.pm-tile:hover { transform: scale(0.96); }
.pm-tile.show { background: linear-gradient(135deg, var(--pm-accent), var(--pm-accent-light)); border-color: var(--pm-accent-light); box-shadow: 0 0 22px rgba(139,92,246,0.6), inset 0 0 12px rgba(255,255,255,0.3); }
.pm-tile.picked { background: linear-gradient(135deg, var(--pm-accent-dark), var(--pm-accent)); border-color: var(--pm-accent-light); }
.pm-tile.correct { background: linear-gradient(135deg, #047857, var(--pm-success)); border-color: var(--pm-success); box-shadow: 0 0 22px rgba(52,211,153,0.45); }
.pm-tile.wrong { background: linear-gradient(135deg, #7f1d1d, var(--pm-danger)); border-color: var(--pm-danger); box-shadow: 0 0 22px rgba(248,113,113,0.45); }

.pm-board[data-size="3"] .pm-tile { width: 86px; height: 86px; }
.pm-board[data-size="4"] .pm-tile { width: 74px; height: 74px; }
.pm-board[data-size="5"] .pm-tile { width: 60px; height: 60px; }
.pm-board[data-size="6"] .pm-tile { width: 50px; height: 50px; }

.pm-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.result-card, .lb-card { background: var(--pm-surface); border-radius: 16px; padding: 36px 28px; border: 1px solid var(--pm-surface-light); text-align: center; max-width: 480px; margin: 40px auto; box-shadow: 0 18px 36px rgba(0,0,0,0.4); }
.result-card h2 { font-family: 'Syne', sans-serif; font-size: 2rem; color: var(--pm-accent-light); letter-spacing: 4px; margin: 0 0 12px; }
.result-score { font-family: 'JetBrains Mono', monospace; font-size: 3rem; font-weight: 700; color: var(--pm-gold); margin: 8px 0; }
.result-detail { color: var(--pm-text-dim); font-size: 0.95rem; margin-bottom: 18px; line-height: 1.6; }
#nickname { width: 100%; padding: 12px 14px; border-radius: 10px; background: var(--pm-bg); color: var(--pm-text); border: 1.5px solid var(--pm-surface-light); font-family: 'DM Sans', sans-serif; font-size: 0.95rem; margin-bottom: 12px; box-sizing: border-box; }
#nickname:focus { outline: none; border-color: var(--pm-accent); }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }

.lb-card h2 { font-family: 'Syne', sans-serif; color: var(--pm-accent-light); letter-spacing: 4px; margin-bottom: 18px; }
#leaderboard-list { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; counter-reset: lb; }
#leaderboard-list li { counter-increment: lb; display: flex; justify-content: space-between; padding: 10px 14px; background: var(--pm-bg); margin-bottom: 6px; border-radius: 8px; border: 1px solid var(--pm-surface-light); }
#leaderboard-list li::before { content: counter(lb); color: var(--pm-accent-light); font-weight: 700; margin-right: 10px; min-width: 24px; }
#leaderboard-list li:nth-child(1) { border-color: var(--pm-gold); }
#leaderboard-list li:nth-child(1)::before { color: var(--pm-gold); }
#leaderboard-list .lb-score { font-family: 'JetBrains Mono', monospace; color: var(--pm-accent-light); font-weight: 600; }

@media (max-width: 900px) {
    .pm-layout { flex-direction: column; padding: 12px; }
    .ad-slot { width: 100%; }
    .ad-placeholder--vertical { width: 100%; height: 90px; }
    .diff-grid { grid-template-columns: repeat(2, 1fr); }
    .pm-header h1 { font-size: 1.9rem; letter-spacing: 2px; }
    .pm-board[data-size="3"] .pm-tile { width: 72px; height: 72px; }
    .pm-board[data-size="4"] .pm-tile { width: 60px; height: 60px; }
    .pm-board[data-size="5"] .pm-tile { width: 50px; height: 50px; }
    .pm-board[data-size="6"] .pm-tile { width: 42px; height: 42px; }
}
