* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding: 20px 0;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Farcaster Frame Optimizations */
.container.farcaster-optimized {
    max-width: 100%;
    padding: 10px;
}

@media (max-width: 600px) {
    body {
        padding: 10px 0;
    }
    
    .container {
        padding: 10px;
    }
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
    to { text-shadow: 2px 2px 4px rgba(0,0,0,0.3), 0 0 20px rgba(255,255,255,0.3); }
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 15px;
    font-weight: 600;
}

.header-badges {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-mode-badge span, .token-badge span {
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
}

.game-mode-badge span {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
}

.token-badge a {
    text-decoration: none;
}

.token-badge button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.farcaster-token-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.token-badge span, .farcaster-token-btn span {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
}

.token-badge span:hover, .farcaster-token-btn span:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

/* Wallet Status */
.wallet-status {
    text-align: center;
    margin-top: 10px;
    color: white;
    font-size: 0.85rem;
}

.wallet-address {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 15px;
    border-radius: 20px;
    font-family: monospace;
}

/* Game Setup Styles */
.game-setup {
    background: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.player-selection, .player-name-section {
    margin-bottom: 30px;
}

.player-selection h3, .player-name-section h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3rem;
}

.difficulty-warning {
    text-align: center;
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    color: #856404;
    font-weight: 600;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.6);
    }
}

.hard-mode-note {
    text-align: center;
    margin-top: 10px;
    color: #dc3545;
    font-weight: 600;
    font-size: 0.9rem;
}

.player-options {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.player-btn {
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 140px;
}

.player-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.cow-btn:hover, .cow-btn.selected {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
}

.grass-btn:hover, .grass-btn.selected {
    border-color: #28a745;
    background: linear-gradient(135deg, #d4edda, #a8e6cf);
}

.player-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.player-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 5px;
    display: block;
}

.player-desc {
    font-size: 0.85rem;
    color: #666;
    display: block;
}

/* Player Name Input */
.player-name-section {
    text-align: center;
}

#playerNameInput {
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    width: 100%;
    max-width: 300px;
    text-align: center;
    transition: all 0.3s ease;
}

#playerNameInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Game Board Styles */
.game-board {
    background: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.game-header {
    margin-bottom: 30px;
}

.players-info {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    gap: 30px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player-avatar {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 3px solid #e0e0e0;
}

.player-details {
    text-align: left;
}

.player-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 2px;
}

.player-type {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.vs-divider {
    font-weight: bold;
    font-size: 1.2rem;
    color: #666;
    padding: 0 15px;
}

.game-status {
    text-align: center;
}

.current-turn {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.game-info {
    color: #666;
    font-size: 0.95rem;
}

.hard-mode-indicator {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
    animation: hardModeGlow 2s ease-in-out infinite alternate;
}

@keyframes hardModeGlow {
    from { 
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
    }
    to { 
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.6);
    }
}

/* Board Styles */
.board-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.cell {
    width: 80px;
    height: 80px;
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cell:hover:not(.disabled) {
    background: #f0f8ff;
    border-color: #667eea;
    transform: scale(1.05);
}

.cell.cow {
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    border-color: #e17055;
    animation: cellGlow 0.5s ease-out;
}

.cell.grass {
    background: linear-gradient(135deg, #a8e6cf, #81c784);
    border-color: #27ae60;
    animation: cellGlow 0.5s ease-out;
}

@keyframes cellGlow {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.cell.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.cell.winning {
    animation: winning 1s ease-in-out infinite;
}

@keyframes winning {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.cell.hint {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-color: #2196f3;
    animation: hintPulse 1s ease-in-out 3;
}

@keyframes hintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Button Styles */
.btn-primary, .btn-secondary, .btn-hint {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-hint {
    background: linear-gradient(135deg, #17a2b8, #20c997);
    color: white;
}

.btn-hint:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(23, 162, 184, 0.4);
}

.btn-hint:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Leaderboard Section */
.leaderboard-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.leaderboard-section h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.5rem;
}

.leaderboard-info {
    text-align: center;
    margin-bottom: 20px;
}

.leaderboard-info p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.reset-timer {
    font-weight: 600;
    color: #667eea;
}

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-style: italic;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.leaderboard-item.gold {
    background: linear-gradient(135deg, #ffe4b5, #ffd700);
    border-color: #ffd700;
}

.leaderboard-item.silver {
    background: linear-gradient(135deg, #e0e0e0, #c0c0c0);
    border-color: #c0c0c0;
}

.leaderboard-item.bronze {
    background: linear-gradient(135deg, #f4d3b2, #cd7f32);
    border-color: #cd7f32;
}

.leaderboard-rank {
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 15px;
    min-width: 30px;
}

.leaderboard-name {
    flex: 1;
    font-weight: 500;
}

.leaderboard-score {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

/* Stats Section */
.stats-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
}

.stats-section h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    text-align: center;
}

.stat-item {
    background: #f8f9fa;
    padding: 20px 15px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

/* Game Result Modal */
.game-result {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.result-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: resultSlideIn 0.5s ease-out;
}

@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: iconBounce 1s ease-in-out infinite alternate;
}

@keyframes iconBounce {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.result-text {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.result-message {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 15px;
}

.result-score {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
}

.token-promo {
    background: rgba(255, 215, 0, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #ffd700;
}

.token-promo p {
    margin-bottom: 10px;
    color: #333;
    font-size: 0.95rem;
}

.small-token-link {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.small-token-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

/* Token Info Section */
.token-info-section {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2), 0 0 30px rgba(255, 215, 0, 0.3);
    color: white;
    text-align: center;
    border: 2px solid #ffd700;
    position: relative;
    overflow: hidden;
    animation: tokenGlow 3s ease-in-out infinite;
}

@keyframes tokenGlow {
    0%, 100% { 
        box-shadow: 0 15px 35px rgba(0,0,0,0.2), 0 0 30px rgba(255, 215, 0, 0.3);
    }
    50% { 
        box-shadow: 0 15px 35px rgba(0,0,0,0.2), 0 0 50px rgba(255, 215, 0, 0.5);
    }
}

.token-info-section h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #ffd700;
}

.token-description {
    font-size: 1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.token-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.token-address {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    font-family: monospace;
}

.token-address .label {
    color: #ffd700;
    margin-right: 10px;
}

.token-address .address {
    font-size: 0.85rem;
    word-break: break-all;
}

.buy-token-btn {
    display: inline-block;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.buy-token-btn span {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
}

.buy-token-btn span:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
}

/* Transaction Status */
.transaction-status {
    margin-top: 15px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 0.9rem;
}

.transaction-status.success {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
}

.transaction-status.error {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.transaction-status.pending {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

/* Status Messages */
.status {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-top: 20px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    min-height: 20px;
}

.status.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border-left: 4px solid #28a745;
}

.status.info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.status.warning {
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    color: #856404;
    border-left: 4px solid #ffc107;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .header-badges {
        flex-direction: column;
        align-items: center;
    }
    
    .player-options {
        flex-direction: column;
        align-items: center;
    }
    
    .players-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .vs-divider {
        transform: rotate(90deg);
    }
    
    .board {
        padding: 15px;
        gap: 8px;
    }
    
    .cell {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
    
    .game-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .game-actions button {
        width: 100%;
        max-width: 200px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-content {
        margin: 10px;
        padding: 30px 20px;
    }
    
    .token-info-section {
        padding: 20px;
    }
    
    .token-address {
        font-size: 0.75rem;
        padding: 8px 15px;
    }
    
    .buy-token-btn span {
        padding: 12px 20px;
        font-size: 1rem;
    }
}

/* Farcaster Frame Specific */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .game-setup, .game-board, .stats-section, .leaderboard-section, .token-info-section {
        padding: 15px;
        border-radius: 15px;
    }
    
    .board {
        padding: 10px;
        gap: 6px;
    }
    
    .cell {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
        border-radius: 8px;
    }
    
    .player-btn {
        min-width: 120px;
        padding: 15px;
    }
    
    .player-icon {
        font-size: 2rem;
    }
    
    .btn-primary, .btn-secondary, .btn-hint {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .leaderboard-item {
        padding: 10px 15px;
    }
    
    .leaderboard-rank {
        font-size: 1rem;
    }
    
    .leaderboard-score {
        font-size: 1rem;
    }
    
    .token-badge span, .farcaster-token-btn span {
        padding: 6px 15px;
        font-size: 0.85rem;
    }
    
    .buy-token-btn span {
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    
    .difficulty-warning {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .hard-mode-indicator {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .cell:hover:not(.disabled) {
        background: white;
        border-color: #e0e0e0;
        transform: none;
    }
    
    .cell:active:not(.disabled) {
        background: #f0f8ff;
        border-color: #667eea;
        transform: scale(0.95);
    }
    
    button:active {
        transform: scale(0.95);
    }
}

/* Prevent text selection on game elements */
.board, .cell, .player-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 480px) {
    .board {
        padding: 10px;
        gap: 6px;
    }
    
    .cell {
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
    
    .game-setup, .game-board, .stats-section, .leaderboard-section {
        padding: 15px;
    }
    
    .leaderboard-item {
        padding: 8px 12px;
    }
    
    .leaderboard-rank {
        font-size: 0.9rem;
    }
    
    .leaderboard-score {
        font-size: 0.9rem;
    }
    
    .token-info-section h3 {
        font-size: 1.2rem;
    }
    
    .token-description {
        font-size: 0.9rem;
    }
    
    .token-address .address {
        font-size: 0.7rem;
    }
    
    .wallet-status {
        font-size: 0.75rem;
    }
    
    .transaction-status {
        font-size: 0.85rem;
        padding: 8px 15px;
    }
}