/* Gomoku Game Styles */
:root {
    /* Game-specific colors */
    --gomoku-primary: #4a6fa5;
    --gomoku-secondary: #6b8cae;
    --gomoku-accent: #ff9800;
    --gomoku-success: #4caf50;
    --gomoku-warning: #ff9800;
    --gomoku-danger: #f44336;
    
    /* Board colors */
    --board-bg: #e6c19c;
    --board-line: #7d5642;
    --board-shadow: rgba(0, 0, 0, 0.2);
    
    /* Stone colors */
    --stone-black: #222;
    --stone-white: #fff;
    --stone-shadow: rgba(0, 0, 0, 0.4);
    
    /* Game dimensions */
    --board-size: 600px;
    --stone-size: 32px;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Game header */
.game-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.back-home-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gomoku-primary);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(74, 111, 165, 0.3);
}

.back-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 111, 165, 0.4);
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gomoku-primary), var(--gomoku-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.help-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--gomoku-accent);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.help-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

/* Main game area */
.game-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: calc(100vh - 80px);
    position: relative;
    transition: all 0.8s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Background styles */
.game-main.bg-traditional {
    background-image: 
        linear-gradient(rgba(103, 126, 234, 0.75), rgba(118, 75, 162, 0.75)),
        url('img/gomoku-1.jpeg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

.game-main.bg-modern {
    background-image: 
        linear-gradient(rgba(103, 126, 234, 0.65), rgba(118, 75, 162, 0.65)),
        url('img/gomoku-2.jpeg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

.game-main.bg-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Mobile optimization for backgrounds */
@media (max-width: 768px) {
    .game-main.bg-traditional,
    .game-main.bg-modern {
        background-attachment: scroll; /* Fixed attachment can cause issues on mobile */
        background-size: cover;
    }
}

.game-description {
    text-align: center;
    margin-bottom: 1rem;
}

.game-description p {
    font-size: 1rem;
    color: white;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Welcome screen */
.welcome-screen {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    max-width: 600px;
    margin: 0 auto;
    flex-shrink: 0;
}

.welcome-screen.visible {
    opacity: 1;
    visibility: visible;
}

.welcome-content {
    text-align: center;
}

.welcome-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    background: linear-gradient(135deg, var(--gomoku-primary), var(--gomoku-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-description {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* Game setup */
.game-setup {
    margin-bottom: 1.5rem;
}

.setup-section {
    margin-bottom: 1.5rem;
}

.setup-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.8rem;
    text-align: center;
}

.mode-selection,
.difficulty-selection,
.color-selection {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.mode-option,
.difficulty-option,
.color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 0.6rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    min-width: 90px;
    text-align: center;
    backdrop-filter: blur(5px);
}

.mode-option:hover,
.difficulty-option:hover,
.color-option:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(74, 111, 165, 0.15);
    border-color: var(--gomoku-primary);
}

.mode-option.active,
.difficulty-option.active,
.color-option.active {
    border-color: var(--gomoku-primary);
    background: rgba(74, 111, 165, 0.15);
    box-shadow: 0 4px 15px rgba(74, 111, 165, 0.2);
}

.mode-option i,
.difficulty-option i {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
    color: var(--gomoku-primary);
}

.mode-option span,
.difficulty-option span,
.color-option span {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.mode-option small,
.difficulty-option small,
.color-option small {
    font-size: 0.7rem;
    color: #666;
    line-height: 1.2;
}

.color-preview {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    margin-bottom: 0.4rem;
    box-shadow: 0 2px 8px var(--stone-shadow);
}

.color-preview.black {
    background: var(--stone-black);
}

.color-preview.white {
    background: var(--stone-white);
    border: 2px solid #ddd;
}

/* Game controls */
.game-controls {
    margin-bottom: 1.2rem;
}

.game-controls button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 2rem;
    background: var(--gomoku-success);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    margin: 0 auto;
}

.game-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* Welcome stats */
.welcome-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    margin-top: 1.5rem;
    padding: 0 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 0.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
}

.stat-item:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.85);
}

.stat-label {
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gomoku-primary);
}

/* Game board container */
.game-board-container {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    overflow: auto;
    max-width: 800px;
    margin: 0 auto;
}

.game-board-container.visible {
    display: block;
}

/* Game status */
.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(8px);
}

.status-info {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.current-player {
    display: flex;
    align-items: center;
}

.player-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-piece {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 6px var(--stone-shadow);
}

.player-piece.black {
    background: var(--stone-black);
}

.player-piece.white {
    background: var(--stone-white);
    border: 2px solid #ddd;
}

.game-info {
    display: flex;
    gap: 1rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-label {
    font-weight: 600;
    color: #666;
}

.info-value {
    color: var(--gomoku-primary);
    font-weight: 600;
}

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

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: var(--gomoku-accent);
    color: white;
    border: none;
    border-radius: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.25);
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Board wrapper */
.board-wrapper {
    display: flex;
    justify-content: center;
    margin: 0.75rem 0;
    position: relative;
    flex-shrink: 0;
    padding: 0.75rem 0;
    min-height: 580px;
    align-items: center;
}

.game-canvas {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
}

#boardCanvas {
    border-radius: var(--border-radius);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.3),
        0 4px 16px rgba(0, 0, 0, 0.2),
        inset 0 0 0 2px rgba(139, 105, 20, 0.3);
    cursor: crosshair;
    border: 3px solid #8b6914;
    position: relative;
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* AI thinking indicator */
.ai-thinking {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 10;
}

.ai-thinking.visible {
    display: block;
}

.thinking-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--gomoku-primary);
    font-weight: 600;
}

.thinking-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid var(--gomoku-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Move history */
.move-history {
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
}

.history-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
    text-align: center;
}

.move-list {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.move-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.move-item:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: translateX(2px);
}

.move-number {
    font-weight: 600;
    color: var(--gomoku-primary);
    min-width: 30px;
}

.move-player {
    font-weight: 500;
    color: #444;
}

.move-position {
    color: #666;
    font-family: monospace;
    font-size: 0.75rem;
}

.no-moves {
    text-align: center;
    color: #aaa;
    font-style: italic;
    font-size: 0.8rem;
    padding: 1rem 0;
}

/* Game instructions */
.game-instructions {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.25rem;
    margin-top: 1rem;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Hide game instructions during gameplay */
.game-main.playing .game-instructions {
    display: none;
}

.game-instructions h3 {
    color: #333;
    margin-bottom: 1.2rem;
    font-size: 1.3rem;
    text-align: center;
    font-weight: 600;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
}

.instruction-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.instruction-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(74, 111, 165, 0.1);
}

.instruction-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 0.8rem;
    background: rgba(74, 111, 165, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--gomoku-primary);
}

.instruction-item h4 {
    color: #333;
    margin-bottom: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
}

.instruction-item p {
    color: #666;
    line-height: 1.5;
    margin: 0;
    font-size: 0.85rem;
}

/* Victory modal */
.victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.victory-modal.visible {
    opacity: 1;
    visibility: visible;
}

.victory-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.victory-header {
    margin-bottom: 2rem;
}

.victory-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.victory-title {
    color: var(--gomoku-primary);
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.victory-message {
    color: #666;
    margin: 0;
    line-height: 1.6;
}

.victory-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.victory-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: rgba(74, 111, 165, 0.1);
    border-radius: var(--border-radius);
}

.victory-stat .stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.victory-stat .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gomoku-primary);
}

.victory-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.victory-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.victory-btn.primary {
    background: var(--gomoku-success);
    color: white;
}

.victory-btn.secondary {
    background: var(--gomoku-accent);
    color: white;
}

.victory-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Help modal */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.help-modal.visible {
    opacity: 1;
    visibility: visible;
}

.help-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.help-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.help-close:hover {
    color: var(--gomoku-primary);
}

.help-title {
    color: var(--gomoku-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.help-section {
    margin-bottom: 2rem;
}

.help-section h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.help-section p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.help-section ul {
    color: #666;
    line-height: 1.6;
    padding-left: 1.5rem;
}

.help-section li {
    margin-bottom: 0.5rem;
}

.help-section strong {
    color: var(--gomoku-primary);
}

/* Share modal */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.share-modal.visible {
    opacity: 1;
    visibility: visible;
}

.share-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    position: relative;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.share-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.share-close:hover {
    color: var(--gomoku-primary);
}

.share-title {
    color: var(--gomoku-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.share-result {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

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

.share-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: white;
}

.share-btn.twitter {
    background: #1da1f2;
}

.share-btn.facebook {
    background: #4267b2;
}

.share-btn.whatsapp {
    background: #25d366;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes stonePlace {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.stone-animation {
    animation: stonePlace 0.4s ease-out;
}

@keyframes winningLine {
    0% {
        stroke-dasharray: 0, 1000;
    }
    100% {
        stroke-dasharray: 1000, 0;
    }
}

.winning-line {
    animation: winningLine 1s ease-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 0.5rem;
    }
    
    .back-home-btn span,
    .help-btn span {
        display: none;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .game-main {
        padding: 0.5rem;
        min-height: calc(100vh - 60px);
    }
    
    .game-main.playing {
        padding-top: 0.25rem;
        justify-content: flex-start;
    }
    
    .game-description {
        margin-bottom: 0.5rem;
    }
    
    .game-description p {
        font-size: 0.9rem;
    }
    
    .game-board-container {
        padding: 0.5rem;
        margin-top: 0;
        border-radius: 12px;
    }
    
    .board-wrapper {
        margin: 0.25rem 0;
        padding: 0.25rem 0;
    }
    
    .move-history {
        max-height: 100px;
        margin-top: 0.5rem;
        padding: 0.4rem 0.6rem;
    }
    
    .game-status {
        padding: 0.3rem 0.6rem;
        margin-bottom: 0.4rem;
    }
    
    .action-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        gap: 0.3rem;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .mode-selection,
    .difficulty-selection,
    .color-selection {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-option,
    .difficulty-option,
    .color-option {
        width: 100%;
        max-width: 200px;
    }
    
    .welcome-stats {
        grid-template-columns: 1fr;
    }
    
    .game-status {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .status-info {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .action-btn span {
        display: none;
    }
    
    :root {
        --board-size: 400px;
        --stone-size: 24px;
    }
    
    .board-wrapper {
        min-height: 450px;
        margin: 0.5rem 0;
        padding: 0.5rem 0;
    }
    
    .instruction-grid {
        grid-template-columns: 1fr;
    }
    
    .victory-stats {
        grid-template-columns: 1fr;
    }
    
    .victory-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .help-content,
    .share-content {
        margin: 0.5rem;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .game-main {
        padding: 0.5rem;
    }
    
    .welcome-screen,
    .game-board-container,
    .game-instructions {
        padding: 0.75rem;
    }
    
    .welcome-title {
        font-size: 1.8rem;
    }
    
    :root {
        --board-size: 360px;
        --stone-size: 20px;
    }
    
    .board-wrapper {
        min-height: 400px;
        margin: 0.25rem 0;
        padding: 0.25rem 0;
    }
    
    .game-main.playing {
        padding-top: 0.25rem;
    }
    
    .game-main.playing .game-board-container {
        max-height: calc(100vh - 80px);
        padding: 0.75rem;
    }
}

/* Forbidden rules button styling */
#forbiddenBtn {
    transition: all 0.3s ease;
}

#forbiddenBtn:hover {
    background: var(--gomoku-primary);
    color: white;
}

#forbiddenBtn #forbiddenText {
    font-weight: 600;
    font-size: 0.9em;
}

/* Background button styling */
#backgroundBtn {
    transition: all 0.3s ease;
}

#backgroundBtn:hover {
    background: linear-gradient(135deg, var(--gomoku-primary), var(--gomoku-secondary));
    color: white;
}

#backgroundBtn #backgroundText {
    font-weight: 600;
    font-size: 0.9em;
}

/* Forbidden move indicators */
.forbidden-indicator {
    color: var(--gomoku-danger);
    font-weight: bold;
    text-shadow: 0 0 3px rgba(244, 67, 54, 0.5);
}

/* Game message styling */
.game-message {
    animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
    0% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
    15% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
    85% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
    100% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
}

/* Layout optimizations for better board focus */
.game-board-container.visible {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    justify-content: center;
}

.board-wrapper {
    order: 1;
    flex-shrink: 0;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-status {
    order: 0;
    flex-shrink: 0;
}

.move-history {
    order: 2;
    flex-shrink: 0;
    min-height: 0;
}

/* Game playing mode - more compact layout */
.game-main.playing {
    justify-content: center;
    align-items: center;
    padding-top: 0.5rem;
    min-height: calc(100vh - 80px);
}

.game-main.playing .game-board-container {
    margin-top: 0;
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.08);
    max-width: 900px;
    height: auto;
    max-height: calc(100vh - 120px);
}

.game-main.playing .move-history {
    background: rgba(255, 255, 255, 0.5);
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    max-height: 140px;
}

/* Board focus enhancement */
.board-focused {
    scroll-margin-top: 2rem;
    position: relative;
}

.board-focused::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.board-focused.highlight::before {
    opacity: 1;
}

/* Performance optimizations */
.game-board-container,
.victory-modal,
.help-modal,
.share-modal,
.ai-thinking {
    will-change: transform, opacity;
}

.action-btn,
.victory-btn,
.share-btn {
    will-change: transform;
} 