@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --bg-dark: #0a0515;
    --bg-panel: #1a103c;
    --primary: #6c5ce7;
    --accent: #ffd700;
    --text-main: #ffffff;
    --text-muted: #a098b6;
    --gold-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --purple-gradient: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    background-image: radial-gradient(circle at 50% 0%, #2a1b54 0%, var(--bg-dark) 50%);
}

.app-container {
    width: 100%;
    max-width: 450px;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background: var(--bg-dark);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 10;
    padding-bottom: 70px; /* Space for bottom nav */
    overflow-y: auto;
}

.active-screen {
    display: flex;
}

#screen-game {
    padding-bottom: 0; /* No bottom nav in game */
}

/* Splash / Loading Screen */
#screen-splash {
    background: radial-gradient(circle at 50% 50%, #3a0d58 0%, #1a0429 100%);
    justify-content: space-between;
    align-items: center;
    z-index: 100; /* Above everything */
    padding-bottom: 0;
}

.splash-content.loading-layout {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    padding: 60px 20px 40px;
    align-items: center;
}

.logo-area-large {
    text-align: center;
    margin-top: 50px;
    position: relative;
}

.logo-text-huge {
    font-size: 55px;
    line-height: 1.2;
    color: var(--accent);
    text-transform: uppercase;
    text-shadow: 0 5px 15px rgba(255, 215, 0, 0.6);
    font-weight: 800;
    margin-bottom: 20px;
}

.logo-text-huge span {
    color: #fff;
    font-size: 40px;
    display: block;
    margin-top: 5px;
}

.logo-graphics {
    position: relative;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.crown {
    position: absolute;
    top: -90px;
    font-size: 60px;
    filter: drop-shadow(0 0 10px rgba(255,215,0,0.8));
    animation: floatUp 2s infinite alternate ease-in-out;
}

.dice-large {
    font-size: 80px;
    z-index: 5;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.8));
}

.pawns-group {
    position: absolute;
    width: 200px;
    height: 150px;
    z-index: 2;
}

.pawn {
    position: absolute;
    font-size: 45px;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5));
}

.pawn.red { top: -20px; left: 10px; transform: rotate(-15deg); }
.pawn.blue { bottom: 0; left: 0; transform: rotate(-5deg); font-size: 55px; }
.pawn.yellow { bottom: 0; right: 0; transform: rotate(15deg); font-size: 60px; }
.pawn.green { top: -30px; right: 10px; transform: rotate(20deg); }

.loading-container {
    width: 80%;
    text-align: center;
    margin-bottom: 30px;
}

.loading-text {
    color: white;
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(108, 92, 231, 0.4);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8a2be2, #d100ff);
    width: 0%;
    border-radius: 10px;
    animation: fillProgress 3s ease-in-out forwards;
    box-shadow: 0 0 10px #d100ff;
}

@keyframes fillProgress {
    0% { width: 0%; }
    50% { width: 60%; }
    100% { width: 100%; }
}

@keyframes floatUp {
    from { transform: translateY(0px); }
    to { transform: translateY(-10px); }
}

/* Dashboard / Home Screen */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.menu-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.wallet-badge {
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
    padding: 5px 15px 5px 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: 1px solid rgba(255,215,0,0.3);
}

.coin-icon {
    width: 24px;
    height: 24px;
}

.add-coin-btn {
    background: var(--accent);
    color: black;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
}

.user-profile-summary {
    text-align: center;
    margin: 10px 0 30px;
}

.avatar-container {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--primary);
}

.level-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--accent);
    color: black;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
}

.game-modes-stacked {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 20px;
}

.mode-btn-stacked {
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.mode-btn-stacked.ai {
    background: linear-gradient(90deg, #1e0b50, #37147a);
    border: 1px solid #4a6cfa;
    box-shadow: 0 0 15px rgba(74, 108, 250, 0.4);
}
.mode-btn-stacked.local {
    background: linear-gradient(90deg, #0f3d17, #135520);
    border: 1px solid #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}
.mode-btn-stacked.create {
    background: linear-gradient(90deg, #2c084a, #4a0d78);
    border: 1px solid #9b59b6;
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.4);
}
.mode-btn-stacked.join {
    background: linear-gradient(90deg, #4d0a42, #7a1068);
    border: 1px solid #ff3399;
    box-shadow: 0 0 15px rgba(255, 51, 153, 0.4);
}

.mode-btn-stacked:hover, .mode-btn-stacked:active {
    transform: translateX(5px);
}
.mode-btn-stacked.ai:hover { box-shadow: 0 5px 25px rgba(74, 108, 250, 0.7); }
.mode-btn-stacked.local:hover { box-shadow: 0 5px 25px rgba(46, 204, 113, 0.7); }
.mode-btn-stacked.create:hover { box-shadow: 0 5px 25px rgba(155, 89, 182, 0.7); }
.mode-btn-stacked.join:hover { box-shadow: 0 5px 25px rgba(255, 51, 153, 0.7); }

.btn-icon {
    width: 45px;
    height: 45px;
    margin-right: 15px;
}

.mode-text-stacked h3 {
    font-size: 16px;
    margin-bottom: 2px;
}

.mode-text-stacked p {
    font-size: 11px;
    color: var(--text-muted);
}

/* Bottom Navigation */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: #150b2e;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    flex: 1;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

/* Wallet Screen */
.screen-header {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 20px;
}

.back-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.wallet-balance-card {
    background: linear-gradient(135deg, #2b1b54, #1a103c);
    margin: 0 20px 30px;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255,215,0,0.2);
}

.wallet-balance-card p {
    color: var(--text-muted);
    font-size: 14px;
}

.balance-amount {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.balance-amount span {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
}

.add-coins-btn-large {
    background: rgba(108, 92, 231, 0.2);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 10px 30px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.coin-packages {
    padding: 0 20px;
}

.coin-packages h3 {
    font-size: 16px;
    margin-bottom: 15px;
}

.package-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.package-item.popular {
    border: 1px solid var(--primary);
}

.pkg-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pkg-icon {
    width: 30px;
    height: 30px;
}

.pkg-left span {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    background: #e74c3c;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.buy-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}


/* Game Area Overrides for new layout */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0,0,0,0.3);
}

.player-info-top-left, .player-info-top-right {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.05);
    padding: 5px 10px;
    border-radius: 20px;
}

.mini-avatar, .mini-avatar-bot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #444;
    display: flex;
    justify-content: center;
    align-items: center;
}

.p-name {
    font-size: 12px;
    font-weight: bold;
}

.p-coins {
    font-size: 10px;
    color: var(--accent);
}

.timer {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--accent);
}

.timer span {
    font-size: 10px;
    color: white;
    background: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
}

.game-area {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 90px auto 10px auto;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.board-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    z-index: 5;
}

.ludo-board {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    position: relative;
    background-image: url('board.svg');
    background-size: 100% 100%;
    touch-action: manipulation;
}

.game-footer {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px;
    margin-top: 20px;
}

.action-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 20px;
    position: relative;
    cursor: pointer;
}

.action-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #2ecc71;
}

.active-dice-area {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(108, 92, 231, 0.2);
    border: 2px solid var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}
.active-dice-area.rolling #dice-visual {
    animation: diceRollAnim 0.3s ease-in-out infinite;
}
@keyframes diceRollAnim {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.3); }
    100% { transform: rotate(360deg) scale(1); }
}

#dice-visual {
    font-size: 45px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    transition: transform 0.2s;
}

.dice-result-badge {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
    border-radius: 10px;
    box-shadow: inset 0 -2px 5px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.4);
    color: #333;
    font-size: 30px;
    font-weight: 900;
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}
.active-dice-area.active-green { border-color: #2ecc71; box-shadow: 0 0 20px #2ecc71; background: rgba(46, 204, 113, 0.2); }
.active-dice-area.active-red { border-color: #e74c3c; box-shadow: 0 0 20px #e74c3c; background: rgba(231, 76, 60, 0.2); }
.active-dice-area.active-blue { border-color: #3498db; box-shadow: 0 0 20px #3498db; background: rgba(52, 152, 219, 0.2); }
.active-dice-area.active-yellow { border-color: #f1c40f; box-shadow: 0 0 20px #f1c40f; background: rgba(241, 196, 15, 0.2); }

.player-panel.active-turn .p-name {
    animation: nameBlink 0.8s infinite alternate;
    transition: all 0.3s;
}
.green-panel.active-turn .p-name { color: #2ecc71; text-shadow: 0 0 10px #2ecc71, 0 0 20px #2ecc71; }
.yellow-panel.active-turn .p-name { color: #f1c40f; text-shadow: 0 0 10px #f1c40f, 0 0 20px #f1c40f; }
.red-panel.active-turn .p-name { color: #e74c3c; text-shadow: 0 0 10px #e74c3c, 0 0 20px #e74c3c; }
.blue-panel.active-turn .p-name { color: #3498db; text-shadow: 0 0 10px #3498db, 0 0 20px #3498db; }

@keyframes nameBlink {
    0% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.4; transform: scale(1); }
}

.dice-btn-placeholder {
    font-size: 40px;
}

.exit-game-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    z-index: 100;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.exit-game-btn:hover {
    background: rgba(231, 76, 60, 0.8);
    border-color: #e74c3c;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6);
}


/* Existing Token & 3D Dice styling kept for game functionality */
/* Tokens */
.token {
    width: 4.8%; height: 4.8%; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.8);
    position: absolute; transition: left 0.25s linear, top 0.25s linear; z-index: 10;
    transform: translate(-50%, -50%);
}
.token.green { background-color: #30a241; }
.token.yellow { background-color: #fbd109; }
.token.red { background-color: #e82121; }
.token.blue { background-color: #2c51b6; }

.token.clickable {
    cursor: pointer;
    border: 3px solid #000;
    box-shadow: 0 0 15px #fff;
    animation: bounce 0.4s infinite alternate;
    z-index: 9999 !important;
    pointer-events: auto !important;
    touch-action: manipulation;
    transform: translate(-50%, -50%) scale(1.4);
    transition: transform 0.15s ease;
}
/* Expand touch target for small tokens */
.token.clickable::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
}
@keyframes bounce { from { margin-top: 0; } to { margin-top: -10px; } }

/* Player Panels */
.player-panel { 
    position: absolute;
    width: 65px;
    height: 65px;
    border-radius: 12px;
    display: flex;
    pointer-events: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}
.green-panel { top: -40px; left: -10px; background-color: transparent; }
.yellow-panel { top: -40px; right: -10px; background-color: transparent; }
.red-panel { bottom: -40px; left: -10px; background-color: transparent; }
.blue-panel { bottom: -40px; right: -10px; background-color: transparent; }

/* 3D Dice Styling */
.dice-container-3d {
    width: 50px;
    height: 50px;
    perspective: 400px;
    display: block;
}
.dice-3d {
    width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transform: translateZ(-25px);
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.dice-face {
    position: absolute; width: 50px; height: 50px; background-color: white; border: 2px solid #ccc; border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}
.face-1 { transform: rotateY(0deg) translateZ(25px); }
.face-6 { transform: rotateY(180deg) translateZ(25px); }
.face-3 { transform: rotateY(90deg) translateZ(25px); }
.face-4 { transform: rotateY(-90deg) translateZ(25px); }
.face-2 { transform: rotateX(90deg) translateZ(25px); }
.face-5 { transform: rotateX(-90deg) translateZ(25px); }

.dot { position: absolute; width: 10px; height: 10px; background: #333; border-radius: 50%; box-shadow: inset 0 2px 5px rgba(0,0,0,0.3); }
.face-1 .dot { top: 50%; left: 50%; transform: translate(-50%, -50%); background: #e82121;}
.face-2 .dot:nth-child(1) { top: 20%; left: 20%; }
.face-2 .dot:nth-child(2) { bottom: 20%; right: 20%; }
.face-3 .dot:nth-child(1) { top: 20%; left: 20%; }
.face-3 .dot:nth-child(2) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.face-3 .dot:nth-child(3) { bottom: 20%; right: 20%; }
.face-4 .dot:nth-child(1) { top: 20%; left: 20%; }
.face-4 .dot:nth-child(2) { top: 20%; right: 20%; }
.face-4 .dot:nth-child(3) { bottom: 20%; left: 20%; }
.face-4 .dot:nth-child(4) { bottom: 20%; right: 20%; }
.face-5 .dot:nth-child(1) { top: 20%; left: 20%; }
.face-5 .dot:nth-child(2) { top: 20%; right: 20%; }
.face-5 .dot:nth-child(3) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.face-5 .dot:nth-child(4) { bottom: 20%; left: 20%; }
.face-5 .dot:nth-child(5) { bottom: 20%; right: 20%; }
.face-6 .dot:nth-child(1) { top: 15%; left: 20%; }
.face-6 .dot:nth-child(2) { top: 50%; left: 20%; transform: translateY(-50%); }
.face-6 .dot:nth-child(3) { bottom: 15%; left: 20%; }
.face-6 .dot:nth-child(4) { top: 15%; right: 20%; }
.face-6 .dot:nth-child(5) { top: 50%; right: 20%; transform: translateY(-50%); }
.face-6 .dot:nth-child(6) { bottom: 15%; right: 20%; }

.active-dice-area:not(.rolling) #dice-visual {
    animation: dicePulse 0.6s infinite alternate;
}
@keyframes dicePulse { from { transform: scale(1); } to { transform: scale(1.1); } }

/* Shared Utilities */
.hidden { display: none !important; }


.btn-primary { width: 100%; padding: 15px; border-radius: 12px; border: none; background: linear-gradient(90deg, #6c5ce7, #d100ff); color: white; font-size: 16px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4); transition: transform 0.2s; }
.btn-primary:active { transform: scale(0.95); }

/* Hide scrollbar globally for the entire app */
::-webkit-scrollbar {
  display: none;
}
* {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Win Screen */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.win-overlay .trophy {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounceTrophy 2s infinite ease-in-out;
}

.win-overlay h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

@keyframes bounceTrophy {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background-color: #f00;
    top: -10px;
    z-index: 10000;
    animation: fall linear infinite;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}
