:root {
    --bg-dark: #060b14;
    --bg-panel: rgba(8, 20, 36, 0.92);
    --cyan: #00e5ff;
    --cyan-dim: rgba(0, 229, 255, 0.25);
    --teal: #26a17b;
    --gold: #ffb347;
    --danger: #ff5252;
    --text: #e0f2ff;
    --text-dim: #7a9bb5;
}

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

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: "Inter", sans-serif;
    overflow-x: hidden;
}

#gameContainer {
    display: grid;
    grid-template-columns: 1fr 340px;
    height: 100vh;
}

/* --- Board --- */
#board {
    position: relative;
    background: radial-gradient(circle at center, #0a1a2f, #030812);
    border: 2px solid var(--cyan);
    border-radius: 18px;
    margin: 14px;
    box-shadow:
        0 0 30px var(--cyan-dim),
        inset 0 0 40px rgba(0, 229, 255, 0.06);
    overflow: hidden;
}

.board-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: "Orbitron", sans-serif;
    font-size: 5.5vw;
    font-weight: 900;
    color: var(--cyan);
    letter-spacing: 10px;
    text-shadow:
        0 0 12px var(--cyan),
        0 0 40px var(--cyan),
        0 0 80px rgba(0, 229, 255, 0.5);
    pointer-events: none;
    z-index: 0;
    animation: pulseGlow 3s ease-in-out infinite alternate;
    text-transform: uppercase;
}

@keyframes pulseGlow {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.tile {
    position: absolute;
    width: 78px;
    height: 78px;
    border: 1px solid var(--cyan-dim);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(0, 30, 50, 0.7);
    color: var(--text-dim);
    padding: 4px;
    transition: 0.25s;
    z-index: 2;
}
.tile:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 14px var(--cyan-dim);
    transform: scale(1.08);
    z-index: 20;
}
.tile-profit { border-color: rgba(38, 161, 123, 0.6); background: rgba(38, 161, 123, 0.15); color: #7dffb3; }
.tile-loss { border-color: rgba(255, 82, 82, 0.5); background: rgba(255, 82, 82, 0.12); color: #ff9b9b; }

.player-token {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid #fff;
    box-shadow: 0 0 12px var(--gold);
    z-index: 15;
    transition: all 0.5s ease-out;
}

#diceResult {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cyan);
    color: #001018;
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 20px;
    display: none;
    z-index: 30;
}

/* --- UI Panel --- */
#uiPanel {
    background: var(--bg-panel);
    border-left: 2px solid var(--cyan-dim);
    padding: 18px 16px;
    overflow-y: auto;
    position: relative;
}
#uiPanel h1 { font-family: "Orbitron", sans-serif; font-size: 24px; color: var(--cyan); letter-spacing: 3px; }
.subtitle { font-size: 12px; color: var(--text-dim); margin-bottom: 16px; }

#helpBtn {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--cyan);
    background: transparent;
    color: var(--cyan);
    font-weight: 800;
    cursor: pointer;
}
#helpBtn:hover { background: var(--cyan); color: #001018; }

/* Wallet */
#walletPanel { margin-bottom: 16px; }
#connectWallet {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 8px;
    background: var(--cyan);
    color: #001018;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 1px;
}
#connectWallet:hover { opacity: 0.85; }
#connectWallet:disabled { opacity: 0.5; cursor: not-allowed; }

.wallet-address { font-size: 11px; color: var(--text-dim); margin: 8px 0; }

.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    margin: 10px 0;
}
.asset-card {
    border-radius: 10px;
    padding: 8px 6px;
    text-align: center;
    border: 1px solid var(--cyan-dim);
    background: rgba(0, 24, 44, 0.7);
}
.asset-card.gas { border-color: rgba(0, 229, 255, 0.5); }
.asset-card.usdt { border-color: rgba(38, 161, 123, 0.5); }
.asset-card.hpoly { border-color: rgba(255, 179, 71, 0.4); }
.asset-label { display: block; font-size: 9px; letter-spacing: 1px; color: var(--text-dim); }
.asset-value { display: block; font-size: 15px; font-weight: 800; font-family: "Orbitron", monospace; margin-top: 2px; }

.info-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--text-dim); }
.accent { color: var(--cyan); font-weight: 700; }

/* Auto-refresh */
.auto-refresh-toggle { display: flex; align-items: center; gap: 8px; font-size: 11px; margin-top: 10px; color: var(--text-dim); }
.switch { position: relative; display: inline-block; width: 42px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #333; border-radius: 20px; cursor: pointer; transition: 0.3s; }
.slider::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
input:checked + .slider { background: var(--cyan); }
input:checked + .slider::before { transform: translateX(22px); }

/* Player Info */
#playerInfo { margin-bottom: 14px; }
#playerInfo h3 { font-size: 13px; letter-spacing: 1px; margin-bottom: 6px; color: var(--text-dim); }

/* Buttons */
#gameActions { display: grid; gap: 8px; margin-bottom: 18px; }
.game-btn {
    padding: 11px;
    border: 1px solid var(--cyan-dim);
    border-radius: 8px;
    background: rgba(0, 229, 255, 0.06);
    color: var(--cyan);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: 0.25s;
    letter-spacing: 1px;
}
.game-btn:hover:not(:disabled) { background: rgba(0, 229, 255, 0.15); box-shadow: 0 0 14px var(--cyan-dim); }
.game-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#claimPointBtn.enabled { border-color: var(--teal); color: #7dffb3; animation: pulseTeal 1.6s infinite; }
#claimPointBtn.disabled { border-color: var(--danger); color: var(--danger); }

@keyframes pulseTeal {
    0%, 100% { box-shadow: 0 0 4px rgba(38, 161, 123, 0.3); }
    50% { box-shadow: 0 0 16px rgba(38, 161, 123, 0.6); }
}

/* Boost Shop */
.shop-panel {
    margin: 16px 0;
    padding: 12px;
    border-radius: 10px;
    background: rgba(0, 24, 44, 0.6);
    border-left: 3px solid var(--cyan);
}
.shop-panel h3 { font-size: 12px; letter-spacing: 2px; color: var(--cyan); margin-bottom: 8px; }
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(0, 229, 255, 0.08);
}
.shop-item small { display: block; font-size: 10px; color: var(--text-dim); }
.shop-buy {
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    background: var(--teal);
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
}
.shop-buy:hover { box-shadow: 0 0 12px var(--teal); }
.shop-buy:disabled { opacity: 0.4; cursor: not-allowed; }
.boost-credits { font-size: 11px; color: var(--gold); margin-top: 8px; min-height: 14px; }

/* Game Info & Tile */
#gameInfo { font-size: 12px; margin-bottom: 14px; }
#tileDetails {
    padding: 10px;
    border: 1px solid var(--cyan-dim);
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 14px;
}
#tileDetails h3 { color: var(--cyan); font-size: 13px; margin-bottom: 4px; }

/* Log */
#gameLog { margin-top: 10px; }
#gameLog h3 { font-size: 11px; letter-spacing: 2px; color: var(--text-dim); margin-bottom: 6px; }
#logEntries { max-height: 160px; overflow-y: auto; font-size: 11px; }
.log-entry { padding: 3px 6px; margin: 2px 0; border-radius: 4px; background: rgba(0, 229, 255, 0.04); }
.log-entry-profit { color: #7dffb3; }
.log-entry-loss { color: #ff9b9b; }
.log-entry-neutral { color: var(--text-dim); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    overflow-y: auto;
}
.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--cyan);
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    margin: 6% auto;
    padding: 22px;
    position: relative;
}
.modal-content h2 { color: var(--cyan); margin-bottom: 12px; }
.modal-content li { font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.modal-content a { color: var(--cyan); }
.close { position: absolute; top: 10px; right: 16px; font-size: 24px; color: var(--cyan); cursor: pointer; }

/* Responsive */
@media (max-width: 820px) {
    #gameContainer { grid-template-columns: 1fr; grid-template-rows: 60vh 1fr; }
    #board { margin: 8px; }
    .board-title { font-size: 10vw; letter-spacing: 5px; }
    .tile { width: 60px; height: 60px; font-size: 8px; }
}