@import url("https://fonts.googleapis.com/css2?family=Righteous&family=Nunito:wght@400;600;700;800;900&display=swap");

:root {
    --gold: #f5c842;
    --teal: #00d4aa;
    --cell-light: #e6dfd1;
    --cell-dark: #d0c2ac;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
height: 100vh;
background: radial-gradient(ellipse at top, #1e1060 0%, #0d0d1a 80%);
font-family: "Nunito", sans-serif;
display: flex;
flex-direction: column;
align-items: center;
overflow: hidden; 
padding: 10px 5px;
}
header {
text-align: center;
margin-bottom: 5px;
}
header h1 {
font-family: "Righteous", cursive;
font-size: clamp(1.4rem, 5vw, 2.2rem);
background: linear-gradient(135deg, #f5c842, #ff4d8d, #00d4aa);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin: 0;
}
header p {
color: rgba(255, 255, 255, 0.5);
font-size: 0.7rem;
margin: 0;
}
#layout {
display: flex;
flex-direction: column;
gap: 15px;
align-items: center;
width: 100%;
max-width: 500px;
}
#scene {
perspective: 900px;
width: 95vw;
max-width: 420px;
}
#board-wrap {
transform: rotateX(20deg);
transform-style: preserve-3d;
transition: transform 0.5s;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
border-radius: 8px;
}
#board-wrap.flat {
transform: rotateX(0deg);
}
#board {
display: grid;
grid-template-columns: repeat(10, 1fr);
grid-template-rows: repeat(10, 1fr);
width: 100%;
aspect-ratio: 1 / 1;
border: 6px solid #2a1f6e;
border-radius: 8px;
background: #111;
position: relative;
box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 8px 0 #120b33;
}
.cell {
width: 100%;
height: 100%;
display: flex;
align-items: flex-start;
justify-content: flex-end;
padding: 2px 4px;
font-size: clamp(9px, 2.5vw, 12px);
font-weight: 800;
color: rgba(0, 0, 0, 0.6);
position: relative;
user-select: none;
box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.6), inset -2px -2px 4px rgba(0, 0, 0, 0.25);
border: 1px solid rgba(0, 0, 0, 0.1);
}
.cell.light {
    background: var(--cell-light);
}
.cell.dark {
    background: var(--cell-dark);
}
.cell.snake-head-cell {
background: #b2f5b2 !important;
box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.7), inset -2px -2px 4px rgba(0, 100, 0, 0.4);
}
.cell.ladder-bottom {
background: #ffe8a0 !important;
box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.7), inset -2px -2px 4px rgba(150, 100, 0, 0.3);
}
#svg-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 2;
}
#panel {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 8px;
width: 95vw;
max-width: 420px;
justify-content: space-between;
}
#setup,
#dice-wrap {
flex: 1 1 45%;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
padding: 10px;
backdrop-filter: blur(5px);
}
#cards {
flex: 1 1 100%;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
#setup p {
color: rgba(255, 255, 255, 0.6);
font-size: 0.7rem;
margin-bottom: 5px;
font-weight: 700;
text-align: center;
}
.setup-btns {
display: flex;
gap: 5px;
}
.sbtn {
flex: 1;
padding: 5px;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 6px;
color: #fff;
cursor: pointer;
}
.sbtn.sel {
background: var(--gold);
color: #000;
font-weight: bold;
}
.dice-top {
display: flex;
align-items: center;
justify-content: space-around;
gap: 10px;
}
#dice {
width: 44px;
height: 44px;
background: #fff;
border-radius: 8px;
display: grid;
grid-template-columns: repeat(3, 1fr);
    padding: 5px;
    gap: 3px;
    box-shadow:
        inset 0 0 5px #ccc,
        0 4px 0 #999,
        0 5px 10px rgba(0, 0, 0, 0.5);
}
#dice.rolling {
    animation: diceAnim 0.4s ease;
}
@keyframes diceAnim {
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}
.pip {
    width: 8px;
    height: 8px;
    background: #222;
    border-radius: 50%;
    margin: auto;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.5);
}
.pip.off {
    visibility: hidden;
}

#roll-btn {
    padding: 8px 12px;
    font-family: "Righteous";
    font-size: 1rem;
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 0 #b38900;
    cursor: pointer;
    flex: 1;
}
#roll-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #b38900;
}
#roll-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}
#status-box {
    text-align: center;
    color: var(--teal);
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 6px;
}
.pcard {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pcard.active {
    border-color: var(--gold);
    background: rgba(245, 200, 66, 0.1);
}
.pcard-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.pcard-info {
    display: flex;
    flex-direction: column;
}
.pcard-name {
    font-family: "Righteous";
    font-size: 0.85rem;
    color: #fff;
}
.pcard-pos {
    font-size: 0.65rem;
    color: #aaa;
}
.piece {
    position: absolute;
    width: clamp(16px, 4vw, 22px);
    height: clamp(16px, 4vw, 22px);
    border-radius: 50%;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.8);
    transition:
        left 0.4s,
        top 0.4s;
    pointer-events: none;
    margin-top: -5px;
    margin-left: -5px;
}
.piece-1 {
    background: radial-gradient(circle at top, #ff4d4d, #990000);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}
.piece-2 {
    background: radial-gradient(circle at top, #4d8fff, #003399);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}
.piece-3 {
    background: radial-gradient(circle at top, #4ddd77, #006622);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}
.piece-4 {
    background: radial-gradient(circle at top, #ffcc00, #997a00);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}
.piece.active-glow {
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold);
    z-index: 25;
}

#view-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #fff;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
}
#win-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
#win-overlay.show {
    display: flex;
}
#win-box {
    background: #111;
    border: 2px solid var(--gold);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
}
#win-box h2 {
    color: var(--gold);
    font-family: "Righteous";
    margin-bottom: 10px;
}
#win-box p {
    color: #fff;
    margin-bottom: 20px;
}
#play-again {
    padding: 10px 20px;
    background: var(--gold);
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.hub-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    transition: all 0.2s;
    cursor: pointer;
}
