/* The Room - Main Stylesheet */

/* General */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Login Page */
.card {
    border-radius: 15px;
    overflow: hidden;
}

.card-header {
    border-bottom: none;
}

.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* PIN input styling */
#pin {
    letter-spacing: 8px;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Dashboard */
.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
}

.card.bg-secondary {
    background-color: #2d3238 !important;
    border: 1px solid #3d4248;
}

.table-dark {
    --bs-table-bg: transparent;
}

/* Room code styling */
code {
    font-size: 1.1em;
    letter-spacing: 2px;
}

/* ==================== */
/* TURN INDICATOR       */
/* ==================== */

.turn-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 25px;
    margin: 0 auto 20px auto;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    max-width: 500px;
    transition: all 0.5s ease;
}

.turn-indicator.waiting {
    background: linear-gradient(135deg, #2d3238 0%, #1a1a2e 100%);
    border: 2px solid #4a4a6a;
    color: #888;
}

.turn-indicator.my-turn {
    background: linear-gradient(135deg, #155724 0%, #1e7e34 100%);
    border: 2px solid #28a745;
    color: #fff;
    box-shadow: 0 0 30px rgba(40, 167, 69, 0.5), 0 0 60px rgba(40, 167, 69, 0.3);
    animation: turnPulse 1.5s infinite;
}

.turn-light {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 15px;
    transition: all 0.5s ease;
}

.turn-indicator.waiting .turn-light {
    background-color: #555;
    box-shadow: none;
}

.turn-indicator.my-turn .turn-light {
    background-color: #28a745;
    box-shadow: 0 0 15px #28a745, 0 0 30px #28a745;
    animation: lightPulse 1s infinite;
}

@keyframes turnPulse {
    0% { box-shadow: 0 0 30px rgba(40, 167, 69, 0.5), 0 0 60px rgba(40, 167, 69, 0.3); }
    50% { box-shadow: 0 0 40px rgba(40, 167, 69, 0.7), 0 0 80px rgba(40, 167, 69, 0.4); }
    100% { box-shadow: 0 0 30px rgba(40, 167, 69, 0.5), 0 0 60px rgba(40, 167, 69, 0.3); }
}

@keyframes lightPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==================== */
/* VICTORY SCREEN       */
/* ==================== */

.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.victory-content {
    text-align: center;
    padding: 40px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.victory-icon {
    font-size: 100px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.victory-title {
    font-size: 60px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ffa500, 0 0 60px #ff8c00;
    margin: 20px 0;
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 20px #ffd700, 0 0 40px #ffa500, 0 0 60px #ff8c00; }
    50% { text-shadow: 0 0 30px #ffd700, 0 0 60px #ffa500, 0 0 90px #ff8c00; }
}

.victory-message {
    font-size: 24px;
    color: #fff;
    margin-bottom: 30px;
}

.victory-runes {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}

.victory-rune {
    font-size: 40px;
    color: #ffd700;
    background: #2a2a4a;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    box-shadow: 0 0 20px #ffd700;
    animation: runeFloat 2s infinite ease-in-out;
}

.victory-rune:nth-child(1) { animation-delay: 0s; }
.victory-rune:nth-child(2) { animation-delay: 0.2s; }
.victory-rune:nth-child(3) { animation-delay: 0.4s; }
.victory-rune:nth-child(4) { animation-delay: 0.6s; }

@keyframes runeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Player list active turn highlight */
.player-list li.active-turn {
    background-color: #155724 !important;
    border-left: 3px solid #28a745;
}

/* ==================== */
/* GAME BOARD STYLES    */
/* ==================== */

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 500px;
}

.board-wrapper {
    position: relative;
    display: inline-block;
    padding: 60px; /* Spazio per le rune esterne */
}

/* Griglia 6x6 */
.game-board {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 3px;
    background-color: #1a1a2e;
    padding: 10px;
    border-radius: 10px;
    border: 3px solid #4a4a6a;
    box-shadow: 0 0 30px rgba(74, 74, 106, 0.5);
}

/* Celle della griglia */
.cell {
    width: 60px;
    height: 60px;
    background-color: #16213e;
    border: 1px solid #3a3a5a;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.cell:hover {
    background-color: #1f3460;
    transform: scale(1.05);
    z-index: 5;
}

/* ==================== */
/* RUNE STYLES          */
/* ==================== */

.runes-container {
    position: absolute;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

/* Rune NORD - sopra la griglia */
.runes-north {
    top: 5px;
    left: 60px;
    right: 60px;
    height: 50px;
    flex-direction: row;
}

/* Rune SUD - sotto la griglia */
.runes-south {
    bottom: 5px;
    left: 60px;
    right: 60px;
    height: 50px;
    flex-direction: row;
}

/* Rune OVEST - a sinistra della griglia */
.runes-west {
    left: 5px;
    top: 60px;
    bottom: 60px;
    width: 50px;
    flex-direction: column;
}

/* Rune EST - a destra della griglia */
.runes-east {
    right: 5px;
    top: 60px;
    bottom: 60px;
    width: 50px;
    flex-direction: column;
}

/* Singola runa */
.rune {
    width: 45px;
    height: 45px;
    background-color: #2a2a4a;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.5;
    color: #888;
}

.rune:hover {
    transform: scale(1.15);
    opacity: 0.8;
    border-color: #6a6a8a;
}

.rune.active {
    background-color: #ffd700;
    border-color: #ffaa00;
    box-shadow: 0 0 20px #ffd700, 0 0 40px #ffa500;
    opacity: 1;
    color: #333;
    animation: pulse 2s infinite;
}

.rune.active:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Rune vincenti - hint per il master (verde tenue quando spente) */
.rune.winning-hint:not(.active) {
    background-color: #1a4a2a;
    border-color: #2d6a3e;
    color: #4ade80;
    opacity: 0.7;
}

/* ==================== */
/* TOKEN STYLES         */
/* ==================== */

.token {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
    border: 2px solid rgba(255,255,255,0.3);
}

.token:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 6px 12px rgba(0,0,0,0.5), inset 0 -2px 4px rgba(0,0,0,0.3);
    z-index: 15;
}

/* Indicatore segnalini multipli sulla stessa casella */
.token-stack {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: #ff4444;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ==================== */
/* MASTER PANEL         */
/* ==================== */

.master-panel {
    background-color: #2d3238;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #3d4248;
}

.player-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.player-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background-color: #1a1a2e;
    border-radius: 5px;
    margin-bottom: 5px;
}

.player-list li:hover {
    background-color: #242438;
}

.player-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    border: 2px solid rgba(255,255,255,0.2);
}

/* Pannello segnalini sovrapposti */
.stacked-tokens-panel {
    position: absolute;
    background-color: #2d3238;
    border: 2px solid #4a4a6a;
    border-radius: 10px;
    padding: 10px;
    z-index: 1000;
    min-width: 150px;
}

.stacked-tokens-panel h6 {
    margin-bottom: 10px;
    color: #ffd700;
}

.stacked-token-item {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 5px;
    margin-bottom: 5px;
}

.stacked-token-item:hover {
    background-color: #3d4248;
}

/* ==================== */
/* ANIMATIONS           */
/* ==================== */

@keyframes pulse {
    0% { box-shadow: 0 0 20px #ffd700, 0 0 40px #ffa500; }
    50% { box-shadow: 0 0 30px #ffd700, 0 0 60px #ffa500, 0 0 80px #ff8c00; }
    100% { box-shadow: 0 0 20px #ffd700, 0 0 40px #ffa500; }
}

@keyframes tokenAppear {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.token {
    animation: tokenAppear 0.3s ease-out;
}

/* ==================== */
/* RESPONSIVE           */
/* ==================== */

@media (max-width: 768px) {
    .board-wrapper {
        padding: 50px;
    }
    
    .game-board {
        grid-template-columns: repeat(6, 48px);
        grid-template-rows: repeat(6, 48px);
        gap: 2px;
        padding: 8px;
    }
    
    .cell {
        width: 48px;
        height: 48px;
    }
    
    .token {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .rune {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    .runes-north,
    .runes-south {
        left: 50px;
        right: 50px;
        height: 45px;
    }
    
    .runes-west,
    .runes-east {
        top: 50px;
        bottom: 50px;
        width: 45px;
    }
}

@media (max-width: 480px) {
    .board-wrapper {
        padding: 45px;
    }
    
    .game-board {
        grid-template-columns: repeat(6, 40px);
        grid-template-rows: repeat(6, 40px);
        gap: 2px;
        padding: 6px;
    }
    
    .cell {
        width: 40px;
        height: 40px;
    }
    
    .token {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .rune {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .runes-north,
    .runes-south {
        left: 45px;
        right: 45px;
        height: 40px;
    }
    
    .runes-west,
    .runes-east {
        top: 45px;
        bottom: 45px;
        width: 40px;
    }
}
