/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #00ff44;
    --accent: #00ff44;
    --green-dim: #008822;
    --green-dark: #003311;
    --bg: #060a06;
    --surface: rgba(0, 18, 0, 0.88);
    --border: #0f0;
    --text: #ccffcc;
}

html, body {
    background: var(--bg);
    color: var(--green);
    font-family: 'Courier New', Courier, monospace;
    min-height: 100vh;
    padding: 15px;
    padding-top: 64px;
    text-align: center;
    overflow-x: hidden;
}

body::after {
    content: "";
    pointer-events: none;
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(0,255,68,0.04) 0%, transparent 60%),
        radial-gradient(ellipse 50% 30% at 80% 20%, rgba(0,200,255,0.03) 0%, transparent 60%);
    z-index: 0;
    animation: bgPulse 8s ease-in-out infinite alternate;
}
@keyframes bgPulse {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

body::before {
    content: "";
    pointer-events: none;
    position: fixed; inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent, transparent 2px,
        rgba(0,255,0,0.012) 2px, rgba(0,255,0,0.012) 4px
    );
    z-index: 9999;
}

/* ─── Network Badge ────────────────────────────────────────────────────────── */
.network-status {
    position: fixed;
    top: 12px; right: 15px;
    display: flex;
    align-items: center;
    background: var(--surface);
    padding: 7px 14px;
    border: 1px solid var(--green);
    border-radius: 30px;
    font-size: 11px;
    box-shadow: 0 0 14px rgba(0,255,0,0.2);
    z-index: 1000;
}
.nav-icon {
    width: 20px; height: 20px; margin-right: 7px;
    filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(60deg);
}

/* ─── Logo ASCII ───────────────────────────────────────────────────────────── */
.ascii-logo {
    font-size: clamp(5px, 1.2vw, 9px);
    line-height: 1.25;
    color: var(--green);
    text-shadow: 0 0 8px var(--green), 0 0 20px rgba(0,255,0,0.3);
    display: inline-block;
    white-space: pre;
    margin: 10px auto 0;
    overflow: hidden;
    position: relative; z-index: 1;
    animation: logoFlicker 10s steps(1) infinite;
}
@keyframes logoFlicker {
    0%, 94%, 96%, 98%, 100% { opacity: 1; }
    95%, 97%                { opacity: 0.7; }
}

.tagline {
    font-size: 14px;
    letter-spacing: 3px;
    text-shadow: 0 0 10px var(--green);
    margin: 8px 0 14px;
    opacity: 0.85;
    position: relative; z-index: 1;
}

/* ─── Season Banner ────────────────────────────────────────────────────────── */
.season-banner {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 auto 14px;
    position: relative; z-index: 1;
}
.season-item {
    background: var(--surface);
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 8px;
    padding: 8px 16px;
    min-width: 130px;
    box-shadow: 0 0 14px rgba(255,215,0,0.08);
}
.season-label {
    display: block;
    font-size: 10px;
    opacity: 0.65;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}
.season-value {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255,215,0,0.5);
}

/* ─── Auth ─────────────────────────────────────────────────────────────────── */
#authSection { margin: 8px auto; position: relative; z-index: 1; }

#walletInfo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--green-dim);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
}

/* ─── Status Message ───────────────────────────────────────────────────────── */
.status-msg {
    min-height: 22px;
    font-size: 12px;
    opacity: 0.9;
    margin: 5px auto;
    transition: color 0.3s;
    position: relative; z-index: 1;
}

/* ─── Modals (nickname + skin shop) ────────────────────────────────────────── */
#nicknameModal, #skinShopModal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
#nicknameModal[style*="block"] { display: flex !important; }

.modal-inner {
    background: #040d04;
    border: 1px solid var(--green);
    border-radius: 10px;
    padding: 30px 40px;
    box-shadow: 0 0 50px rgba(0,255,0,0.18), inset 0 0 20px rgba(0,40,0,0.4);
    max-width: 340px;
    width: 90%;
    animation: modalIn 0.2s ease-out;
}
.skin-shop-inner { max-width: 380px; }
@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.modal-inner h3 { margin-bottom: 10px; font-size: 18px; }
.modal-inner p  { font-size: 13px; opacity: 0.75; margin-bottom: 16px; }

/* ─── Skin Shop List ───────────────────────────────────────────────────────── */
#skinShopList { display: flex; flex-direction: column; gap: 8px; text-align: left; max-height: 300px; overflow-y: auto; }
.skin-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,25,0,0.5);
    border: 1px solid rgba(0,255,68,0.15);
    border-radius: 6px;
    padding: 8px 10px;
}
.skin-swatch {
    width: 18px; height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
}
.skin-name { flex: 1; font-size: 12px; }
.skin-action button { padding: 5px 10px; font-size: 11px; }

/* ─── Main Layout ──────────────────────────────────────────────────────────── */
.main-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin-top: 14px;
    flex-wrap: wrap;
    position: relative; z-index: 1;
}

/* ─── Side Panels ──────────────────────────────────────────────────────────── */
.side-panel {
    background: var(--surface);
    border: 1px solid rgba(0,255,68,0.25);
    border-radius: 10px;
    padding: 16px;
    width: 200px;
    min-width: 160px;
    text-align: left;
    box-shadow: 0 0 20px rgba(0,0,0,0.4), inset 0 0 10px rgba(0,20,0,0.3);
    transition: border-color 0.4s;
}
.side-panel:hover {
    border-color: rgba(0,255,68,0.45);
}
.side-panel h3 {
    font-size: 13px;
    text-align: center;
    margin-bottom: 12px;
    text-shadow: 0 0 8px var(--green);
    border-bottom: 1px solid rgba(0,255,68,0.2);
    padding-bottom: 8px;
}

/* ─── Leaderboard ──────────────────────────────────────────────────────────── */
#leaderboardList { list-style: none; padding: 0; }
#leaderboardList li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 2px;
    font-size: 12px;
    border-bottom: 1px solid rgba(0,255,0,0.08);
    gap: 4px;
    transition: background 0.15s;
}
#leaderboardList li:hover { background: rgba(0,255,0,0.05); }
.lb-rank  { font-size: 14px; flex-shrink: 0; }
.lb-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.lb-score { font-weight: bold; color: var(--green); flex-shrink: 0; }
.lb-empty { font-size: 11px; opacity: 0.5; text-align: center; padding: 10px; }

.lb-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.lb-tab {
    flex: 1;
    background: transparent;
    border: 1px solid rgba(0,255,68,0.2);
    color: var(--green);
    opacity: 0.55;
    font-size: 10px;
    padding: 6px 4px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-weight: normal;
    letter-spacing: 0.3px;
    transition: 0.15s;
}
.lb-tab:hover { opacity: 0.8; background: rgba(0,255,68,0.06); }
.lb-tab.active {
    opacity: 1;
    background: rgba(0,255,68,0.12);
    border-color: var(--green);
    font-weight: bold;
    box-shadow: 0 0 8px rgba(0,255,68,0.15);
}

.btn-small {
    width: 100%;
    margin-top: 10px;
    padding: 6px;
    font-size: 11px;
    background: transparent;
    border: 1px solid rgba(0,255,68,0.3);
    color: var(--green);
    cursor: pointer;
    border-radius: 4px;
    transition: 0.2s;
    font-family: inherit;
}
.btn-small:hover { background: rgba(0,255,68,0.1); border-color: var(--green); }
.btn-small:disabled { opacity: 0.5; cursor: default; }

/* ─── Game Area ────────────────────────────────────────────────────────────── */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

canvas {
    background: #050a05;
    border: 2px solid var(--green);
    border-radius: 6px;
    box-shadow:
        0 0 40px rgba(0,255,68,0.15),
        0 0 80px rgba(0,255,68,0.07),
        inset 0 0 30px rgba(0,0,0,0.6);
    display: block;
    max-width: 100%;
    transition: border-color 0.4s, box-shadow 0.4s;
}

.game-stats {
    display: flex;
    gap: 24px;
    font-size: 14px;
}
.game-stats strong {
    color: var(--green);
    text-shadow: 0 0 8px var(--green);
    transition: color 0.4s, text-shadow 0.4s;
}

/* ─── D-Pad ────────────────────────────────────────────────────────────────── */
.dpad {
    display: grid;
    grid-template-areas:
        ". up ."
        "left center right"
        ". down .";
    grid-template-columns: 44px 44px 44px;
    grid-template-rows: 44px 44px 44px;
    gap: 3px;
}
.dpad-btn {
    background: rgba(0,35,0,0.9);
    border: 1px solid rgba(0,255,68,0.3);
    color: var(--green);
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: 0.1s;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.dpad-btn:active, .dpad-btn:hover {
    background: rgba(0,255,68,0.2);
    border-color: var(--green);
    box-shadow: 0 0 10px var(--green);
    transform: scale(0.95);
}
.dpad-btn[disabled] { background: transparent; border-color: transparent; cursor: default; font-size: 8px; }
.dpad-up     { grid-area: up; }
.dpad-left   { grid-area: left; }
.dpad-center { grid-area: center; }
.dpad-right  { grid-area: right; }
.dpad-down   { grid-area: down; }

.game-buttons-row { display: flex; gap: 8px; }

.btn-restart {
    background: transparent;
    border: 1px solid rgba(0,255,68,0.35);
    color: var(--green);
    padding: 8px 20px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    font-family: inherit;
    transition: 0.2s;
}
.btn-restart:hover {
    background: rgba(0,255,68,0.1);
    border-color: var(--green);
    box-shadow: 0 0 12px rgba(0,255,68,0.3);
    transform: translateY(-1px);
}

/* ─── Roulette Panel ───────────────────────────────────────────────────────── */
.roulette-desc {
    font-size: 11px;
    opacity: 0.65;
    margin-bottom: 12px;
    line-height: 1.5;
}
.spin-cost { font-size: 11px; opacity: 0.5; margin-top: 6px; transition: all 0.3s; }
.divider { border: none; border-top: 1px solid rgba(0,255,68,0.15); margin: 12px 0; }
.hint { font-size: 11px; opacity: 0.6; line-height: 1.5; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
button {
    background: var(--green);
    color: #000;
    border: none;
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}
button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}
button:hover:not(:disabled) {
    background: #fff;
    box-shadow: 0 0 20px rgba(255,255,255,0.5);
    transform: translateY(-1px);
}
button:active:not(:disabled) {
    transform: translateY(0);
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#spinBtn {
    width: 100%;
    animation: spinPulse 3s ease-in-out infinite;
}
#spinBtn:disabled { animation: none; }
@keyframes spinPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(0,255,68,0.4); }
    50%       { box-shadow: 0 0 20px rgba(0,255,68,0.7), 0 0 40px rgba(0,255,68,0.2); }
}

input[type="text"] {
    background: rgba(0,25,0,0.8);
    border: 1px solid var(--green);
    color: var(--green);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    border-radius: 6px;
    width: 100%;
    outline: none;
    transition: box-shadow 0.2s;
}
input[type="text"]::placeholder { opacity: 0.4; }
input[type="text"]:focus { box-shadow: 0 0 14px rgba(0,255,0,0.3), inset 0 0 8px rgba(0,40,0,0.4); }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .side-panel { width: 100%; max-width: 400px; }
    .main-container { flex-direction: column; align-items: center; }
    canvas { width: min(400px, 95vw) !important; height: min(400px, 95vw) !important; }
    .ascii-logo { font-size: 5px; }
    .season-banner { gap: 6px; }
    .season-item { min-width: 100px; padding: 6px 10px; }
}
