/* ================================== */
/* ===         GLOBAL STYLES        === */
/* ================================== */

* { 
    box-sizing: border-box; 
}

:root {
    --font-color: #ddd;
    --background-color: #0d47a1; 
    --selection-glow-color: #FFD700;
    --alert-glow-color: #FF4136;
    --link-color: orange;
    --button-color: rgb(80, 29, 161);
    --tile-width: 52px;
    --tile-height: 70px;
    --tile-border-radius: 8px;
    --tile-thickness: 5px;
}

/* MODIFIED: Full-height Flexbox layout */
body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--font-color);
    margin: 0; 
    padding: 0; 
    height: 100vh; /* Full viewport height */
    display: flex;
    flex-direction: column;
    align-items: center;
}

button {
    border: none; 
    outline: none; 
    font-family: inherit; 
    font-size: inherit; 
    font-weight: inherit;
    color: var(--font-color); 
    background-color: var(--button-color); 
    padding: 5px 15px; 
    margin-left: 10px; 
    cursor: pointer;
}

button:hover { 
    background-color: rgb(113, 29, 161); 
}


/* ================================== */
/* ===      MAIN LAYOUT & GAME      === */
/* ================================== */

/* MODIFIED: Wrapper is now a flex container to manage vertical space */
#wrapper { 
    transform-origin: top; 
    width: 1000px; 
    display: flex;
    flex-direction: column;
    height: 100%; /* Take up the full height of the body */
}

header, footer { 
    position: relative; 
    text-align: center; 
    padding: 15px; 
    flex-shrink: 0; /* Prevent header/footer from shrinking */
}

#statusText { 
    float: left; 
}

#controls { 
    float: right; 
}

/* === THIS IS THE CORRECTED #game RULE === */
#game { 
    background-color: #2c3e50; 
    position: relative; 
    border-radius: 5px; 
    opacity: 0;
    flex: 1;           /* This makes the game area grow to fill available space */
    overflow: hidden;    /* Prevents scrollbars inside the game area */
    /* NOTE: The fixed 'height: 700px;' has been removed to fix the layout */
}

/* 3D TILE STYLES */
.tile {
    position: absolute;
    border-radius: var(--tile-border-radius);
    background-color: #F7F7F7;
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.4), inset 0 calc(-1 * var(--tile-thickness)) 0 #BDBDBD, inset 0 1px 1px #FFF, inset 0 -1px 1px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.15s ease-in-out;
}

.tile img { 
    display: block; 
    width: 100%; 
    height: 100%; 
    padding: 5px; 
    border-radius: var(--tile-border-radius); 
}

.selectedTile { 
    box-shadow: 0 0 12px 4px var(--selection-glow-color), 4px 4px 8px rgba(0, 0, 0, 0.4), inset 0 calc(-1 * var(--tile-thickness)) 0 #BDBDBD, inset 0 1px 1px #FFF, inset 0 -1px 1px rgba(0, 0, 0, 0.15); 
}

.alertTile { 
    box-shadow: 0 0 12px 4px var(--alert-glow-color), 4px 4px 8px rgba(0, 0, 0, 0.4), inset 0 calc(-1 * var(--tile-thickness)) 0 #BDBDBD, inset 0 1px 1px #FFF, inset 0 -1px 1px rgba(0, 0, 0, 0.15); 
}


/* ================================== */
/* ===         ALL OVERLAYS         === */
/* ================================== */

/* --- General Overlay Styles --- */
.overlay-hidden {
    display: none !important;
}

#infoOverlay, #winOverlay, #certificateOverlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* --- Info Overlay Specific Styles --- */
#infoOverlay {
    display: none; /* Controlled by .visible class from JS */
}
#infoOverlay.visible {
    display: flex;
}
#infoText {
    background-color: #2c3e50;
    padding: 30px;
    border-radius: 10px;
    max-width: 600px;
    position: relative;
    text-align: left;
}
#infoText h3 { color: var(--selection-glow-color); }
#infoText ul { padding-left: 20px; }
#infoText li { margin-bottom: 10px; }
#closeInfoButton {
    position: absolute;
    top: 10px; right: 10px;
    font-size: 24px;
    background: none;
    border: none;
    color: #fff;
    padding: 0 10px;
}

/* --- Win & Certificate Overlay General Styles --- */
.overlay-content {
    background-color: #2c3e50;
    padding: 40px;
    border-radius: 10px;
    border: 1px solid var(--selection-glow-color);
    max-width: 500px;
}
.overlay-buttons {
    margin-top: 30px;
}
.overlay-content h2 {
    color: var(--selection-glow-color);
    font-size: 2em;
}

/* --- Win Overlay Specific Styles --- */
.win-symbol {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--selection-glow-color);
    margin-bottom: 20px;
}

/* --- Certificate Overlay Specific Styles --- */
#certificate {
    background-color: #f5f5dc; /* Parchment paper color */
    color: #3a3a3a;
    padding: 30px;
    border: 10px solid #c0a060; /* Ornate border */
    position: relative;
}
.cert-logo {
    max-width: 150px;
    margin-bottom: 15px;
}
#certificate h1 {
    font-family: 'Garamond', serif;
    color: #5d4037;
}
#playerName {
    font-family: 'Brush Script MT', cursive;
    font-size: 2.5em;
    border: none;
    border-bottom: 2px solid #8d6e63;
    background: transparent;
    text-align: center;
    width: 80%;
    color: #3e2723;
    margin: 20px 0;
}
#playerName:focus {
    outline: none;
}
.cert-date {
    margin-top: 25px;
    font-style: italic;
}
.cert-player-name {
    /* Style for the name when downloading certificate */
    font-family: 'Brush Script MT', cursive;
    font-size: 2.5em;
    color: #3e2723;
    margin: 20px 0;
}


/* --- Other Styles --- */
#level-indicator {
    color: var(--selection-glow-color);
}


/* ================================== */
/* ===       MEDIA QUERIES          === */
/* ================================== */
@media (max-width: 1000px) { 
    #wrapper { 
        width: 100%; 
        transform: scale(calc(100vw / 1000)); 
        transform-origin: top center; 
    } 
}