/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a url('../images/background.png') no-repeat center center fixed;
    background-size: cover;
    color: #eee;
    height: 100vh;
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow-y: auto;
}

/* Screens */
.screen {
    display: none;
    width: 100%;
    min-height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.screen.active { display: flex; }

/* Menu */
#menu-screen h1 {
    font-size: 5rem;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.8), 2px 2px 4px black;
    margin-bottom: 50px;
    font-weight: 900;
}
.menu-buttons button {
    display: block;
    width: 320px;
    padding: 18px;
    margin: 12px 0;
    font-size: 1.3rem;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.7);
    color: #ff4444;
    border: 2px solid #ff4444;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    backdrop-filter: blur(5px);
}
.menu-buttons button:hover {
    background: #ff4444;
    color: white;
    box-shadow: 0 0 20px #ff4444;
    transform: scale(1.05);
}

/* Game Container */
#game-container {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 20px;
    gap: 20px;
    background: rgba(0, 0, 0, 0.4);
}

/* Board Area */
#board-container {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 10px;
}
#game-board {
    position: relative;
    width: 100%;
    max-width: 85vh; 
    aspect-ratio: 1 / 1;
    background: none; 
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    transition: transform 1s ease; /* Smooth rotation */
}
.board-bg {
    width: 100%;
    height: 100%;
    object-fit: fill; 
    border-radius: 5px;
    display: block;
}

/* Home Highlights */
.home-highlight {
    position: absolute;
    width: 40%;
    height: 40%;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 5;
    box-shadow: inset 0 0 50px 20px currentColor;
    border: 5px solid currentColor;
}
.home-highlight.red { bottom: 2%; left: 2%; color: #ff4444; }
.home-highlight.blue { top: 2%; left: 2%; color: #4444ff; }
.home-highlight.green { top: 2%; right: 2%; color: #44ff44; }
.home-highlight.yellow { bottom: 2%; right: 2%; color: #ffff44; }

.home-highlight.active {
    opacity: 1;
    animation: homePulse 1.5s infinite alternate;
}
@keyframes homePulse {
    from { box-shadow: inset 0 0 30px 10px currentColor; opacity: 0.6; }
    to { box-shadow: inset 0 0 60px 30px currentColor; opacity: 1; }
}

/* Pawns */
.pawn {
    position: absolute;
    width: 6.2%; /* Increased size */
    height: 6.2%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: default; /* Default no cursor */
    transition: left 0.3s ease, top 0.3s ease;
    z-index: 50;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5));
}
.pawn.turn-owner {
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.65)) brightness(1.12);
}
.pawn.playable {
    /* IMPORTANT: do NOT animate transform here (it conflicts with JS counter-rotation/positioning) */
    filter: drop-shadow(0 0 6px gold) brightness(1.25);
    animation: playablePulse 1s infinite alternate;
    cursor: pointer;
    z-index: 100;
}
@keyframes playablePulse {
    from { filter: drop-shadow(0 0 3px gold) brightness(1.15); }
    to { filter: drop-shadow(0 0 10px gold) brightness(1.35); }
}

/* Board Rotation Classes */
#game-board.rotate-0 { transform: rotate(0deg); }
#game-board.rotate-90 { transform: rotate(90deg); }
#game-board.rotate-180 { transform: rotate(180deg); }
#game-board.rotate-270 { transform: rotate(270deg); }

/* Counter-rotate pawns logic moved to JS to avoid conflicts with inline styles */


/* Info Panel */
#info-panel {
    flex: 1;
    max-width: 350px;
    background: rgba(0,0,0,0.85);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid #444;
    gap: 15px;
}

#turn-indicator {
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    color: #ccc;
    background: rgba(255,255,255,0.05);
    border: 1px solid #444;
    transition: all 0.3s;
}
#turn-indicator.active-turn {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: white;
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
}
#turn-indicator.yours {
    background: rgba(0, 255, 0, 0.2);
    border-color: #44ff44;
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.3);
}
#turn-indicator.others.red { border-left: 5px solid #ff4444; }
#turn-indicator.others.blue { border-left: 5px solid #4444ff; }
#turn-indicator.others.green { border-left: 5px solid #44ff44; }
#turn-indicator.others.yellow { border-left: 5px solid #ffff44; }

#dice-container {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    cursor: pointer;
    background: white;
    border-radius: 15px;
    padding: 5px;
    box-shadow: 0 0 15px rgba(255,255,255,0.2);
    transition: transform 0.2s, opacity 0.3s;
    position: relative;
    z-index: 100;
}
#dice-container:active { transform: scale(0.95); }
#dice-container.pulse { animation: pulse 1.5s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

#dice-img { width: 100%; height: 100%; object-fit: contain; }
.rolling { animation: roll 0.6s ease-in-out infinite; }
@keyframes roll {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(1); }
    75% { transform: rotate(270deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

#players-info {
    flex: 1;
    overflow-y: auto;
}
.player-card {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    border-left: 5px solid #ccc;
    transition: all 0.3s;
}
.player-card.red { border-left-color: #ff4444; }
.player-card.green { border-left-color: #44ff44; }
.player-card.yellow { border-left-color: #ffff44; }
.player-card.blue { border-left-color: #4444ff; }
.player-card.active { 
    background: rgba(255,255,255,0.2); 
    border: 1px solid white; 
    transform: scale(1.02);
}

.player-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    background: #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Chat */
#chat-container {
    flex: 1;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 200px;
    border: 1px solid #444;
}
#chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 0.9rem;
}
.chat-msg { margin-bottom: 5px; padding: 5px; border-radius: 5px; background: rgba(255,255,255,0.05); }
.chat-msg.mine { background: rgba(100, 200, 255, 0.1); text-align: right; }
.chat-msg .sender { font-weight: bold; color: #aaa; font-size: 0.8rem; }

#chat-input-area {
    display: flex;
    padding: 5px;
    background: rgba(0,0,0,0.8);
}
#chat-input { flex: 1; padding: 8px; border-radius: 5px; border: none; background: #333; color: white; }
#chat-input-area button { padding: 0 15px; margin-left: 5px; background: #ff4444; color: white; border: none; border-radius: 5px; cursor: pointer; }

/* Message Area */
#message-area {
    min-height: 20px;
    text-align: center;
    color: #ffaa00;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    transition: opacity 0.5s;
    opacity: 0;
}

/* Big Start Button */
#btn-start-game {
    width: 100%;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
    transition: all 0.3s;
}
#btn-start-game:hover {
    background: #218838;
    transform: scale(1.05);
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal.active { display: flex; }
.modal-content {
    background: #222;
    padding: 30px;
    border-radius: 15px;
    width: 400px;
    text-align: center;
    border: 2px solid #ff4444;
}
.modal-content input { width: 100%; padding: 10px; margin: 15px 0; background: #333; border: 1px solid #555; color: white; border-radius: 5px; text-align: center; font-size: 1.1rem; }
.color-select {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}
.color-opt { width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; opacity: 0.6; }
.color-opt.selected { opacity: 1; border-color: white; transform: scale(1.2); }
.color-opt.red { background: #ff4444; }
.color-opt.green { background: #44ff44; }
.color-opt.yellow { background: #ffff44; }
.color-opt.blue { background: #4444ff; }

.modal-buttons button { padding: 10px 20px; margin: 5px; border-radius: 5px; border: none; cursor: pointer; font-weight: bold; }
.modal-buttons button:first-child { background: #ff4444; color: white; }
.modal-buttons button:last-child { background: #444; color: white; }

#game-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #444;
    padding: 5px;
    border-radius: 5px;
}
.game-item { padding: 10px; border-bottom: 1px solid #333; cursor: pointer; display: flex; justify-content: space-between; }
.game-item:hover { background: rgba(255,255,255,0.1); }

@media (max-width: 768px) {
    #game-container { flex-direction: column; }
    #info-panel { width: 100%; max-width: none; }
    #chat-container { min-height: 150px; }
}
