/* =========================================================
   LUDO CHAMPION — style.css
   ========================================================= */

* { box-sizing: border-box; }

/* Keep native dropdown menus readable throughout the dark interface.
   color-scheme also tells browsers to render the opened system menu in dark mode. */
select {
    color-scheme: dark;
}

select option,
select optgroup {
    background-color: #1b1b2f;
    color: #fff;
}

html {
    overflow-y: auto;
}

body {
    overflow: hidden;
}

body {
    margin: 0;
    padding: 20px;
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: Arial, sans-serif;
}

/* ── GAME CONTAINER ── */
#game-container {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 760px;
    position: relative;
    overflow: visible;
}

/* ── BOARD ──
   Board is authored at 657×657 (the BOARD constant in the scaler).
   The scaler positions it centred inside #game-container and scales
   it down via transform. transform-origin: top left lets the scaler
   compute the exact offset trivially.                               */
#board {
    width: 700px;
    height: 700px;
    /* Stylesheets live in css/, while the board asset remains at project root. */
    background-image: url("../board1.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: absolute;
    transform-origin: top left;
}

/* ── TOKENS ── */
.token {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: absolute;
    border: 3px solid white;
    cursor: pointer;
    transition: left 0.28s ease, top 0.28s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.red    { background: radial-gradient(circle at 35% 35%, #ff6666, #cc0000); }
.blue   { background: radial-gradient(circle at 35% 35%, #6699ff, #0033cc); }
.green  { background: radial-gradient(circle at 35% 35%, #66cc66, #006600); }
.yellow { background: radial-gradient(circle at 35% 35%, #ffee55, #cc9900); }

/* Per-color glow pulse — each token glows its own color */
.token.can-move {
    z-index: 20;
    cursor: pointer;
}

.token.red.can-move {
    animation: pulse-red 0.7s infinite alternate;
}
.token.blue.can-move {
    animation: pulse-blue 0.7s infinite alternate;
}
.token.green.can-move {
    animation: pulse-green 0.7s infinite alternate;
}
.token.yellow.can-move {
    animation: pulse-yellow 0.7s infinite alternate;
}

@keyframes pulse-red {
    from { box-shadow: 0 0 6px 2px rgba(255,100,100,0.6); transform: scale(1);    }
    to   { box-shadow: 0 0 18px 8px rgba(255,0,0,0.95);   transform: scale(1.18); }
}
@keyframes pulse-blue {
    from { box-shadow: 0 0 6px 2px rgba(100,130,255,0.6); transform: scale(1);    }
    to   { box-shadow: 0 0 18px 8px rgba(0,80,255,0.95);  transform: scale(1.18); }
}
@keyframes pulse-green {
    from { box-shadow: 0 0 6px 2px rgba(80,200,80,0.6);   transform: scale(1);    }
    to   { box-shadow: 0 0 18px 8px rgba(0,180,0,0.95);   transform: scale(1.18); }
}
@keyframes pulse-yellow {
    from { box-shadow: 0 0 6px 2px rgba(255,220,50,0.6);  transform: scale(1);    }
    to   { box-shadow: 0 0 18px 8px rgba(220,160,0,0.95); transform: scale(1.18); }
}

/* Finished tokens are dimmed */
.token[data-finished="true"] {
    opacity: 0.45;
    cursor: default;
    animation: none;
}

/* ── CONTROLS — turn label left, dice centered ── */
#controls {
    flex-shrink: 0;
    width: 100%;
    max-width: 760px;
    margin-top: 4px;
    margin-bottom: 2px;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 6px 20px;
    box-sizing: border-box;
}

/* Turn label — natural width, not pushed to extreme edge */
#controls #current-player {
    flex-shrink: 0;
    min-width: 0;
    padding-right: 8px;
}

/* Dice wrapper fills the middle and centers the dice */
#controls #dice-value {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Invisible right spacer matches turn label so dice stays truly centered */
#controls::after {
    content: "";
    flex-shrink: 0;
    width: 80px;
}

/* ── ROLL BUTTON — wraps the 3D dice, tap the dice to roll ── */
#roll-btn {
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.1s, opacity 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#roll-btn:not(:disabled) { animation: dice-glow 1.4s ease-in-out infinite; }
#roll-btn:not(:disabled):hover  { transform: scale(1.08); }
#roll-btn:not(:disabled):active { transform: scale(0.93); animation: none; }
#roll-btn:disabled { opacity: 0.35; cursor: not-allowed; }

@keyframes dice-glow {
    0%   { box-shadow: 0 0 6px 2px rgba(255,220,50,0.5); }
    50%  { box-shadow: 0 0 18px 8px rgba(255,220,50,0.95); }
    100% { box-shadow: 0 0 6px 2px rgba(255,220,50,0.5); }
}

/* ── DICE FACE ── */
#dice-value {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* .dice-face kept for legacy compat but not used visually */
.dice-face { display: none; }
/* NOTE: .dot on 3D faces must remain visible — only hide the flat #d1-d9 dots */

/* ── WIN OVERLAY ── */
#win-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.78);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
}

#win-overlay.show {
    display: flex;
}

#win-box {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid rgba(255,215,0,0.5);
    border-radius: 20px;
    padding: 28px 32px;
    text-align: center;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.25);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 460px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-sizing: border-box;
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

#win-emoji {
    font-size: 64px;
    margin-bottom: 4px;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-10px); }
}

#win-title {
    font-size: 40px;
    font-weight: bold;
    color: gold;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
    letter-spacing: 3px;
    line-height: 1.1;
}

#win-message {
    font-size: 16px;
    color: rgba(255,255,255,0.85);
    margin: 8px 0 2px;
}

/* ── Standings header ── */
#lb-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 14px 0 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

#lb-head-pot { color: gold; }

/* ── Leaderboard rows ── */
#leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
}

.lb-row.lb-first {
    background: rgba(255,215,0,0.10);
    border-color: rgba(255,215,0,0.45);
}

.lb-row.lb-me { box-shadow: inset 0 0 0 1.5px rgba(126,255,126,0.55); }

.lb-medal { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }

.lb-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    font-weight: bold;
    color: white;
    font-size: 15px;
}

.lb-avatar-img { width: 100%; height: 100%; object-fit: cover; }

.lb-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lb-you-tag {
    font-style: normal;
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.8px;
    color: #111;
    background: #7eff7e;
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.lb-amount {
    font-size: 14px;
    font-weight: bold;
    color: gold;
    white-space: nowrap;
}

.lb-row:not(.lb-first) .lb-amount { color: rgba(255,255,255,0.6); }

/* ── Play again button ── */
#play-again-btn {
    margin-top: 16px;
    padding: 13px 36px;
    font-size: 16px;
    font-weight: bold;
    background: gold;
    color: #111;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s;
    width: 100%;
}

#play-again-btn:hover  { transform: scale(1.02); }
#play-again-btn:active { transform: scale(0.97); }

/* ── PLACE BADGES (stamped inside home quadrants) ── */
.place-badge {
    position: absolute;
    display: none;               /* hidden until a player finishes */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 50;
    animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Position each badge over its home quadrant center
   Board is 700×700. Each home block is ~210×210.
   Centers: blue=105,105 | yellow=595,105 | red=105,595 | green=595,595 */
#badge-blue   { left: 42px;  top: 42px;  width: 210px; height: 210px; }
#badge-yellow { left: 448px; top: 42px;  width: 210px; height: 210px; }
#badge-red    { left: 42px;  top: 448px; width: 210px; height: 210px; }
#badge-green  { left: 448px; top: 448px; width: 210px; height: 210px; }

.place-badge .badge-medal {
    font-size: 52px;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

.place-badge .badge-label {
    font-size: 15px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    margin-top: 4px;
    letter-spacing: 1px;
    background: rgba(0,0,0,0.45);
    padding: 2px 10px;
    border-radius: 20px;
}

@keyframes badgePop {
    0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
    70%  { transform: scale(1.2) rotate(5deg);  opacity: 1; }
    100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}

/* ── TOAST NOTIFICATION ── */
#toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.92);
    color: white;
    font-size: 18px;
    font-weight: bold;
    padding: 14px 28px;
    border-radius: 40px;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    z-index: 999;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    /* Never intercept clicks — always a notification, never a button */
    pointer-events: none;
}

#toast.show {
    bottom: 36px;
}

/* ── MUTE BUTTON ── */
#mute-btn.muted  { background: rgba(255,80,80,0.25); }

