:root {
    /* --- CONFIGURATION ANIMATION --- */
    --flip-duration: 1.2s;
    /* MODIFY HERE to change flip speed */
}

body {
    background-color: #222 !important;
    /* Force color */
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    padding: 15px;
    box-sizing: border-box;
    gap: 10px;

    /* Standard Cursor */
    cursor: default;
}

/* Standard Pointer for interactive elements */
button,
label,
.cell,
input,
.btn-challenge {
    cursor: pointer;
}

h1 {
    margin: 0;
    font-size: 1.5em;
    text-transform: uppercase;
    letter-spacing: 2px;
    flex-shrink: 0;
    color: #eee;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-bottom: 5px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 8px;
    justify-content: center;
}

.control-row {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

label {
    color: #ccc;
    font-size: 0.9em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.modal-btn-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

#modal-btn-view {
    background-color: #555;
    margin-left: 0;
}

#modal-btn-view:active {
    background-color: #333;
}

.active-turn {
    border-bottom: 1px solid #e6b800;
    padding-bottom: 4px;
    transition: border-color 0.3s;
}

#score-board {
    display: flex;
    gap: 20px;
    font-size: 1em;
    font-weight: bold;
    background: #333;
    padding: 8px 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin: 0;
    flex-shrink: 0;
    border: 1px solid #444;
}

#status,
#game-status {
    font-size: 1.0em;
    color: #aaa;
    min-height: 1.2em;
    text-align: center;
    margin: 0;
    flex-shrink: 0;
}

/* --- SCACCHIERA --- */
#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    background-color: #111;
    border: 6px solid #3d3d3d;
    border-radius: 4px;
    aspect-ratio: 1 / 1;
    width: min(90vw, 55vh);
    max-width: 600px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
}

.cell {
    background-color: #2e8b57;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    perspective: 800px;
    /* Enable 3D space */
}

.disc {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: absolute;
    /* Needed for transform */
    transform-style: preserve-3d;
    /* Enable 3D children */
    transition: transform var(--flip-duration) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Custom ease with bounce */
    box-shadow: none;
    /* Shadow moves to faces or handled differently? Let's put shadow on faces */
    z-index: 2;
}

/* Rotation States */
.disc.black {
    transform: rotateY(0deg);
}

.disc.white {
    transform: rotateY(180deg);
}

/* Faces */
.face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
}

.face.front {
    background: radial-gradient(circle at 35% 35%, #666, #000);
    transform: rotateY(0deg);
    /* Front is Black */
}

.face.back {
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #d0d0d0 50%, #999999 100%);
    transform: rotateY(180deg);
    /* Back is White */
}

.hint {
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: #333;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
    border: 1px solid #555;
    width: 80%;
    max-width: 350px;
}

.modal-content h2 {
    margin-top: 0;
    color: #fff;
    font-size: 1.6em;
}

.modal-content p {
    font-size: 1.1em;
    color: #ccc;
    margin: 15px 0;
    line-height: 1.5;
}

.btn-restart {
    background-color: #2e8b57;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.2s;
}

.btn-restart:active {
    background-color: #1e5f3b;
}

.hidden {
    display: none !important;
}