@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
}

.game-container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 90%;
    max-width: 600px;
}

h1 {
    color: #212529;
    margin-top: 0;
}

h2 {
    color: #007bff;
    font-weight: 400;
}

#guess-input {
    width: 80%;
    padding: 12px;
    margin: 20px 0;
    border: none;
    border-bottom: 2px solid #ced4da;
    background-color: #ffffff;
    color: #212529;
    font-size: 1.2em;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

#guess-input:focus {
    border-bottom-color: #007bff;
}

/* Base style for most buttons */
#submit-button, .rules-button, #skip-button, .mode-button, #play-again-btn {
    color: #ffffff;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    margin: 5px;
}

#submit-button { background-color: #007bff; }
#submit-button:hover { background-color: #0056b3; }

.rules-button { background-color: #6c757d; }
.rules-button:hover { background-color: #5a6268; }

#skip-button { background-color: #fd7e14; }
#skip-button:hover { background-color: #e66a00; }

#feedback-text {
    margin-top: 20px;
    font-size: 1.1em;
    min-height: 25px;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    position: relative;
    max-width: 400px;
    width: 80%;
    text-align: center;
}
.modal-content h2, .modal-content p { color: #212529; }

.close-button {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2em;
    color: #6c757d;
    cursor: pointer;
}
.close-button:hover { color: #212529; }

.show-modal { display: flex; }

/* --- Solutions Box --- */
#solutions-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
    text-align: left;
}
#solutions-container h3 {
    text-align: center;
    color: #007bff;
    margin-bottom: 15px;
}
#solutions-container p { margin: 5px 0 5px 10px; }
#solutions-container span {
    font-weight: 600;
    color: #495057;
}

/* --- Mode Buttons --- */
.mode-button { background-color: #007bff; }
.mode-button:hover { background-color: #0056b3; }

/* --- Timer Display --- */
#timer-display {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 1.5em;
    font-weight: 600;
    color: #fd7e14;
}

/* --- Layout for Game + Pyramid --- */
.main-content {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    padding-top: 150px;
}

/* --- Pyramid --- */
#progress-pyramid-container {
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    width: 200px;
    display: none;
}

#progress-pyramid-container h4 {
    text-align: center;
    margin-top: 0;
    color: #6c757d;
    font-weight: 400;
}

.pyramid-row {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.pyramid-square {
    width: 18px;
    height: 18px;
    background-color: #e9ecef;
    margin: 2px;
    border-radius: 4px;
    transition: background-color 0.5s;
}

/* --- Score Container --- */
#score-container {
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    width: 200px;
    text-align: center;
    display: none;
}

#score-container h4 {
    text-align: center;
    margin-top: 0;
    color: #6c757d;
    font-weight: 400;
}

#score-total {
    font-size: 3em;
    font-weight: 600;
    color: #007bff;
}

/* --- Stats Display --- */
.stats-display {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    margin: 0 auto 20px auto;
    max-width: 200px;
}
.stats-display h4 {
    margin: 0 0 5px 0;
    font-weight: 400;
    color: #6c757d;
}

.stats-bar { display: flex; justify-content: center; gap: 40px; }
.stat { text-align: center; }
.stat h4 { margin: 0; font-weight: 500; color: #4a90e2; }
.stat div { font-size: 1.5em; font-weight: 600; color: #333; }

#full-trees-count {
    font-size: 2em;
    font-weight: 600;
    color: #212529;
}

/* --- Daily Results --- */
#results-pyramid-container { margin: 20px auto; }
#results-pyramid-container .pyramid-square {
    width: 27px;
    height: 27px;
    margin: 3px;
}
#results-score { font-size: 1.5em; }
#results-pyramid-container h4 { display: none; }
#daily-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* --- Top Bar --- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #fff;
  padding: 10px 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.game-stats {
  display: flex;
  gap: 25px;
  align-items: center;
}

#score-container-top, #progress-pyramid-top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#score-total-top {
  font-size: 1.5em;
  font-weight: 600;
  color: #007bff;
}

.pyramid-square-top {
  width: 15px;
  height: 15px;
  margin: 1px;
  border-radius: 3px;
  background-color: #e9ecef;
}

/* Stats icon */
#stats-icon {
  cursor: pointer;
  font-size: 1.5rem;
}

/* Top bar pyramid rows */
.pyramid-row-top {
  display: flex;
  gap: 2px;
  justify-content: center;
  margin: 0;
}

.pyramid-square-top {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background-color: #e9ecef;
  transition: background-color 0.3s;
}

.pyramid-square-top.correct { background-color: #28a745; }
.pyramid-square-top.skipped { background-color: #dc3545; }
.pyramid-square-top.current { border: 1px solid #007bff; }

/* Fix for results pyramid colors */
#results-pyramid-container .pyramid-square.correct {
    background-color: #28a745; /* Green */
}

#results-pyramid-container .pyramid-square.skipped {
    background-color: #dc3545; /* Red */
}

/* --- Mobile --- */
/* --- Mobile --- */
@media (max-width: 768px) {
    /* Make the main game content stack vertically and fill the width */
    .top-bar {
        padding: 3px 15px; /* Reduces the height of the top bar */
    }
    .main-content {
        flex-direction: column;
        align-items: center;
        width: 100%;
        padding: 10px 0;
    }

    /* Base styles for all containers on mobile */
    .game-container {
        padding: 20px;
        box-sizing: border-box;
    }

    /* Specifically center the start and results screens */
    #mode-selection,
    #daily-results {
        width: 95%;
        margin: 0 auto; /* This centers the containers */
    }

    /* Ensure the active game area takes up the full width */
    #game-area.game-container {
        width: 100%;
        max-width: none;
    }

    .bottom-containers {
        display: flex;
        justify-content: space-around;
        width: 100%;
        padding: 10px 0;
    }
  
    #score-container,
    #progress-pyramid-container {
        flex: 1;
        margin: 0 5px;
        text-align: center;
        width: auto;
        max-width: none;
    }

    #challenge-text { font-size: 1.6rem; }
    #score-total { font-size: 2.5rem; }
    .pyramid-square { width: 20px; height: 20px; }
    #results-pyramid-container .pyramid-square { width: 25px; height: 25px; }
}

/* Definitive centering for start and results screens */
#mode-selection,
#daily-results {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; /* Ensure it doesn't touch the edges */
}

/* Push the main game content down to avoid the top bar */
.main-content {
    padding-top: 150px;
}

/* --- On-screen Keyboard Styles --- */
#keyboard-container {
    position: fixed;
    bottom: 0;
    left: 50%; /* Center the container */
    transform: translateX(-50%); /* Fine-tune the centering */
    width: 100%;
    max-width: 600px; /* Set a max-width */
    padding: 10px;
    background-color: #ced4da;
    box-sizing: border-box;
    z-index: 100;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.key {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1em;
    height: 50px;
    flex-grow: 1;
    margin: 3px;
    border: none;
    border-radius: 5px;
    background-color: #ffffff;
    color: #212529;
    cursor: pointer;
    user-select: none; /* Prevents text selection on rapid taps */
}

.key.large {
    flex-grow: 1.5;
}

.key:active {
    background-color: #adb5bd; /* Feedback on tap */
}

#results-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

#results-streak {
    font-size: 1.2em;
    font-weight: 600;
    margin-top: 20px;
}