:root {
    --primary-color: #FFD700; 
    --secondary-color: #FFA500; 
    --bg-color: #2b0c0c; 
    --game-bg: #1a0505; 
    --text-color: #faebd7; 
    --text-muted: #d2b48c; 
    --snake-color: #FFD700; 
    --food-color: #4ade80; 
    --panel-bg: #4a1212; 
    --border-color: #8B0000; 
    --button-bg: #800000; 
    --button-hover: #a52a2a; 
    --input-bg: #1a0505; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    background-image: linear-gradient(135deg, #2b0c0c 0%, #000000 100%); 
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    max-width: 624px; 
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch; 
    gap: 20px;
    box-sizing: border-box; 
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    background: var(--panel-bg);
    border-radius: 10px;
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

h1 {
    margin: 0;
    font-size: 1.8rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.social-links {
    display: flex;
    gap: 8px;
}

.social-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--input-bg);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.social-btn:hover {
    transform: translateY(-2px);
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 10px var(--primary-color);
}

.x-btn:hover {
    
}

.tg-btn:hover {
    
}

.btn {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    background-color: var(--button-bg);
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn.primary {
    background-color: var(--primary-color);
    color: var(--bg-color); 
    border-color: var(--primary-color);
}

.btn.primary:hover {
    background-color: #fff;
    box-shadow: 0 0 15px var(--primary-color);
}

.btn.sm {
    padding: 5px 10px;
    font-size: 0.8rem;
    margin-left: 10px;
}

.btn.secondary {
    background-color: var(--panel-bg);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn.secondary:hover {
    background-color: var(--border-color);
}

.address-display {
    font-family: monospace;
    background: var(--input-bg);
    padding: 8px 15px;
    border-radius: 5px;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.wallet-info {
    display: flex;
    align-items: center;
}

#walletIcon img {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    vertical-align: middle;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
}

.close-modal:hover {
    color: white;
}

.wallet-list {
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.wallet-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    background: var(--input-bg);
    border: 1px solid transparent;
}

.wallet-item:hover {
    background: var(--border-color);
    border-color: var(--primary-color);
}

.wallet-item img {
    width: 32px;
    height: 32px;
    margin-right: 15px;
    border-radius: 6px;
}

.wallet-item span {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-color);
}

.loading-wallets {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.modal-footer {
    padding: 15px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
}

.hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.game-area {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    background-color: var(--panel-bg);
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

canvas {
    background-color: var(--game-bg);
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-color);
}

.score-board {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px; 
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    box-sizing: border-box;
    color: var(--primary-color);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.hidden {
    display: none !important;
}

.leaderboard-area {
    width: 100%;
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 10px;
    box-sizing: border-box;
    border: 2px solid var(--border-color); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.leaderboard-header h3 {
    margin-bottom: 0;
    color: var(--primary-color);
}

.status-badge {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--bg-color);
    font-weight: bold;
}

.status-badge.online {
    background-color: #FFD700;
    box-shadow: 0 0 5px #FFD700;
}

.status-badge.offline {
    background-color: #ff4d4d;
    box-shadow: 0 0 5px #ff4d4d;
    color: white;
    opacity: 0.9;
}

.leaderboard-area ul {
    list-style: none;
    padding: 0;
}

.leaderboard-area li {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-area li:last-child {
    border-bottom: none;
}

.rank {
    color: var(--primary-color);
    font-weight: bold;
    width: 30px;
}

.addr {
    font-family: monospace;
    color: var(--text-muted);
}

.score {
    color: var(--primary-color);
    font-weight: bold;
}

.note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.round-info {
    background: var(--input-bg);
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.round-timer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
}

.round-timer .time {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: bold;
}

.history-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.history-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--text-muted);
    text-align: center;
}

.history-list {
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.9rem;
}

.history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.round-badge {
    background: var(--primary-color);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
    color: var(--bg-color);
    margin-right: 5px;
    font-weight: bold;
}

.winner-addr {
    font-family: monospace;
    color: #fff;
}

.winner-score {
    color: var(--primary-color);
}

.empty-history {
    text-align: center;
    color: var(--text-muted);
    padding: 10px;
    font-size: 0.9rem;
}

.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; 
}

.toast {
    background: rgba(43, 12, 12, 0.95);
    border: 1px solid var(--primary-color);
    color: var(--text-color);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 90vw;
    animation: slideDown 0.3s ease-out forwards;
    pointer-events: auto; 
    backdrop-filter: blur(5px);
}

.toast.success {
    border-color: #00ff00;
}

.toast.error {
    border-color: #ff3333;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-content {
    flex: 1;
    font-size: 0.95rem;
}

.toast.hiding {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}