@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

:root {
    /* Dimensions */
    --cell-size-game: 24px;

    /* Colors */
    --color-red: #ff0000;
    --color-green: #0a9d0a;
    --color-blue: #2389da;
    --color-yellow: #f5d400;

    --color-path: #ffffff;
    --color-home-inner: #ffffff;
    --border-color: #000;

    /* Menu colors */
    --menu-bg-dark: #0a0b1a;
    --sidebar-bg: #0d1236;
    --btn-yellow: #e5cd23;
    --btn-blue: #0b4991;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Fredoka One', cursive, sans-serif;
    user-select: none;
    background: linear-gradient(-45deg, #0a0b1a, #162436, #0b4991, #1a2a40);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: #fff;
    min-height: 100vh;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* =========================================
   MAIN MENU SCREEN
   ========================================= */
#menu-screen {
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: rgba(13, 18, 54, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.4);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 1px;
}

.logo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    width: 30px;
    height: 30px;
    border: 1px solid #fff;
}

.logo-red {
    background: var(--color-red);
}

.logo-green {
    background: var(--color-green);
}

.logo-blue {
    background: var(--color-blue);
}

.logo-yellow {
    background: var(--color-yellow);
}

.search-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 85%;
    margin: 20px 0;
}

.search-input {
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: inherit;
    outline: none;
    transition: background 0.3s;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.search-btn {
    padding: 10px 15px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(145deg, #146cc2, #0b4991);
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.search-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.search-btn:active {
    transform: translateY(1px) scale(0.95);
}

.btn-play-now {
    background: linear-gradient(to bottom, #ffe45c, var(--btn-yellow));
    color: #000;
    border: none;
    border-radius: 30px;
    padding: 12px 25px;
    font-family: inherit;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(229, 205, 35, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.5);
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.5);
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

.btn-play-now:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 20px rgba(229, 205, 35, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.btn-play-now:active {
    transform: translateY(1px) scale(0.95);
    box-shadow: 0 2px 5px rgba(229, 205, 35, 0.4);
}

.btn-play-now:disabled {
    filter: grayscale(1);
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.bottom-nav-btn {
    margin-top: auto;
    margin-bottom: 20px;
}

/* Menu Main Area */
.menu-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 50px;
    padding: 20px;
}

/* Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.modal-content {
    background: rgba(10, 11, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 40px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.board-preview-img {
    width: 390px;
    height: 360px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    margin-bottom: -10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    animation: floatImg 4s ease-in-out infinite;
}

@keyframes floatImg {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}

.btn-play-now.large {
    font-size: 24px;
    padding: 15px 40px;
    border-radius: 30px;
}

/* Modes Section */
.modes-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.hero-text {
    text-align: center;
    font-size: 28px;
    line-height: 1.2;
    text-shadow: 2px 2px 4px #000;
}

.highlight {
    color: var(--btn-yellow);
    font-size: 32px;
}

.modes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.mode-btn {
    background: linear-gradient(145deg, rgba(20, 108, 194, 0.8), rgba(11, 73, 145, 0.9));
    backdrop-filter: blur(5px);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    padding: 15px;
    width: 140px;
    height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mode-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.mode-btn:active {
    transform: translateY(2px) scale(0.95);
}

.mode-btn.selected {
    background: linear-gradient(145deg, #146cc2, #0b4991);
    box-shadow: 0 0 25px rgba(229, 205, 35, 0.6), inset 0 2px 5px rgba(255, 255, 255, 0.3);
    border-color: var(--btn-yellow);
    transform: translateY(-8px) scale(1.05);
}

.mode-icon {
    font-size: 32px;
    margin-bottom: 8px;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s;
}

.mode-btn:hover .mode-icon {
    transform: scale(1.15) rotate(5deg);
}

.mode-text {
    color: var(--btn-yellow);
    text-align: center;
    font-size: 13px;
    line-height: 1.1;
    text-shadow: 1px 1px 1px #000;
}

/* =========================================
   BOARD & GRID STYLES
   ========================================= */
.board {
    display: grid;
    background: var(--border-color);
    gap: 1px;
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    background-color: #c0c0c0;
    /* Gray lines */
}

/* Specific sizing for game board */
#main-board {
    grid-template-columns: repeat(15, var(--cell-size-game));
    grid-template-rows: repeat(15, var(--cell-size-game));
    width: calc(15 * var(--cell-size-game) + 16px);
    height: calc(15 * var(--cell-size-game) + 16px);
}

.cell {
    background: var(--color-path);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}

.cell.red-bg {
    background: var(--color-red);
}

.cell.green-bg {
    background: var(--color-green);
}

.cell.yellow-bg {
    background: var(--color-yellow);
}

.cell.blue-bg {
    background: var(--color-blue);
}

.track-arrow {
    font-weight: bold;
    font-size: calc(var(--cell-size-game) * 0.7);
}

.track-arrow.red-text {
    color: var(--color-red);
}

.track-arrow.green-text {
    color: var(--color-green);
}

.track-arrow.yellow-text {
    color: var(--color-yellow);
}

.track-arrow.blue-text {
    color: var(--color-blue);
}

.star {
    color: #888;
    font-family: sans-serif;
    font-size: calc(var(--cell-size-game) * 0.9);
}

/* Home Bases */
.home {
    position: relative;
    box-sizing: border-box;
}

.home.red-home {
    background: var(--color-red);
    grid-area: 1 / 1 / 7 / 7;
}

.home.green-home {
    background: var(--color-green);
    grid-area: 1 / 10 / 7 / 16;
}

.home.blue-home {
    background: var(--color-blue);
    grid-area: 10 / 1 / 16 / 7;
}

.home.yellow-home {
    background: var(--color-yellow);
    grid-area: 10 / 10 / 16 / 16;
}

.home-inner {
    position: absolute;
    background: var(--color-home-inner);
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    place-items: center;
    padding: 3px;
    box-sizing: border-box;
    top: calc(var(--cell-size-game) + 1px);
    left: calc(var(--cell-size-game) + 1px);
    width: calc(4 * var(--cell-size-game) + 3px);
    height: calc(4 * var(--cell-size-game) + 3px);
}

.home-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    text-shadow: 
      -1.5px -1.5px 0 #fff,  
       1.5px -1.5px 0 #fff,
      -1.5px  1.5px 0 #fff,
       1.5px  1.5px 0 #fff;
    z-index: 10;
}

.home-text.top {
    top: -22px;
}

.home-text.bottom {
    bottom: -22px;
}

.base-circle {
    width: calc(var(--cell-size-game) * 1.1);
    height: calc(var(--cell-size-game) * 1.1);
    border-radius: 50%;
    border: 2px solid #000;
    background-color: #fff; /* Empty white hole */
}
/* Border colors to match player */
.red-base-circle { border-color: var(--color-red); }
.green-base-circle { border-color: var(--color-green); }
.blue-base-circle { border-color: var(--color-blue); }
.yellow-base-circle { border-color: var(--color-yellow); }

/* Center Triangles */
.center-area {
    grid-area: 7 / 7 / 10 / 10;
    width: 100%;
    height: 100%;
    position: relative;
}

.center-area svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Tokens for Game Logic */
.game-token {
    position: absolute !important;
    z-index: 100;
    transition: top 0.3s ease-in-out, left 0.3s ease-in-out, transform 0.2s;
    cursor: pointer;
    transform: scale(var(--token-scale, 1)) translate(var(--token-x, 0px), var(--token-y, 0px));
}

.game-token.playable {
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(var(--token-scale, 1)) translate(var(--token-x, 0px), var(--token-y, 0px));
        filter: brightness(1);
    }

    100% {
        transform: scale(calc(var(--token-scale, 1) * 1.2)) translate(var(--token-x, 0px), var(--token-y, 0px));
        filter: brightness(1.2);
    }
}

.circle-token {
    border-radius: 50%;
    border: 2px solid #000;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
    width: calc(var(--cell-size-game) * 0.9);
    height: calc(var(--cell-size-game) * 0.9);
}

.red-token.circle-token {
    background: var(--color-red);
}

.yellow-token.circle-token {
    background: var(--color-yellow);
}

.pin-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: calc(var(--cell-size-game) * 0.8);
    height: calc(var(--cell-size-game) * 0.95);
    z-index: 5;
    transition: top 0.3s, left 0.3s;
}

.pin-body {
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 1px solid #000;
    position: relative;
    z-index: 2;
    box-shadow: inset -1px -1px 2px rgba(0, 0, 0, 0.3);
    width: 14px;
    height: 14px;
}

.green-token .pin-body {
    background: var(--color-green);
}

.blue-token .pin-body {
    background: var(--color-blue);
}

.red-token .pin-body {
    background: var(--color-red);
}

.yellow-token .pin-body {
    background: var(--color-yellow);
}

.pin-dot {
    position: absolute;
    background: #000;
    border-radius: 50%;
    z-index: 3;
    top: 5px;
    width: 6px;
    height: 6px;
}

.pin-base {
    position: absolute;
    bottom: 2px;
    border-radius: 50%;
    border: 1px solid #000;
    z-index: 1;
    background: #8a2a2a;
    width: 14px;
    height: 6px;
}

/* =========================================
   GAME SCREEN UI
   ========================================= */
#game-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #3b74b6;
    background-image:
        linear-gradient(45deg, #2a5a92 25%, transparent 25%, transparent 75%, #2a5a92 75%, #2a5a92),
        linear-gradient(45deg, #2a5a92 25%, transparent 25%, transparent 75%, #2a5a92 75%, #2a5a92);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.top-controls,
.bottom-controls {
    width: calc(15 * var(--cell-size-game) + 16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-controls {
    padding-bottom: 5px;
}

.bottom-controls {
    padding-top: 5px;
    position: relative;
}

.player-name {
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 10px;
    border-radius: 10px;
}

.dice-box {
    border: 2px solid #ffd700;
    background: linear-gradient(to right, #e8f3d6, #0055b3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 3px 5px;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6);
    transition: filter 0.3s, transform 0.1s;
}

.die-container {
    background: #f7d6d6;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.5);
}

.dice-box:not(.active-dice) {
    filter: grayscale(1) opacity(0.6);
}

.dice-box.active-dice.can-roll {
    cursor: pointer;
    box-shadow: 0 0 15px #ffd700;
}

.dice-box.active-dice.can-roll:active {
    transform: scale(0.95);
}

.die {
    width: 28px;
    height: 28px;
    background: linear-gradient(to bottom, #eeeeee, #999999);
    border: 1px solid #555;
    border-radius: 6px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), inset 2px 2px 4px rgba(255,255,255,0.8), 2px 2px 3px rgba(0,0,0,0.5);
}

.die-dot {
    width: 8px;
    height: 8px;
    background: #000;
    border-radius: 50%;
}

.hint-container {
    position: absolute;
    left: 80px;
    top: 25px;
    display: flex;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s;
}

.hand-icon {
    width: 45px;
    height: 45px;
    margin-top: -20px;
    margin-left: -20px;
    transform: rotate(-45deg);
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.7));
    animation: pointBounce 1s infinite alternate ease-in-out;
}

@keyframes pointBounce {
    0% {
        transform: rotate(-45deg) translate(0, 0);
    }

    100% {
        transform: rotate(-45deg) translate(-5px, -5px);
    }
}

.hint-text {
    color: #fff;
    font-size: 14px;
    line-height: 1.2;
    text-shadow: 1px 1px 2px #000;
    margin-left: -5px;
    font-family: sans-serif;
}

.arrow-up-text {
    color: #66b2ff;
    margin-right: 2px;
}

.btn-back {
    margin-top: 20px;
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 8px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================
   MODALS
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: rgba(10, 11, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.player-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.btn-player-count {
    background: linear-gradient(145deg, #146cc2, #0b4991);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    font-family: inherit;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-player-count:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-player-count:active {
    transform: translateY(1px) scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}