:root {
    --bg-dark: #0a0b10;
    --card-bg: #141721;
    --card-inner: #0d0f17;
    --accent-cyan: #00f3ff;
    --accent-pink: #ff0055;
    --accent-gold: #ffcc00;
    --accent-blue: #007aff;
    --text-main: #f0f3f6;
    --text-muted: #8b9bb4;
    --border-color: rgba(255, 255, 255, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent clipping and rubber-banding */
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#appRoot {
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0d0e15;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

/* ==========================================================
   MAIN MENU SCREEN
   ========================================================== */
.screen-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.screen-view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.96);
}

#mainMenuScreen {
    background: radial-gradient(circle at 50% 20%, #1f1a3a 0%, #0a0b10 80%);
    padding: 24px 20px;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
}

.menu-header {
    text-align: center;
    margin-top: 15px;
}

.title-glow {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(0, 243, 255, 0.5));
}

.title-sub {
    font-size: 0.82rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
}

.menu-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.75rem;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(0, 243, 255, 0.3);
    color: var(--accent-cyan);
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff66;
    box-shadow: 0 0 6px #00ff66;
}

.menu-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-menu {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #181d2c;
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.btn-menu:active {
    transform: scale(0.98);
}

.btn-menu.primary {
    background: linear-gradient(135deg, #007aff, #00c6ff);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
}

.btn-menu.secondary {
    background: linear-gradient(135deg, #af52de, #ff2d55);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(255, 45, 85, 0.4);
}

.menu-footer-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.btn-menu-small {
    flex: 1;
    background: #141724;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.menu-player-bar {
    width: 100%;
    background: #11141e;
    padding: 8px 14px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

/* ==========================================================
   GAME BATTLE ARENA (RESPONSIVE NO-CLIP VERTICAL STACK)
   ========================================================== */
#gameArenaScreen {
    background: #090a10;
    padding: 6px 10px 10px 10px;
    justify-content: space-between;
    z-index: 10;
}

/* Arena Top Header */
.arena-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.btn-back-menu {
    background: #1b1f2e;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.arena-stats-mini {
    display: flex;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
}

/* OPPONENT(S) BAR (MOUNTED OVER TOP OF PLAYER BOARD) */
.rivals-strip {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    min-height: 125px;
}

.rival-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.rival-card.teammate {
    border-color: rgba(0, 122, 255, 0.6);
}

.rival-card.opponent {
    border-color: rgba(255, 0, 85, 0.6);
}

.rival-tag {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.rival-tag.red { color: var(--accent-pink); }
.rival-tag.blue { color: var(--accent-cyan); }

.rival-card canvas {
    width: 80px;
    height: 110px;
    background: #08090f;
    border-radius: 4px;
}

/* When in 1v1 mode, make opponent canvas slightly larger and centered */
.rivals-strip.mode-1v1 .rival-card canvas {
    width: 110px;
    height: 130px;
}

/* MAIN PLAYER BATTLE BOARD */
.player-board-wrapper {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    max-height: calc(100vh - 230px);
}

.board-frame {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

canvas#mainBoardCanvas {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 8 / 13;
    background: #0d0f17;
    border-radius: 10px;
    border: 2px solid rgba(0, 243, 255, 0.3);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
    cursor: crosshair;
}

/* Arena Bottom Controls */
.arena-controls {
    width: 100%;
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.btn-swap {
    flex: 1;
    background: #1c2233;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-swap:active {
    background: #252e45;
}

/* Minimal Banner Ad */
.arena-banner-ad {
    width: 100%;
    padding: 4px 8px;
    background: #08090d;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ad-pill {
    background: #222;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.6rem;
    margin-right: 6px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.skins-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.skin-card {
    background: #181d2a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.skin-card.active {
    border-color: var(--accent-cyan);
}

.lead-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.lead-table th, .lead-table td {
    padding: 7px 5px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.user-row {
    background: rgba(0, 243, 255, 0.12);
    font-weight: bold;
    color: var(--accent-cyan);
}

.floating-notice {
    position: fixed;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-cyan);
    color: #000;
    padding: 6px 18px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 0 4px 16px rgba(0, 243, 255, 0.5);
    z-index: 9999;
}
