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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    background: #050510;
    color: #fff;
    user-select: none;
}

#gameContainer { position: relative; width: 100vw; height: 100vh; height: 100dvh; }
#gameCanvas { display: block; width: 100%; height: 100%; }
#uiOverlay { position: absolute; inset: 0; pointer-events: none; }
#uiOverlay button, #uiOverlay .overlay.active { pointer-events: auto; }
.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 0, 20, 0.82);
    z-index: 1000; opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.loading-content h2 { color: #FFD700; }

/* ---------- top bar ---------- */
#topBar {
    position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
    text-align: center; width: 100%;
}
.logo {
    font-size: clamp(22px, 4vw, 44px); font-weight: 900; letter-spacing: 3px;
    background: linear-gradient(180deg, #FFF6B0, #FFD700 45%, #FF8C00);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 0 12px rgba(255, 140, 0, 0.6));
}
.logo span { color: #FF4FD8; -webkit-text-fill-color: #FF4FD8; font-size: 0.6em; vertical-align: middle; }
.rules { font-size: clamp(10px, 1.3vw, 14px); letter-spacing: 2px; color: #CDB8FF; margin-top: 4px; }

/* ---------- free spins banner ---------- */
#freeSpinsBanner {
    position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 28px; padding: 8px 26px; border-radius: 40px;
    background: linear-gradient(90deg, #3A0050, #7A0090, #3A0050);
    border: 2px solid #FF4FD8; box-shadow: 0 0 25px #FF00FF88; z-index: 20;
}
#freeSpinsBanner > div { display: flex; flex-direction: column; align-items: center; }
#freeSpinsBanner .lbl { font-size: 10px; letter-spacing: 2px; color: #FFC6F5; }
#freeSpinsBanner strong { font-size: 22px; color: #FFF; }
#freeSpinsBanner .mult strong { color: #FFD700; font-size: 26px; text-shadow: 0 0 12px #FFD700; }
body.battle-mode .rules { visibility: hidden; }
body.battle-mode #gameCanvas { filter: saturate(1.25) hue-rotate(-10deg); }

/* ---------- Storm Duel move picker ---------- */
#movePanel {
    position: absolute; left: 50%; bottom: 200px; transform: translateX(-50%); z-index: 25;
    display: flex; gap: 14px; pointer-events: auto; transition: opacity 0.2s;
}
#movePanel.dim { opacity: 0.35; }
#movePanel .move {
    font: 900 16px/1 "Arial Black", Arial, sans-serif; letter-spacing: 1px; color: #fff; cursor: pointer;
    padding: 14px 20px; border-radius: 14px; border: 2px solid #9fe8ff;
    background: linear-gradient(180deg, #1d5a8a, #0b1f45); box-shadow: 0 0 18px #4fd8ff99, inset 0 2px 0 #ffffff44;
    animation: movePulse 1.1s ease-in-out infinite alternate;
}
#movePanel .move:nth-child(2) { border-color: #d4ff9f; background: linear-gradient(180deg, #3f7a1d, #12300b); box-shadow: 0 0 18px #b4ff4f99; }
#movePanel .move:nth-child(3) { border-color: #ffe79f; background: linear-gradient(180deg, #8a641d, #45300b); box-shadow: 0 0 18px #ffd34f99; }
#movePanel .move:hover { transform: translateY(-3px) scale(1.05); }
#movePanel .move.chosen { transform: scale(1.12); filter: brightness(1.4); }
#movePanel .move .key { display: inline-block; margin-right: 8px; padding: 2px 7px; border-radius: 6px; background: #00000066; font-size: 12px; }
@keyframes movePulse { to { box-shadow: 0 0 30px currentColor; } }
#movePanel .move:disabled { cursor: default; animation: none; }

/* ---------- clash HUD ---------- */
#clashHud {
    position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 20; text-align: center;
    padding: 6px 26px 8px; border-radius: 18px; border: 2px solid var(--clash, #4fd8ff);
    background: linear-gradient(90deg, #0a0618ee, #1c0f3cee, #0a0618ee); box-shadow: 0 0 26px var(--clash, #4fd8ff);
}
.ch-title { font-size: 15px; font-weight: 900; letter-spacing: 4px; color: var(--clash, #4fd8ff); text-shadow: 0 0 10px var(--clash, #4fd8ff); }
.ch-row { display: flex; gap: 30px; justify-content: center; }
.ch-row > div { display: flex; flex-direction: column; align-items: center; }
.ch-row .lbl { font-size: 10px; letter-spacing: 2px; color: #cfc4ff; }
.ch-row strong { font-size: 22px; color: #fff; min-height: 28px; }
body.clash-mode .rules { visibility: hidden; }

/* ---------- win ticker ---------- */
#winTicker {
    position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%);
    text-align: center; padding: 6px 24px; border-radius: 12px;
    background: rgba(0, 0, 0, 0.7); border: 2px solid #FFD700; z-index: 20; max-width: 92vw;
}
#winTickerLine { font-size: 12px; color: #CDB8FF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#winTickerAmount { font-size: 28px; font-weight: 900; color: #7CFF7C; text-shadow: 0 0 10px #39FF14; }
#winTicker.bump { animation: bump 0.3s ease-out; }
@keyframes bump { 0% { transform: translateX(-50%) scale(1.25); } 100% { transform: translateX(-50%) scale(1); } }

/* ---------- multiplier pop ---------- */
#multiplierDisplay {
    position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
    font-size: clamp(60px, 12vw, 140px); font-weight: 900; color: #FFD700; z-index: 30;
    text-shadow: 0 0 20px #FF8C00, 0 0 50px #FF00FF, 4px 4px 0 #000;
}
#multiplierDisplay.pop { animation: multPop 0.45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes multPop { from { transform: translate(-50%, -50%) scale(0.2); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ---------- bottom bar ---------- */
#bottomBar {
    position: absolute; bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(10, 0, 30, 0.95), rgba(10, 0, 30, 0.6));
    border-top: 2px solid #6B3CFF; z-index: 10;
}
.stats { display: flex; gap: 22px; align-items: center; flex: 1; }
.stat { display: flex; flex-direction: column; }
.label { font-size: 10px; letter-spacing: 2px; color: #A99BD8; }
.value { font-size: 20px; font-weight: 800; }
.value.gold { color: #FFD700; }
.value.green { color: #7CFF7C; }
.small-stat .value { font-size: 14px; color: #ccc; }
.bet-row { display: flex; align-items: center; gap: 8px; }
.round {
    width: 30px; height: 30px; border-radius: 50%; border: 2px solid #A98BFF;
    background: #241052; color: #fff; font-size: 18px; font-weight: 900; cursor: pointer;
}
.round:hover { background: #3A1C80; }

.spin-button {
    width: 104px; height: 104px; border-radius: 50%; flex-shrink: 0; margin-top: -40px;
    border: 4px solid #FFE680; cursor: pointer;
    background: radial-gradient(circle at 35% 30%, #7CFF7C, #13A813 55%, #075807);
    color: #fff; font-size: 22px; font-weight: 900; letter-spacing: 2px;
    text-shadow: 0 2px 0 #000; box-shadow: 0 0 25px rgba(124, 255, 124, 0.55), inset 0 -6px 0 rgba(0,0,0,.3);
    transition: transform 0.1s;
}
.spin-button:hover:not(:disabled) { transform: scale(1.06); }
.spin-button:active:not(:disabled) { transform: scale(0.95); }
.spin-button:disabled { cursor: default; filter: saturate(0.6) brightness(0.85); }
.spin-button.spinning { pointer-events: auto; cursor: pointer; }
.spin-button.spinning::after {
    content: '⟳'; font-size: 44px; display: inline-block; animation: rot 0.6s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.controls { display: flex; gap: 8px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
.pill {
    padding: 8px 14px; border-radius: 20px; border: 2px solid #6B3CFF;
    background: #1A0B3D; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
}
.pill:hover:not(:disabled) { background: #2D1666; }
.pill.active { background: #6B3CFF; border-color: #CDB8FF; }
.pill.warn { border-color: #FFB020; background: #4A2A00; animation: warnPulse 1s ease-in-out infinite; }
@keyframes warnPulse { 50% { box-shadow: 0 0 16px #FFB020; } }
.pill.buy { border-color: #FF4FD8; background: linear-gradient(180deg, #7A0090, #3A0050); }
.pill:disabled { opacity: 0.4; cursor: default; }

/* ---------- celebration ---------- */
#celebrationOverlay { background: radial-gradient(ellipse at center, rgba(5,0,20,0.6) 0%, rgba(5,0,20,0.25) 45%, rgba(5,0,20,0) 75%); }
.celebration-content { text-align: center; padding: 20px; }
.celebration-title {
    font-size: clamp(42px, 9vw, 110px); font-weight: 900;
    background: linear-gradient(180deg, #FFF, #FFD700 40%, #FF4500);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 0 25px #FF8C00); animation: celebPulse 0.8s ease-in-out infinite alternate;
}
@keyframes celebPulse { to { transform: scale(1.06); } }
.celebration-amount { font-size: clamp(36px, 7vw, 84px); font-weight: 900; color: #7CFF7C; text-shadow: 0 0 20px #39FF14; margin-top: 10px; }
.celebration-sub { color: #E6D9FF; font-size: clamp(13px, 1.8vw, 20px); margin-top: 6px; }
.celebration-progress { width: min(420px, 80vw); height: 10px; margin: 26px auto 0; background: #ffffff22; border-radius: 6px; overflow: hidden; }
.celebration-bar { height: 100%; width: 0; background: linear-gradient(90deg, #FFD700, #FF00FF); }
.hint { margin-top: 14px; font-size: 12px; color: #9a8fc0; }

/* ---------- toast ---------- */
#gameMessage {
    position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(0.7);
    font-size: clamp(20px, 3.5vw, 40px); font-weight: 900; color: #FFD700; text-align: center;
    text-shadow: 0 0 16px #FF8C00, 3px 3px 0 #000; padding: 12px 30px; border-radius: 14px;
    background: rgba(0, 0, 0, 0.7); border: 2px solid #FFD700;
    z-index: 900; pointer-events: none; opacity: 0; transition: opacity 0.2s, transform 0.25s;
}
#gameMessage.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- paytable ---------- */
.paytable {
    max-width: 640px; max-height: 86vh; overflow-y: auto; padding: 26px 30px; border-radius: 16px;
    background: #120830; border: 2px solid #6B3CFF; line-height: 1.45; font-size: 14px;
}
.paytable h2 { color: #FFD700; margin-bottom: 8px; }
.paytable h3 { color: #FF8CF0; margin: 14px 0 4px; }
.paytable table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.paytable th, .paytable td { padding: 4px 8px; border-bottom: 1px solid #ffffff1a; text-align: right; }
.paytable th:first-child, .paytable td:first-child { text-align: left; }
.paytable .small { color: #9a8fc0; font-size: 12px; margin-top: 12px; }

/* ---------- mobile ---------- */
@media (max-width: 768px) {
    #bottomBar { flex-wrap: wrap; justify-content: center; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
    .stats { order: 1; width: 100%; justify-content: space-between; gap: 8px; flex: none; }
    .small-stat { display: none; }
    .value { font-size: 16px; }
    .spin-button { order: 2; width: 76px; height: 76px; margin-top: 0; font-size: 16px; }
    .controls { order: 3; flex: none; justify-content: center; }
    .pill { padding: 6px 10px; font-size: 11px; }
    .rules { display: none; }
    #winTicker { bottom: 178px; }
    #freeSpinsBanner { gap: 14px; padding: 6px 14px; top: 50px; }
    #movePanel { bottom: 250px; gap: 6px; }
    #movePanel .move { font-size: 11px; padding: 10px 8px; }
    #clashHud { top: 50px; padding: 4px 14px; }
    .ch-row strong { font-size: 16px; }
    #freeSpinsBanner strong { font-size: 16px; }
}

/* ---- Social casino / game server UI ---- */
.pill.free { border-color: #3CE07A; background: linear-gradient(180deg, #0F5A2E, #06301A); min-width: 64px; }
.pill.free.ready { animation: freePulse 1.2s ease-in-out infinite; }
@keyframes freePulse { 0%, 100% { box-shadow: 0 0 0 rgba(60, 224, 122, 0); } 50% { box-shadow: 0 0 18px rgba(60, 224, 122, 0.9); } }
.mode-badge { position: absolute; top: 10px; right: 12px; padding: 4px 10px; border-radius: 999px; font: 700 11px/1.4 system-ui, sans-serif;
    letter-spacing: 1px; color: #FFE9A8; background: rgba(60, 30, 0, 0.75); border: 1px solid #FFB020; z-index: 20; pointer-events: none; }
.replay-banner { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); padding: 8px 18px; border-radius: 10px; z-index: 30;
    font: 800 16px/1.3 system-ui, sans-serif; letter-spacing: 2px; color: #fff; background: rgba(180, 20, 60, 0.85); border: 2px solid #FF7A9A;
    pointer-events: none; animation: warnPulse 1.4s ease-in-out infinite; }
.history { background: rgba(14, 6, 34, 0.96); border: 2px solid #6B3CFF; border-radius: 14px; padding: 18px 22px; width: min(760px, 94vw);
    max-height: 82vh; overflow: auto; color: #EDE6FF; font-family: system-ui, sans-serif; }
.history h2 { margin: 0 0 6px; color: #FFD700; }
.history table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th, .history td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); text-align: left; white-space: nowrap; }
.history td.num { text-align: right; font-variant-numeric: tabular-nums; }
.history td.win { color: #7CFF7C; }
.history button { background: #2D1666; color: #fff; border: 1px solid #8B6CFF; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; }
.history button:disabled { opacity: 0.5; cursor: default; }
.history .ok { color: #7CFF7C; } .history .bad { color: #FF6B6B; }

/* ---- Accounts ---- */
.account-button { position: absolute; top: 40px; right: 12px; z-index: 21; pointer-events: auto; }
.account-button.guest { border-color: #3CE07A; }
.account-panel { background: rgba(14, 6, 34, 0.97); border: 2px solid #6B3CFF; border-radius: 14px; padding: 18px 22px; width: min(420px, 92vw);
    max-height: 88vh; overflow: auto; color: #EDE6FF; font-family: system-ui, sans-serif; }
.account-panel h2 { margin: 4px 0 8px; color: #FFD700; }
.account-panel h3 { margin: 14px 0 4px; font-size: 14px; color: #CDB8FF; }
.account-panel form { display: flex; flex-direction: column; gap: 8px; }
.account-panel label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: #CDB8FF; }
.account-panel label.check { flex-direction: row; align-items: flex-start; gap: 8px; color: #EDE6FF; }
.account-panel input[type=text], .account-panel input[type=email], .account-panel input[type=password] {
    padding: 8px 10px; border-radius: 8px; border: 1px solid #6B3CFF; background: #1A0C3A; color: #fff; font-size: 15px; }
.account-panel input:focus { outline: 2px solid #FFD700; }
.account-panel button { padding: 9px 14px; border-radius: 8px; border: 1px solid #8B6CFF; background: #2D1666; color: #fff; font-weight: 700; cursor: pointer; }
.account-panel button.primary { background: linear-gradient(180deg, #7A3CFF, #4A1AB0); border-color: #CDB8FF; }
.account-panel button.danger { background: #5A1020; border-color: #FF6B6B; }
.account-panel button:disabled { opacity: 0.5; cursor: default; }
.account-panel a { color: #8FE4FF; }
.account-panel .acct-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.account-panel .acct-tabs a { flex: 1; text-align: center; padding: 6px; border-radius: 8px; text-decoration: none; background: #1A0C3A; color: #CDB8FF; }
.account-panel .acct-tabs a.on { background: #6B3CFF; color: #fff; }
.account-panel .acct-row { display: flex; gap: 8px; margin-top: 14px; }
.account-panel .msg { min-height: 1.2em; margin: 2px 0 0; font-size: 13px; }
.account-panel .msg.ok { color: #7CFF7C; } .account-panel .msg.bad { color: #FF8B8B; }
.account-panel .small.warn { color: #FFD27A; }
