/* General Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    text-align: center;
    margin: 0;
    padding: clamp(8px, 1.1vw, 16px) clamp(10px, 1.4vw, 24px) clamp(12px, 1.4vw, 24px);
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

h1 {
    color: #5a5a5a;
    font-size: clamp(1.45rem, 2.6vw, 3.25rem);
    margin: 0 0 clamp(5px, 0.8vh, 10px);
}

.top-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(6px, 0.8vw, 10px);
    margin-bottom: clamp(4px, 0.8vh, 10px);
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(8px, 1vw, 20px);
    margin: clamp(6px, 1vh, 14px) auto 0;
    max-width: min(1760px, 98vw);
    width: 100%;
}

.score-container {
    width: clamp(52px, 5.4vw, 120px);
    font-size: clamp(2.1rem, 4.5vw, 5.75rem);
    font-weight: bold;
    padding: 0 clamp(4px, 0.7vw, 12px);
    line-height: 1;
}

#red-score { color: #d9534f; }
#blue-score { color: #5bc0de; }

/* Board Styles */
#board, #spymaster-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(6px, 0.8vw, 18px);
    margin: 0 auto;
    max-width: min(1480px, calc(100vw - 140px));
    padding: clamp(7px, 0.9vw, 22px);
    background-color: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    flex-grow: 1;
    width: 100%;
}

/* --- Card Flip Animation Styles --- */
.card {
    background-color: transparent;
    min-height: clamp(68px, 10vh, 165px);
    border: none;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.revealed .card-inner {
    transform: rotateY(180deg);
    cursor: default;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: clamp(0.78rem, 1.18vw, 1.85rem);
    font-weight: bold;
    line-height: 1.12;
    text-transform: uppercase;
    word-break: break-word;
    padding: clamp(4px, 0.6vw, 8px);
}

.card-front {
    background-color: #f0e6d2;
    border: 1px solid #c8aa6e;
    color: #333;
}

.card:hover .card-front {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.card-back {
    color: white;
    transform: rotateY(180deg);
}

/* Card Back Colors */
.card-back.red { background-color: #d9534f; border-color: #d43f3a; }
.card-back.blue { background-color: #5bc0de; border-color: #46b8da; }
.card-back.neutral { background-color: #bfa885; border-color: #a89270; }
.card-back.assassin { background-color: #333; border-color: #000; }
/* --- End Flip Animation Styles --- */


/* =================================================================== */
/* Spymaster Card Colors (Un-revealed) - THIS SECTION IS UPDATED       */
/* =================================================================== */
.card.red-spymaster .card-front {
    background-color: #f2dede; /* Light Red */
    border: 1px solid #ebccd1;
}
.card.blue-spymaster .card-front {
    background-color: #d9edf7; /* Light Blue */
    border: 1px solid #bce8f1;
}
.card.neutral-spymaster .card-front {
    background-color: #faf2e4; /* Light Beige */
    border: 1px solid #faebcc;
}
.card.assassin-spymaster .card-front {
    background-color: #777;    /* Gray */
    border: 1px solid #555;
    color: white;
}
.card.revealed-spymaster .card-inner {
    opacity: 0.4;
    cursor: default;
}
/* =================================================================== */
/* End of updated section                                              */
/* =================================================================== */


/* Modal Styles */
.modal {
    display: none; position: fixed; z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(0,0,0,0.6);
}
.modal-content {
    background-color: #fefefe; margin: 15% auto;
    padding: 20px; border: 1px solid #888;
    width: 90%; max-width: 500px;
    border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
}
.close-button {
    color: #aaa; float: right; font-size: 28px;
    font-weight: bold; position: absolute; top: 10px; right: 20px;
}
.close-button:hover, .close-button:focus {
    color: black; text-decoration: none; cursor: pointer;
}
.modal-content h2 { margin-top: 0; }
.modal-content input {
    width: calc(100% - 24px); padding: 12px;
    margin-bottom: 12px; border-radius: 5px;
    border: 1px solid #ccc;
}
#qr-canvas { display: block; margin: 20px auto; }
#spymaster-url { font-family: monospace; background: #eee; padding: 10px; border-radius: 5px; word-wrap: break-word; }

/* Style for the choice buttons */
.choice-button-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 20px;
    gap: 15px;
}
.choice-button-container button {
    width: 45%;
    padding: 15px 5px;
    font-size: 1em;
}


/* UI Elements */
#turn-display, #clue-display {
    font-size: clamp(1rem, 1.45vw, 2.25rem); margin: clamp(4px, 0.7vh, 8px) 0; font-weight: bold;
}
#clue-display { color: #0275d8; }
#clue-form input {
    padding: 10px; border-radius: 5px;
    border: 1px solid #ccc; margin: 0 5px;
}
button {
    padding: clamp(8px, 0.8vw, 12px) clamp(12px, 1.3vw, 24px); border-radius: 5px; border: none;
    background-color: #5bc0de; color: white;
    font-size: clamp(0.84rem, 0.9vw, 1rem); cursor: pointer;
    transition: background-color 0.2s; margin: 5px;
}
button:hover { background-color: #31b0d5; }
button:disabled { background-color: #ccc; cursor: not-allowed; }

#new-game, #play-again-button { background-color: #5cb85c; }
#new-game:hover, #play-again-button:hover { background-color: #4cae4c; }

#end-turn-button { background-color: #f0ad4e; }
#end-turn-button:hover { background-color: #ec971f; }

#red-spymaster-main { background-color: #d9534f; }
#red-spymaster-main:hover { background-color: #c9302c; }

/* Responsive Design */
@media (max-width: 768px) {
    body { padding: 10px; }
    #board, #spymaster-board { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-width: 100%; padding: 8px; }
    .card { min-height: clamp(54px, 16vw, 78px); }
    .card-front, .card-back { font-size: clamp(0.62rem, 2.5vw, 0.95rem); padding: 4px; }
    .game-container { flex-direction: column; align-items: center; }
    .score-container { width: auto; order: -1; margin-bottom: 8px; font-size: clamp(2rem, 10vw, 3.5rem); }
    #blue-score { order: -1; }
    #board, #spymaster-board { order: 0; }
}

@media (max-height: 820px) and (min-width: 769px) {
    #board, #spymaster-board { max-width: min(1280px, calc(100vw - 116px)); }
    .card { min-height: clamp(58px, 9.2vh, 118px); }
    .card-front, .card-back { font-size: clamp(0.7rem, 1vw, 1.35rem); }
}

@media (min-width: 1200px) and (max-height: 760px) {
    #board, #spymaster-board { max-width: min(1120px, calc(100vw - 104px)); }
    .card { min-height: clamp(52px, 8.6vh, 96px); }
}
@media (max-width: 480px) {
    body { padding: 10px; }
    #board, #spymaster-board { gap: 5px; padding: 6px; }
    .card { min-height: clamp(48px, 15vw, 64px); }
    h1 { font-size: 1.7em; }
    .choice-button-container { flex-direction: column; }
    .choice-button-container button { width: 100%; }
}
