:root {
    --primary: #ff9a9e;
    --secondary: #fecfef;
    --bg-gradient: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-dark: #4a4a4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Jua', sans-serif;
    background: url('assets/bg.png') center/cover no-repeat;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-dark);
    overflow: hidden;
}

/* 시작 화면 */
#start-screen {
    position: absolute; z-index: 200;
    display: flex; flex-direction: column; gap: 1.5rem;
    align-items: center; justify-content: center;
    padding: 3rem; text-align: center;
    background: rgba(255, 255, 255, 0.85);
    min-width: 400px;
}
#start-screen.hidden, .game-container.hidden { display: none !important; }

.form-group { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; text-align: left; }
.form-group label { font-size: 1.2rem; font-weight: bold; }
.form-group input, .form-group select { 
    padding: 0.8rem; font-family: 'Jua'; font-size: 1.1rem; 
    border-radius: 8px; border: 2px solid var(--primary); outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: #d9787c; }

.game-container {
    width: 95vw; max-width: 1000px; height: 95vh;
    display: flex; flex-direction: column; gap: 1rem; position: relative;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
    padding: 1rem;
}

/* Header */
header { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
h1 { font-size: 2.5rem; color: #fff; text-shadow: 2px 2px 4px rgba(0,0,0,0.2); }
.players-info { display: flex; gap: 1.5rem; width: 100%; justify-content: center; flex-wrap: wrap; }
.player-card {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.3); border-radius: 16px; transition: transform 0.3s;
}
.player-card.active { transform: scale(1.15); box-shadow: 0 0 15px rgba(255,255,255,0.8); border: 2px solid #fff; z-index: 5; }
.avatar { font-size: 2rem; }
.info h3 { font-size: 1.1rem; margin:0; }
.info p { margin:0; font-size: 1rem; }

/* Main Board Area */
main { flex: 1; position: relative; display: flex; justify-content: center; align-items: center; }

.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 10px; width: 100%; max-width: 700px; aspect-ratio: 1;
}

.tile {
    background: rgba(255,255,255,0.7); border-radius: 16px; border: 3px solid #fff;
    display: flex; flex-direction: column; justify-content: space-between; align-items: center;
    position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center; font-size: 0.9rem; padding: 5px; transition: transform 0.2s;
}
.tile:hover { transform: scale(1.05); z-index: 5; background: rgba(255,255,255,0.9); }
.tile-name { font-weight: bold; margin-bottom: 2px; }
.tile-icon { font-size: 1.5rem; display:flex; justify-content:center; align-items:center; flex:1; }
.tile-owner { font-size: 0.8rem; color: #888; margin-top: 2px; }

/* Position mapping for 5x5 perimeter (0~15) */
.tile[data-index="0"] { grid-area: 5 / 5; border-color: #ffd700; background: #fffcf0; }
.tile[data-index="1"] { grid-area: 5 / 4; }
.tile[data-index="2"] { grid-area: 5 / 3; }
.tile[data-index="3"] { grid-area: 5 / 2; }
.tile[data-index="4"] { grid-area: 5 / 1; border-color: #87ceeb; background: #f0f8ff; }
.tile[data-index="5"] { grid-area: 4 / 1; }
.tile[data-index="6"] { grid-area: 3 / 1; }
.tile[data-index="7"] { grid-area: 2 / 1; }
.tile[data-index="8"] { grid-area: 1 / 1; border-color: #ff69b4; background: #fff0f5; }
.tile[data-index="9"] { grid-area: 1 / 2; }
.tile[data-index="10"] { grid-area: 1 / 3; }
.tile[data-index="11"] { grid-area: 1 / 4; }
.tile[data-index="12"] { grid-area: 1 / 5; border-color: #dda0dd; background: #f8f0ff; }
.tile[data-index="13"] { grid-area: 2 / 5; }
.tile[data-index="14"] { grid-area: 3 / 5; }
.tile[data-index="15"] { grid-area: 4 / 5; }

.center-ui {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 60%; height: 60%; display: flex; justify-content: center; align-items: center; pointer-events: none;
}

#dice-container {
    pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 1rem;
    padding: 2rem; text-align: center; min-width: 200px;
}

/* 3D Dice Styles */
.scene { width: 80px; height: 80px; perspective: 400px; margin: 10px auto 20px auto; }
.cube { 
    width: 100%; height: 100%; position: relative; 
    transform-style: preserve-3d; transform: translateZ(-40px) rotateX(-15deg) rotateY(15deg); 
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}
.cube__face { 
    position: absolute; width: 80px; height: 80px; 
    border: 2px solid #ff9a9e; background: rgba(255, 255, 255, 0.95); 
    font-size: 3.5rem; display: flex; justify-content: center; align-items: center; 
    box-shadow: inset 0 0 15px rgba(255,154,158,0.3); border-radius: 12px; color: #ff9a9e;
    line-height: 1;
}
.cube__face--1 { transform: rotateY(  0deg) translateZ(40px); }
.cube__face--2 { transform: rotateY( 90deg) translateZ(40px); }
.cube__face--3 { transform: rotateY(180deg) translateZ(40px); }
.cube__face--4 { transform: rotateY(-90deg) translateZ(40px); }
.cube__face--5 { transform: rotateX( 90deg) translateZ(40px); }
.cube__face--6 { transform: rotateX(-90deg) translateZ(40px); }

.jelly-btn {
    background: var(--primary); color: white; border: none; padding: 12px 24px;
    font-size: 1.2rem; font-family: inherit; border-radius: 20px; cursor: pointer;
    box-shadow: 0 4px 0 #d9787c; transition: all 0.1s; white-space: nowrap;
}
.jelly-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #d9787c; }
.jelly-btn.secondary { background: #ccc; box-shadow: 0 4px 0 #999; color: #333; }
.jelly-btn.secondary:active { transform: translateY(4px); box-shadow: 0 0 0 #999; }

.btn-group { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }

/* Player Pieces */
.piece { 
    position: absolute; font-size: 2rem; 
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), margin-top 0.15s ease-out, transform 0.15s ease-out; 
    z-index: 10; width: 40px; height: 40px; display: flex; justify-content: center; align-items: center; pointer-events: none;
}
.piece.jump { margin-top: -20px; transform: scale(1.2); }

/* Popup & Toast */
#popup-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.3); display: flex; justify-content: center; align-items: center; z-index: 100; backdrop-filter: blur(5px); }
#popup-overlay.hidden { display: none; }
.popup { text-align: center; padding: 2.5rem; min-width: 320px; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.popup h2 { font-size: 2rem; color: var(--primary); margin:0; }
.popup p { font-size: 1.2rem; margin:0; }

.toast {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.75); color: #fff; padding: 1rem 2rem;
    border-radius: 30px; font-size: 1.2rem; z-index: 150;
    transition: opacity 0.3s; pointer-events: none;
}
.toast.hidden { opacity: 0; }
