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

:root {
    --bg-color: #fff4e6;
    --text-main: #5c4d4d;
    --text-muted: #9e8e8e;
    --primary: #ff9fb2;
    --primary-hover: #ff758f;
    --secondary: #a0c4ff;
    --board-bg: #ffffff;
    
    --point-color: #ffd6a5;
    --point-corner: #fdffb6;
    --point-center: #caffbf;
    --line-color: #ffc6ff;
    
    --p0-color: #ffadad;
    --p1-color: #ffd6a5;
    --p2-color: #caffbf;
    --p3-color: #a0c4ff;
    
    --font-family: 'Jua', sans-serif;
    --border-radius: 24px;
    --shadow: 0 8px 0 rgba(0,0,0,0.06);
    --border-thick: 4px solid #5c4d4d;
}

#yutnori-app {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: radial-gradient(#ffe0b2 20%, transparent 20%), radial-gradient(#ffe0b2 20%, transparent 20%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    color: var(--text-main);
}

#yutnori-app .screen {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    overflow-y: auto;
    padding: 1rem;
}

#yutnori-app .hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
}

/* Setup Screen */
#yutnori-app .setup-container {
    background: white;
    padding: 2rem;
    border-radius: 30px;
    border: var(--border-thick);
    box-shadow: 0 12px 0 #5c4d4d;
    text-align: center;
    max-width: 90%;
}

#yutnori-app .setup-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    text-shadow: 2px 2px 0 #5c4d4d;
    letter-spacing: 2px;
}

#yutnori-app .setup-container p {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

#yutnori-app .mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#yutnori-app button {
    font-family: var(--font-family);
    background: var(--secondary);
    color: #fff;
    border: 3px solid #5c4d4d;
    padding: 0.8rem 1.5rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 6px 0 #5c4d4d;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

#yutnori-app button:hover {
    background: #8baff0;
    transform: translateY(2px);
    box-shadow: 0 4px 0 #5c4d4d;
}

#yutnori-app button:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #5c4d4d;
}

/* Game Layout */
#yutnori-app .game-layout {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: auto;
    min-height: 100%;
    gap: 1rem;
    flex-direction: column;
}

@media (min-width: 1024px) {
    #yutnori-app .game-layout {
        flex-direction: row;
        gap: 2rem;
        height: 95%;
    }
}

#yutnori-app .side-panel {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (min-width: 1024px) {
    #yutnori-app .side-panel {
        flex: 1;
        flex-direction: column;
        gap: 1.5rem;
    }
}

#yutnori-app .player-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: var(--border-thick);
    box-shadow: 0 4px 0 #5c4d4d;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0.6;
    transform: scale(0.95);
    flex: 1;
    min-width: 140px;
}

@media (min-width: 1024px) {
    #yutnori-app .player-card {
        padding: 1.5rem;
        gap: 1.2rem;
        box-shadow: 0 6px 0 #5c4d4d;
    }
}

#yutnori-app .player-card.active {
    border-color: var(--primary);
    transform: scale(1.05) rotate(-2deg);
    opacity: 1;
    z-index: 10;
}

#yutnori-app .player-card img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid #5c4d4d;
    object-fit: cover;
    background: var(--bg-color);
}

@media (min-width: 1024px) {
    #yutnori-app .player-card img {
        width: 80px;
        height: 80px;
        border-radius: 20px;
        border: 3px solid #5c4d4d;
    }
}

#yutnori-app .player-card .info {
    flex: 1;
}

#yutnori-app .player-card h3 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

@media (min-width: 1024px) {
    #yutnori-app .player-card h3 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
}

#yutnori-app .pieces-container {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
}

#yutnori-app .piece-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #5c4d4d;
    background: #e9ecef;
}

@media (min-width: 1024px) {
    #yutnori-app .piece-indicator {
        width: 24px;
        height: 24px;
    }
}

#yutnori-app .piece-indicator.ready {
    background: var(--primary);
}

#yutnori-app .center-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
}

@media (min-width: 1024px) {
    #yutnori-app .center-panel {
        justify-content: center;
        gap: 1.5rem;
    }
}

#yutnori-app .board-container {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    border: var(--border-thick);
    box-shadow: 0 6px 0 #5c4d4d;
    width: 100%;
    max-width: 650px;
    aspect-ratio: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

@media (min-width: 1024px) {
    #yutnori-app .board-container {
        padding: 2.5rem;
        border-radius: 40px;
        box-shadow: 0 10px 0 #5c4d4d;
    }
}

#yutnori-app .board {
    position: relative;
    width: 100%;
    height: 100%;
}

#yutnori-app .board canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#yutnori-app .board-point {
    position: absolute;
    width: 6%;
    height: 6%;
    background: var(--point-color);
    border: 2px solid #5c4d4d;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    box-shadow: inset -2px -2px 0 rgba(0,0,0,0.1);
}

@media (min-width: 1024px) {
    #yutnori-app .board-point {
        width: 36px;
        height: 36px;
        border: 3px solid #5c4d4d;
        box-shadow: inset -4px -4px 0 rgba(0,0,0,0.1);
    }
}

#yutnori-app .board-point.corner {
    background: var(--point-corner);
    width: 8%;
    height: 8%;
}

@media (min-width: 1024px) {
    #yutnori-app .board-point.corner {
        width: 48px;
        height: 48px;
    }
}

#yutnori-app .board-point.center {
    background: var(--point-center);
    width: 9%;
    height: 9%;
}

@media (min-width: 1024px) {
    #yutnori-app .board-point.center {
        width: 52px;
        height: 52px;
    }
}

#yutnori-app .game-piece {
    position: absolute;
    width: 8%;
    height: 8%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #5c4d4d;
    box-shadow: 0 2px 0 #5c4d4d;
    cursor: pointer;
    background-size: cover;
    background-position: center;
}

@media (min-width: 1024px) {
    #yutnori-app .game-piece {
        width: 50px;
        height: 50px;
        border: 3px solid #5c4d4d;
        box-shadow: 0 4px 0 #5c4d4d;
    }
}

#yutnori-app .game-piece:hover {
    transform: translate(-50%, -50%) scale(1.15) rotate(5deg);
    z-index: 11;
}

#yutnori-app .game-piece .stack-count {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #ff5c8a;
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #5c4d4d;
    font-family: var(--font-family);
}

@media (min-width: 1024px) {
    #yutnori-app .game-piece .stack-count {
        bottom: -8px;
        right: -8px;
        font-size: 1rem;
        width: 26px;
        height: 26px;
        border: 2px solid #5c4d4d;
    }
}

#yutnori-app .yut-area {
    margin-top: auto;
    text-align: center;
    padding: 1rem;
    background: #fff0f3;
    border-radius: 20px;
    border: 3px solid #5c4d4d;
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: 80%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

@media (min-width: 1024px) {
    #yutnori-app .yut-area {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        width: auto;
        padding: 1.5rem;
        border-radius: 24px;
        box-shadow: none;
    }
}

#yutnori-app .yut-result {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    min-height: 2rem;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

@media (min-width: 1024px) {
    #yutnori-app .yut-result {
        font-size: 2rem;
        margin-bottom: 1rem;
        min-height: 2.5rem;
    }
}

#yutnori-app .yut-sticks {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0.5rem;
    perspective: 1000px;
}

@media (min-width: 1024px) {
    #yutnori-app .yut-sticks {
        gap: 15px;
        margin-bottom: 1rem;
    }
}

#yutnori-app .stick {
    width: 24px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 1024px) {
    #yutnori-app .stick {
        width: 36px;
        height: 110px;
    }
}

#yutnori-app .stick .front, #yutnori-app .stick .back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    border: 2px solid #5c4d4d;
    backface-visibility: hidden;
}

@media (min-width: 1024px) {
    #yutnori-app .stick .front, #yutnori-app .stick .back {
        border: 3px solid #5c4d4d;
    }
}

/* Front is flat side */
#yutnori-app .stick .front {
    background: #ffe3a8;
    display: flex;
    justify-content: center;
    align-items: center;
}

#yutnori-app .stick .front::after {
    content: '✖';
    color: #ff9f1c;
    font-size: 16px;
    opacity: 0.6;
}

@media (min-width: 1024px) {
    #yutnori-app .stick .front::after {
        font-size: 24px;
    }
}

/* Back is round side */
#yutnori-app .stick .back {
    background: #ffb703;
    transform: rotateY(180deg);
    box-shadow: inset -3px 0 0 rgba(0,0,0,0.1);
}

@media (min-width: 1024px) {
    #yutnori-app .stick .back {
        box-shadow: inset -5px 0 0 rgba(0,0,0,0.1);
    }
}

#yutnori-app .stick.flip {
    transform: rotateY(180deg);
}

#yutnori-app .throw-btn {
    margin-top: 5px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

@media (min-width: 1024px) {
    #yutnori-app .throw-btn {
        margin-top: 10px;
        padding: 1rem 2rem;
        font-size: 1.5rem;
    }
}

#yutnori-app .turn-indicator {
    font-size: 1.2rem;
    background: white;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    border: var(--border-thick);
    box-shadow: 0 4px 0 #5c4d4d;
    color: var(--primary);
    margin-top: 1rem;
}

@media (min-width: 1024px) {
    #yutnori-app .turn-indicator {
        font-size: 2rem;
        padding: 1rem 3rem;
        box-shadow: 0 6px 0 #5c4d4d;
        margin-top: 0;
    }
}

#yutnori-app .throw-results {
    display: flex;
    gap: 0.5rem;
    min-height: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

@media (min-width: 1024px) {
    #yutnori-app .throw-results {
        gap: 0.8rem;
        min-height: 50px;
    }
}

#yutnori-app .throw-badge {
    background: var(--primary);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 1.2rem;
    border: 2px solid #5c4d4d;
    cursor: pointer;
    box-shadow: 0 2px 0 #5c4d4d;
    transition: transform 0.1s, box-shadow 0.1s;
}

@media (min-width: 1024px) {
    #yutnori-app .throw-badge {
        padding: 0.5rem 1.2rem;
        border-radius: 30px;
        font-size: 1.5rem;
        border: 3px solid #5c4d4d;
        box-shadow: 0 4px 0 #5c4d4d;
    }
}

#yutnori-app .throw-badge:hover {
    background: var(--primary-hover);
    transform: translateY(2px);
    box-shadow: 0 1px 0 #5c4d4d;
}

#yutnori-app .modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 244, 230, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#yutnori-app .modal-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    border: var(--border-thick);
    text-align: center;
    box-shadow: 0 8px 0 #5c4d4d;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
}

@media (min-width: 1024px) {
    #yutnori-app .modal-content {
        padding: 4rem;
        border-radius: 40px;
        box-shadow: 0 15px 0 #5c4d4d;
    }
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#yutnori-app .modal-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

@media (min-width: 1024px) {
    #yutnori-app .modal-content h2 {
        font-size: 3.5rem;
        margin-bottom: 2rem;
        text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
    }
}

#yutnori-app .player-card[data-team="A"] { border-left-color: #ff9fb2; }
#yutnori-app .player-card[data-team="B"] { border-left-color: #a0c4ff; }
