/* SmashBalls — Mobile-first dark arena theme */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    background: #0a0a14;
    color: #e0e0e0;
    font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    max-width: 500px;
    margin: 0 auto;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow-x: hidden;
}
header { text-align: center; padding: 10px 0 5px; }
header h1 { color: #ff4444; font-size: 1.6em; letter-spacing: 2px; }
header p { color: #666; font-size: 0.8em; }

h2 { color: #fff; margin: 12px 0 6px; font-size: 1.1em; }

/* Fighter panels */
.fighters-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}
.fighter-panel {
    background: #16162a;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 8px 12px;
    text-align: center;
    min-width: 110px;
    transition: all 0.2s;
    flex: 1;
}
.fighter-panel.selected-p1 { border-color: #4488ff; background: rgba(68,136,255,0.1); box-shadow: 0 0 10px rgba(68,136,255,0.3); }
.fighter-panel.selected-p2 { border-color: #ff4444; background: rgba(255,68,68,0.1); box-shadow: 0 0 10px rgba(255,68,68,0.3); }
.fighter-panel h3 { font-size: 0.65em; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.fighter-display .ball-emoji { font-size: 1.8em; display: block; }
.fighter-display .ball-name { font-size: 0.85em; display: block; color: #ccc; }
.vs-badge { font-size: 1.4em; font-weight: bold; color: #ff4444; text-shadow: 0 0 8px rgba(255,68,68,0.4); }

/* Ball grid — compact on mobile */
.ball-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 5px;
    margin: 8px 0;
}
.ball-btn {
    background: #16162a;
    border: 2px solid #2a2a40;
    border-radius: 8px;
    padding: 5px 2px;
    color: #ccc;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    font-size: 0.8em;
    -webkit-tap-highlight-color: transparent;
}
.ball-btn:hover { background: #222244; }
.ball-btn:active { transform: scale(0.95); }
.ball-btn.selected-p1 { border-color: #4488ff; background: rgba(68,136,255,0.15); box-shadow: 0 0 8px rgba(68,136,255,0.3); }
.ball-btn.selected-p2 { border-color: #ff4444; background: rgba(255,68,68,0.15); box-shadow: 0 0 8px rgba(255,68,68,0.3); }
.ball-btn .ball-emoji { font-size: 1.3em; display: block; line-height: 1.2; }
.ball-btn .ball-name { font-size: 0.6em; display: block; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Fight button — big and thumb-friendly */
.fight-btn {
    display: block;
    width: 100%;
    max-width: 350px;
    margin: 10px auto;
    padding: 16px;
    font-size: 1.3em;
    font-weight: bold;
    background: linear-gradient(135deg, #ff4444, #ff6622);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    box-shadow: 0 4px 15px rgba(255,68,68,0.3);
    min-height: 52px;
}
.fight-btn:disabled { background: #333; color: #666; cursor: not-allowed; box-shadow: none; }
.fight-btn:not(:disabled):active { transform: scale(0.97); }
.fight-btn.secondary {
    background: linear-gradient(135deg, #333, #444);
    max-width: 200px;
    font-size: 1em;
    padding: 12px;
    box-shadow: none;
}

/* Arena — responsive canvas 9:16 vertical */
#arena-section {
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#arena-container {
    width: 100%;
    max-width: 405px; /* 810/2 for half-res rendering */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0,0,0,0.5);
    background: #000;
    margin: 0 auto;
}
#arena {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
}

/* Fight result overlay */
#fight-result {
    text-align: center;
    padding: 10px;
    margin: 5px 0;
}
.result-text { font-size: 1.6em; font-weight: bold; }
.result-text.winner { color: #ffcc00; text-shadow: 0 2px 10px rgba(255,204,0,0.5); }
.result-text.draw { color: #888; }

/* Random fight button */
.random-btn {
    background: linear-gradient(135deg, #333, #555) !important;
    max-width: 250px !important;
    font-size: 1em !important;
    padding: 12px !important;
    margin-top: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

/* Rankings */
.rank-row {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    background: #16162a;
    border-radius: 6px;
    margin: 3px 0;
    font-size: 0.85em;
}
.rank-pos { width: 25px; font-weight: bold; color: #ffcc00; }
.rank-emoji { font-size: 1.1em; margin: 0 6px; }
.rank-name { flex: 1; font-weight: 600; }
.rank-wins { color: #888; margin-right: 8px; font-size: 0.8em; }
.rank-wr { color: #4f4; font-weight: bold; font-size: 0.85em; }

/* Recent fights */
.fight-card {
    background: #16162a;
    border-radius: 6px;
    padding: 6px 10px;
    margin: 3px 0;
    font-size: 0.85em;
}

/* Ad slots */
.ad-slot { min-height: 50px; margin: 10px 0; }

/* Footer */
footer {
    text-align: center;
    padding: 12px;
    color: #444;
    font-size: 0.7em;
    border-top: 1px solid #1a1a2e;
    margin-top: 15px;
}
footer a { color: #555; text-decoration: none; }

/* Sound toggle */
.sound-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(30,30,50,0.9);
    border: 1px solid #333;
    border-radius: 20px;
    padding: 6px 12px;
    color: #aaa;
    font-size: 0.8em;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}
.sound-toggle:active { transform: scale(0.95); }
.sound-toggle.muted { color: #555; }

/* Mobile adjustments */
@media (max-width: 400px) {
    header h1 { font-size: 1.3em; }
    .ball-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 3px; }
    .ball-btn .ball-name { display: none; }
    .fighter-panel { padding: 6px 8px; min-width: 90px; }
    .fight-btn { font-size: 1.1em; padding: 14px; }
}
@media (min-width: 768px) {
    body { max-width: 600px; }
    .ball-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}