@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;800&display=swap');

:root {
    --wood: #d4a96a;
    --wood-dark: #b8894a;
    --wood-light: #e8c98a;
    --red: #d32f2f;
    --blue: #1565c0;
    --green: #2e7d32;
    --yellow: #f9a825;
    --red-l: #ef9a9a;
    --blue-l: #90caf9;
    --green-l: #a5d6a7;
    --yellow-l: #fff176;
    --cs: 61px;
    --gap: 2px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #3b2a1a;
    background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 40px);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

#game-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
}

#game-container.landscape {
    --cs: 61px;
}

#game-container.portrait {
    --cs: 46px;
}

h1 {
    font-family: 'Fredoka One', cursive;
    color: #f5deb3;
    font-size: 2.2rem;
    letter-spacing: 3px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 16px;
}

#game-area {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

/* ══════════════ BOARD ══════════════ */
#board-wrap {
    background: #fdf5e6;
    background-image:
        repeating-linear-gradient(0deg, rgba(139, 90, 43, .05) 0px, rgba(139, 90, 43, .05) 1px, transparent 1px, transparent 20px),
        repeating-linear-gradient(90deg, rgba(139, 90, 43, .04) 0px, rgba(139, 90, 43, .04) 1px, transparent 1px, transparent 24px);
    border-radius: 12px;
    padding: 14px;
    box-shadow:
        0 0 0 3px #b8894a,
        0 0 0 6px #8b5a2b,
        0 12px 40px rgba(0, 0, 0, 0.6);
    position: relative;
}


#board {
    display: grid;
    grid-template-columns: repeat(11, var(--cs));
    grid-template-rows: repeat(11, var(--cs));
    gap: var(--gap);
}

.cell {
    width: var(--cs);
    height: var(--cs);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 3px;
}

/* Zone backgrounds (corners) */
.z-yellow {
    background: rgba(249, 168, 37, .22);
}

.z-blue {
    background: rgba(21, 101, 192, .18);
}

.z-green {
    background: rgba(46, 125, 50, .18);
}

.z-red {
    background: rgba(211, 47, 47, .18);
}

/* Path cells — hollow circles */
.path {
    background: transparent;
}

.path::before {
    content: '';
    width: 78%;
    height: 78%;
    border-radius: 50%;
    border: 2.5px solid rgba(100, 60, 20, .28);
    background: rgba(255, 255, 255, 0.55);
    position: absolute;
}

/* Colored home path cells */
.home-yellow::before {
    border-color: var(--yellow);
    background: rgba(249, 168, 37, .3);
}

.home-blue::before {
    border-color: var(--blue);
    background: rgba(21, 101, 192, .25);
}

.home-green::before {
    border-color: var(--green);
    background: rgba(46, 125, 50, .25);
}

.home-red::before {
    border-color: var(--red);
    background: rgba(211, 47, 47, .25);
}

/* Base circles (waiting spots in corners) */
.base-circle {
    width: 78%;
    height: 78%;
    border-radius: 50%;
    border: 2.5px solid rgba(100, 60, 20, .2);
    background: rgba(255, 255, 255, 0.45);
    position: absolute;
}

/* Arrows at start entry cells */
.arrow-right::after {
    content: '→';
    font-size: 1.6rem;
    font-weight: 900;
    position: absolute;
    z-index: 2;
}

.arrow-left::after {
    content: '←';
    font-size: 1.6rem;
    font-weight: 900;
    position: absolute;
    z-index: 2;
}

.arrow-down::after {
    content: '↓';
    font-size: 1.6rem;
    font-weight: 900;
    position: absolute;
    z-index: 2;
}

.arrow-up::after {
    content: '↑';
    font-size: 1.6rem;
    font-weight: 900;
    position: absolute;
    z-index: 2;
}

.arrow-right.c-yellow::after {
    color: var(--yellow);
}

.arrow-left.c-red::after {
    color: var(--red);
}

.arrow-down.c-blue::after {
    color: var(--blue);
}

.arrow-up.c-green::after {
    color: var(--green);
}

/* Center cell */
.center-cell {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

.ctri {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* ══ PIECES ══ */
.piece {
    width: 72%;
    height: 72%;
    border-radius: 50%;
    position: absolute;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
    cursor: pointer;
    user-select: none;
    transition: transform .15s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .45), inset 0 -2px 4px rgba(0, 0, 0, .2), inset 0 2px 4px rgba(255, 255, 255, .3);
}

.piece:hover {
    transform: scale(1.18) translateY(-2px);
}

@keyframes hop {
    0% {
        margin-top: -15px;
        box-shadow: 0 10px 10px rgba(0, 0, 0, 0.4);
    }

    100% {
        margin-top: 0;
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
    }
}

.piece.hopping {
    animation: hop 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 25 !important;
}

.p-yellow {
    background: radial-gradient(circle at 38% 32%, #fff176, #f9a825, #e65100);
}

.p-blue {
    background: radial-gradient(circle at 38% 32%, #90caf9, #1565c0, #0d2e6e);
}

.p-green {
    background: radial-gradient(circle at 38% 32%, #a5d6a7, #2e7d32, #1b4f1e);
}

.p-red {
    background: radial-gradient(circle at 38% 32%, #ef9a9a, #d32f2f, #7f0000);
}

.piece.clickable {
    animation: woodglow .65s ease-in-out infinite alternate;
    z-index: 15;
}

@keyframes woodglow {
    from {
        box-shadow: 0 0 4px 2px rgba(255, 200, 0, .7), 0 3px 8px rgba(0, 0, 0, .4);
    }

    to {
        box-shadow: 0 0 18px 8px rgba(255, 200, 0, .9), 0 3px 8px rgba(0, 0, 0, .4);
        transform: scale(1.18);
    }
}

/* ══════════════ SIDEBAR ══════════════ */
#sidebar {
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 200px;
}

.panel {
    background: rgba(232, 201, 138, .12);
    border: 2px solid rgba(232, 201, 138, .2);
    border-radius: 12px;
    padding: 11px 14px;
    transition: all .3s;
}

.panel.on {
    background: rgba(232, 201, 138, .22);
}

.panel.on.py {
    border-color: var(--yellow);
    box-shadow: 0 0 14px rgba(249, 168, 37, .4);
}

.panel.on.pg {
    border-color: var(--green);
    box-shadow: 0 0 14px rgba(46, 125, 50, .4);
}

.panel.on.pr {
    border-color: var(--red);
    box-shadow: 0 0 14px rgba(211, 47, 47, .4);
}

.panel.on.pb {
    border-color: var(--blue);
    box-shadow: 0 0 14px rgba(21, 101, 192, .4);
}

.pname {
    font-family: 'Fredoka One', cursive;
    font-size: .95rem;
    color: #f5deb3;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
}

.dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .3);
}

.pips {
    display: flex;
    gap: 5px;
}

.pip {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 900;
    color: #fff;
}

#dice-box {
    background: rgba(232, 201, 138, .1);
    border: 2px solid rgba(232, 201, 138, .2);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* --- 3D DICE (Cube) --- */
.dice-container {
    perspective: 1000px;
    width: 80px;
    height: 80px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    margin: 5px 0;
}

.dice-container:active {
    transform: scale(0.9);
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s ease-out;
}

.face {
    position: absolute;
    width: 80px;
    height: 80px;
    background: #8e44ad;
    /* Changed from red to purple */
    border: 3px solid white;
    border-radius: 12px;
    color: white;
    font-size: 36px;
    font-family: 'Fredoka One', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
}

/* Faces positions */
.front {
    transform: translateZ(40px);
}

.back {
    transform: rotateY(180deg) translateZ(40px);
}

.right {
    transform: rotateY(90deg) translateZ(40px);
}

.left {
    transform: rotateY(-90deg) translateZ(40px);
}

.top {
    transform: rotateX(90deg) translateZ(40px);
}

.bottom {
    transform: rotateX(-90deg) translateZ(40px);
}

#msg {
    font-size: .82rem;
    color: #f5deb3;
    text-align: center;
    min-height: 30px;
    font-weight: 700;
    line-height: 1.4;
}

#roll-hint {
    font-size: 2.2rem;
    text-align: center;
    margin-top: 5px;
    opacity: 1;
    pointer-events: none;
    transition: opacity 0.3s;
    animation: hotSpotBounce 0.6s infinite alternate cubic-bezier(0.25, 0.46, 0.45, 0.94);
    filter: drop-shadow(0px 5px 8px rgba(142, 68, 173, 0.6));
}

#roll-hint.hidden {
    opacity: 0;
}

@keyframes hotSpotBounce {
    0% {
        transform: translateY(12px) scale(0.9);
    }

    100% {
        transform: translateY(0px) scale(1.1);
        filter: drop-shadow(0px -5px 12px rgba(142, 68, 173, 0.9));
    }
}

#log {
    background: rgba(0, 0, 0, .25);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: .73rem;
    color: #d4a96a;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid rgba(232, 201, 138, .15);
    line-height: 1.7;
}

.ly {
    color: #fff176;
}

.lg {
    color: #a5d6a7;
}

.lr {
    color: #ef9a9a;
}

.lb {
    color: #90caf9;
}

/* WIN */
#win-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .78);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

#win-overlay.show {
    display: flex;
}

#win-box {
    background: #e8c98a;
    border-radius: 22px;
    padding: 36px 54px;
    text-align: center;
    box-shadow: 0 0 0 4px #b8894a, 0 30px 80px rgba(0, 0, 0, .6);
    animation: pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes pop {
    from {
        transform: scale(.5);
        opacity: 0
    }

    to {
        transform: scale(1);
        opacity: 1
    }
}

#win-box h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #3b1a00;
    margin-bottom: 8px;
}

#win-box p {
    color: #6b3a1f;
    margin-bottom: 16px;
}

#rbtn {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    padding: 10px 30px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #d32f2f, #7f0000);
    color: #fff;
    box-shadow: 0 4px 14px rgba(211, 47, 47, .4);
}

#rbtn:hover {
    transform: scale(1.05);
}

/* ════════════ QUESTION MODAL ════════════ */
#question-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

#question-overlay.show {
    opacity: 1;
    pointer-events: all;
}

#question-box {
    background: #fff;
    color: #333;
    padding: min(4vh, 40px) min(4vw, 40px);
    border-radius: 20px;
    max-width: 500px;
    width: 95%;
    max-height: 95vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 5px solid transparent;
    transition: border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#question-box.p-yellow {
    border-color: var(--yellow);
}

#question-box.p-blue {
    border-color: var(--blue);
}

#question-box.p-green {
    border-color: var(--green);
}

#question-box.p-red {
    border-color: var(--red);
}

#q-header {
    margin-bottom: min(2vh, 20px);
    color: #1e3c72;
    font-size: clamp(1.2rem, 3.5vh, 1.8rem);
    font-family: 'Fredoka One', cursive;
}

#q-content {
    font-size: clamp(1rem, 3vh, 1.25rem);
    color: #333;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.q-options {
    display: flex;
    flex-direction: column;
    gap: min(1.5vh, 15px);
}

.q-opt-btn {
    background: #f1f1f1;
    color: #333;
    box-shadow: none;
    border: 2px solid transparent;
    padding: 10px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.q-opt-btn:hover {
    background: #e1e1e1;
    border-color: #2eace1;
}

.q-opt-btn.correct {
    background: #8bc53f !important;
    color: #fff !important;
}

.q-opt-btn.wrong {
    background: #ec1e79 !important;
    color: #fff !important;
}

.q-input {
    padding: 10px;
    font-size: 1.2rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    outline: none;
    text-align: center;
    width: 100%;
}

.q-input:focus {
    border-color: #2eace1;
}

.q-audio-player {
    width: 100%;
    margin-bottom: min(1vh, 5px);
    height: min(5vh, 40px);
    outline: none;
}

.q-subtext {
    font-size: clamp(1rem, 3vh, 1.25rem);
    font-weight: 700;
    color: #333;
    margin-bottom: min(1.5vh, 15px);
}

.q-speaking-img {
    width: 100%;
    max-height: min(25vh, 200px);
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: min(1.5vh, 15px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.submit-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: min(1.5vh, 12px);
    border-radius: 8px;
    font-size: clamp(1rem, 3vh, 1.2rem);
    cursor: pointer;
    font-weight: bold;
    margin-top: min(1vh, 5px);
    transition: background 0.2s;
}

.submit-btn:hover:not(:disabled) {
    background: #219653;
}

.audio-btn,
.mic-btn {
    background: #e67e22;
    border: none;
    padding: 15px;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
    width: 60px;
    height: 60px;
    line-height: 1;
    margin: 0 auto;
}

.mic-btn.recording {
    background: #e74c3c;
    animation: woodglow 1s infinite alternate;
}

.audio-btn:hover,
.mic-btn:hover {
    transform: scale(1.1);
}

.emoji-img {
    font-size: 4rem;
}

#q-feedback {
    margin-top: min(1.5vh, 20px);
    font-weight: bold;
    font-size: clamp(1.1rem, 3.5vh, 1.5rem);
    min-height: min(3.5vh, 28px);
    white-space: pre-line;
    line-height: 1.3;
}

/* Question Path Node */
.qnode {
    background: rgba(155, 89, 182, 0.4);
    box-shadow: inset 0 0 5px rgba(155, 89, 182, 0.8);
    border-radius: 50%;
}

.qnode::after {
    content: '?';
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 900;
    color: #8e44ad;
    font-family: 'Fredoka One', cursive;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

/* Modal Styling */
.modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #fff;
    color: #333;
    padding: min(4vh, 40px) min(4vw, 40px);
    border-radius: 20px;
    max-width: 500px;
    width: 95%;
    max-height: 95vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 5px solid transparent;
    transition: border-color 0.3s ease;
}

.modal-content h2 {
    margin-bottom: min(2vh, 20px);
    color: #1e3c72;
    font-size: clamp(1.2rem, 3.5vh, 1.8rem);
}

/* ════════════ RESPONSIVENESS ════════════ */
#game-container.portrait #game-area {
    flex-direction: column;
    align-items: center;
}

#game-container.portrait #sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 550px;
}

#game-container.portrait .panel {
    flex: 1 1 40%;
    min-width: 130px;
    padding: 8px 10px;
}

#game-container.portrait #dice-box {
    width: 100%;
    flex: 1 1 100%;
    margin-top: 10px;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
}

#game-container.portrait #msg {
    flex: 1;
    font-size: 1.1rem;
}