/* Import site's base styles */
@import url('/css/styles.css');

/* ============================================================================
   GAME MENU CUSTOMIZATION (Nim 21)
   ============================================================================ */
:root {
    --game-primary: #6366f1;
    --game-primary-dark: #4f46e5;
    --game-secondary: #f59e0b;
}

body.game-menu-active {
    --menu-bg-image: url('/interactive/shared/backgrounds/nim21.png');
}

/* Ensure no conflicts: defer menu backdrop/overlay to shared game-menu.css */

/* ============================================================================
   GAME-SPECIFIC STYLES
   ============================================================================ */

/* ===== VARIABLES ===== */
:root {
    /* Site Colors */
    --primary-color: #C90C0F;
    --primary-hover: #a00a0c;
    --secondary-color: #FAB719;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    
    --bg-color: #f8fafc;
    --surface: #FFFFFF;
    --border-color: #e2e8f0;
    --text-primary: #1D1D1B;
    --text-secondary: #64748b;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
}

/* High Contrast Theme */
[data-theme="high-contrast"] {
    --primary-color: #000000;
    --secondary-color: #FFD700;
    --bg-color: #FFFFFF;
    --surface: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #000000;
    --border-color: #000000;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    background: var(--surface);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Use shared game-shell as the core container; keep legacy class for markup */
.game-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

/* ===== HEADER ===== */
.header {
    display: none; /* Hidden by default - game header replaces this */
    background: var(--surface);
    border-bottom: 3px solid var(--primary-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--primary-color);
    margin: 0;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-weight: bold;
}

.header h1 i {
    margin-right: 0.5rem;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ===== GAME BOARD ===== */
.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

/* Total Display */
.total-display {
    text-align: center;
}

.total-number {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.total-number.winning {
    color: var(--success-color);
}

.total-number.danger {
    color: var(--danger-color);
}

.total-label {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-bar-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 2.5rem;
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    margin: 0 auto;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0.25rem;
}

.progress-bar {
    height: calc(100% - 0.5rem);
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-md);
    transition: width 0.5s ease;
    position: relative;
    margin: 0.25rem;
}

.target-marker {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 1;
}

/* Players Section */
.players-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.player-card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    border: 3px solid transparent;
    min-width: 200px;
}

.player-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(201, 12, 15, 0.5);
    transform: scale(1.03);
    background: var(--surface);
}

.player-avatar {
    font-size: 2.5rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.player-card.active .player-avatar {
    color: var(--primary-color);
}

.player-info {
    flex: 1;
}

.player-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.player-status {
    font-size: 0.9rem;
    color: var(--text-primary);
    opacity: 0.8;
}

.vs-divider {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

/* Action Section */
.action-section {
    text-align: center;
}

.action-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.number-btn {
    min-width: 70px;
    min-height: 70px;
    font-size: 2rem;
    font-weight: 700;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.number-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-lg);
    background: var(--primary-hover);
}

.number-btn:active:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
}

.number-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.number-btn.hint-highlight {
    background: var(--success-color);
    animation: hintPulse 1.5s ease-in-out infinite;
}

/* AI Thinking */
.ai-thinking {
    font-size: 1.125rem;
    color: var(--primary-color);
    font-weight: 600;
    min-height: 1.5rem;
}

.ai-thinking i {
    margin-right: 0.5rem;
}

.thinking-dots::after {
    content: '...';
    animation: thinkingDots 1.5s steps(4, end) infinite;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ===== BUTTONS ===== */
/* Base button styling now comes from shared game-menu.css (.btn, .btn-primary, etc.)
   Keep only Nim-specific tweaks here if needed in future. */

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    z-index: 2;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

.modal-scrollable .modal-body {
    overflow-y: auto;
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: white;
    margin: 0;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.modal-header h2 i {
    margin-right: 0.5rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 2rem;
    flex: 1;
}

.modal-footer {
    padding: 1rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: var(--bg-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Settings Modal */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-group label i {
    color: var(--primary-color);
    width: 1.25rem;
}

.setting-group input,
.setting-group select {
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.setting-group input:focus,
.setting-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(201, 12, 15, 0.1);
}

.setting-group small {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
}

/* Move History Modal */
.move-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.move-item {
    padding: 0.875rem;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--border-color);
}

.move-item.player-1-move {
    border-left-color: var(--primary-color);
}

.move-item.player-2-move {
    border-left-color: var(--secondary-color);
}

.move-item.winning-move {
    background: var(--success-color);
    color: white;
    font-weight: 600;
    border-left-color: var(--primary-color);
}

.move-item.no-moves {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    border-left: none;
}

/* Statistics Modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    transition: transform 0.3s ease;
    border: 2px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.stat-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.stat-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Strategy Modal */
.strategy-explanation h4 {
    color: var(--primary-color);
    margin: 1.5rem 0 1rem 0;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    font-size: 1.25rem;
}

.strategy-explanation h4:first-child {
    margin-top: 0;
}

.strategy-explanation h4 i {
    margin-right: 0.5rem;
}

.formula-box {
    background: var(--primary-color);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 1.25rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-md);
}

.winning-positions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
}

.position-badge {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.current-positions {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
}

.strategy-hint {
    background: var(--success-color);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
}

.strategy-hint i {
    margin-right: 0.5rem;
}

.game-theory-box {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 2rem;
    border-left: 4px solid var(--primary-color);
}

.game-theory-box h4 {
    margin-top: 0;
}

.game-theory-box a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.game-theory-box a:hover {
    text-decoration: underline;
}

.strategy-explanation ol,
.strategy-explanation ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.strategy-explanation li {
    margin-bottom: 0.5rem;
}

/* Winner Modal */
.modal-winner {
    max-width: 800px;
}

.modal-body-split {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.winner-content {
    flex: 1;
    text-align: center;
}

.winner-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.winner-image img {
    max-width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
}

.winner-animation {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
}

.winner-text {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.final-score {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Coin Toss Modal */
.coin-toss-container {
    text-align: center;
}

.coin {
    font-size: 6rem;
    margin: 2rem 0;
    color: var(--secondary-color);
}

.coin.flipping {
    animation: coinFlip 1s ease-in-out;
}

.coin-result {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 1rem 0;
}

.coin-explanation {
    color: var(--text-secondary);
    margin-top: 1rem;
}

/* ===== ANIMATIONS ===== */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes hintPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: var(--shadow-md);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
    }
}

@keyframes thinkingDots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(1080deg);
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .header-buttons {
        gap: 0.375rem;
    }
    
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .game-board {
        padding: 1rem;
        justify-content: space-between;
    }
    
    .total-display {
        margin-bottom: 0;
    }
    
    .total-number {
        font-size: clamp(2.5rem, 12vw, 4rem);
        margin: 0.5rem 0;
    }
    
    .total-label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
    
    .progress-bar-container {
        height: 2rem;
        margin-top: 0.75rem;
    }
    
    .target-marker {
        font-size: 0.75rem;
        right: 0.75rem;
    }
    
    .players-section {
        flex-direction: row;
        gap: 0.75rem;
        margin: 0;
    }
    
    .player-card {
        padding: 0.75rem;
        min-width: 0;
        flex: 1;
    }
    
    .player-avatar {
        font-size: 2rem;
    }
    
    .player-name {
        font-size: 0.9rem;
    }
    
    .player-status {
        font-size: 0.8rem;
    }
    
    .vs-divider {
        font-size: 1.25rem;
    }
    
    .action-label {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .action-buttons {
        gap: 0.75rem;
    }
    
    .number-btn {
        min-width: 70px;
        min-height: 70px;
        font-size: 1.75rem;
    }
    
    .ai-thinking {
        font-size: 1rem;
        min-height: 1.25rem;
    }
    
    .game-controls {
        gap: 0.75rem;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        max-height: 90vh;
        margin: 0 0.5rem;
    }
    
    .modal-header {
        padding: 1rem 1.5rem;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-footer {
        padding: 0.75rem 1.5rem;
        flex-wrap: wrap;
    }
    
    .strategy-explanation h4 {
        font-size: 1.1rem;
    }
    
    .formula-box {
        font-size: 1.1rem;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.625rem 0.75rem;
    }
    
    .header h1 {
        font-size: 1.125rem;
    }
    
    .header h1 i {
        margin-right: 0.25rem;
    }
    
    .btn-icon {
        width: 38px;
        height: 38px;
        font-size: 0.95rem;
    }
    
    .game-board {
        padding: 0.75rem;
    }
    
    .total-number {
        font-size: clamp(2rem, 10vw, 3rem);
        margin: 0.375rem 0;
    }
    
    .total-label {
        font-size: 0.75rem;
    }
    
    .progress-bar-container {
        height: 1.75rem;
        margin-top: 0.5rem;
    }
    
    .target-marker {
        font-size: 0.7rem;
        right: 0.5rem;
    }
    
    .players-section {
        gap: 0.5rem;
    }
    
    .player-card {
        padding: 0.625rem;
        border-width: 2px;
    }
    
    .player-avatar {
        font-size: 1.75rem;
    }
    
    .player-name {
        font-size: 0.8rem;
    }
    
    .player-status {
        font-size: 0.7rem;
    }
    
    .vs-divider {
        font-size: 1rem;
    }
    
    .action-label {
        font-size: 0.9rem;
        margin-bottom: 0.625rem;
    }
    
    .action-buttons {
        gap: 0.625rem;
    }
    
    .number-btn {
        min-width: 60px;
        min-height: 60px;
        font-size: 1.5rem;
    }
    
    .ai-thinking {
        font-size: 0.9rem;
    }
    
    .game-controls {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    .modal-content {
        max-height: 92vh;
        margin: 0;
        border-radius: var(--radius-md);
    }
    
    .modal-header {
        padding: 0.875rem 1rem;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
    
    .modal-header h2 {
        font-size: 1.125rem;
    }
    
    .modal-close {
        width: 28px;
        height: 28px;
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 0.625rem 1rem;
    }
    
    .setting-group label {
        font-size: 0.875rem;
    }
    
    .setting-group input,
    .setting-group select {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .setting-group small {
        font-size: 0.8rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    .strategy-explanation h4 {
        font-size: 1rem;
        margin: 1rem 0 0.75rem 0;
    }
    
    .strategy-explanation p,
    .strategy-explanation li {
        font-size: 0.9rem;
    }
    
    .formula-box {
        font-size: 1rem;
        padding: 0.875rem;
        margin: 1rem 0;
    }
    
    .position-badge {
        padding: 0.375rem 0.875rem;
        font-size: 0.9rem;
    }
    
    .move-item {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .modal-body-split {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .winner-image img {
        max-height: 250px;
    }
    
    .winner-animation {
        font-size: 4rem;
        margin-bottom: 1rem;
    }
    
    .winner-text {
        font-size: 1.25rem;
    }
    
    .final-score {
        font-size: 1.125rem;
    }
    
    .coin {
        font-size: 4.5rem;
        margin: 1.5rem 0;
    }
    
    .coin-result {
        font-size: 1.25rem;
    }
}

/* Extra small devices (very small phones) */
@media (max-width: 360px) {
    .header h1 {
        font-size: 1rem;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .total-number {
        font-size: 2rem;
    }
    
    .number-btn {
        min-width: 55px;
        min-height: 55px;
        font-size: 1.375rem;
    }
    
    .player-card {
        padding: 0.5rem;
    }
    
    .player-avatar {
        font-size: 1.5rem;
    }
    
    .player-name {
        font-size: 0.75rem;
    }
    
    .player-status {
        font-size: 0.65rem;
    }
    
    .winner-image img {
        max-height: 200px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {
    .game-board {
        padding: 0.5rem 1rem;
        justify-content: space-around;
    }
    
    .total-number {
        font-size: 2rem;
        margin: 0.25rem 0;
    }
    
    .total-label {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    .progress-bar-container {
        height: 1.5rem;
        margin-top: 0.5rem;
    }
    
    .players-section {
        gap: 0.5rem;
    }
    
    .player-card {
        padding: 0.5rem;
    }
    
    .player-avatar {
        font-size: 1.5rem;
    }
    
    .player-name,
    .player-status {
        font-size: 0.75rem;
    }
    
    .action-label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
    
    .number-btn {
        min-width: 55px;
        min-height: 55px;
        font-size: 1.375rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-height: 38px;
    }
    
    .modal-body-split {
        flex-direction: row;
        gap: 1rem;
    }
    
    .winner-image img {
        max-height: 180px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Scrollbar styling */
.move-list::-webkit-scrollbar,
.modal-scrollable .modal-body::-webkit-scrollbar {
    width: 8px;
}

.move-list::-webkit-scrollbar-track,
.modal-scrollable .modal-body::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.move-list::-webkit-scrollbar-thumb,
.modal-scrollable .modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.move-list::-webkit-scrollbar-thumb:hover,
.modal-scrollable .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================================================
   FRIENDS SYSTEM STYLES
   ============================================================================ */

.friends-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    overflow-y: auto;
}

.friends-container {
    max-width: 800px;
    margin: 2rem auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 3px solid var(--game-primary);
}

.friends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
}

.friends-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: 2rem;
}

.close-friends-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.close-friends-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.friends-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.add-friend-section h2,
.friends-list-section h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.add-friend-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.friend-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-primary);
}

.friend-input:focus {
    outline: none;
    border-color: var(--game-primary);
}

.friend-message {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    font-size: 0.9rem;
    display: none;
}

.friend-message.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
    display: block;
}

.friend-message.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    display: block;
}

.friends-list-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#friends-count {
    background: var(--game-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 1rem;
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.no-friends-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

.friend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-color);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.friend-item:hover {
    border-color: var(--game-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.friend-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--game-primary) 0%, var(--game-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.friend-details {
    display: flex;
    flex-direction: column;
}

.friend-name {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.friend-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.friend-status.online {
    color: var(--success-color);
    font-weight: bold;
}

.friend-status.online::before {
    content: '●';
    color: var(--success-color);
    font-size: 1.2rem;
}

.friend-status.offline::before {
    content: '●';
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.status-indicator {
    display: inline-block;
    font-size: 1rem;
    margin-right: 0.25rem;
}

.status-indicator.online-dot {
    color: var(--success-color);
}

.status-indicator.offline-dot {
    color: var(--text-secondary);
}

/* Connection Quality Indicator */
.connection-quality {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.05);
}

.connection-quality.excellent {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.connection-quality.good {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.connection-quality.fair {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.connection-quality.poor {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.connection-quality-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.connection-quality.excellent .connection-quality-indicator {
    background: #22c55e;
    box-shadow: 0 0 4px #22c55e;
}

.connection-quality.good .connection-quality-indicator {
    background: #3b82f6;
    box-shadow: 0 0 4px #3b82f6;
}

.connection-quality.fair .connection-quality-indicator {
    background: #fbbf24;
    box-shadow: 0 0 4px #fbbf24;
}

.connection-quality.poor .connection-quality-indicator {
    background: #ef4444;
    box-shadow: 0 0 4px #ef4444;
}

.friend-actions {
    display: flex;
    gap: 0.5rem;
}

.friend-action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: var(--transition);
    min-width: 44px;
    min-height: 44px;
}

.friend-action-btn.challenge {
    background: var(--success-color);
    color: white;
}

.friend-action-btn.challenge:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.friend-action-btn.remove {
    background: var(--danger-color);
    color: white;
}

.friend-action-btn.remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .friends-container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        padding: 1rem;
    }
    
    .friend-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .friend-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .add-friend-form {
        flex-direction: column;
    }
}
