/* --- Main Plugin Container --- */
#wp-brand-quiz-game-container {
    font-family: Arial, Helvetica, sans-serif !important; /* Force a common font stack */
    border: 1px solid #cccccc !important;
    padding: 20px !important;
    max-width: 900px !important;
    margin: 20px auto !important;
    background-color: #f9f9f9 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    box-sizing: border-box !important; /* Ensure padding/border are inside max-width */
    color: #333333 !important; /* Default text color for the container */
}

#wp-brand-quiz-game-container *,
#wp-brand-quiz-game-container *::before,
#wp-brand-quiz-game-container *::after {
    box-sizing: border-box !important; /* Universal box-sizing within the plugin */
}

#wp-brand-quiz-game-container h2,
#wp-brand-quiz-game-container h3,
#wp-brand-quiz-game-container h4 {
    color: #333333 !important;
    margin-top: 0 !important;
    margin-bottom: 15px !important; /* Add some default bottom margin */
    font-weight: bold !important;
    font-family: inherit !important; /* Inherit from the container */
}
#wp-brand-quiz-game-container h2 { font-size: 24px !important; }
#wp-brand-quiz-game-container h3 { font-size: 20px !important; }
#wp-brand-quiz-game-container h4 { font-size: 16px !important; }


/* --- User Setup --- */
#wp-brand-quiz-game-container #wbqg-user-setup {
    margin-bottom: 20px !important;
    padding: 15px !important;
    border: 1px solid #e0e0e0 !important;
    background-color: #ffffff !important;
    border-radius: 5px !important;
}

#wp-brand-quiz-game-container #wbqg-user-setup input[type="text"],
#wp-brand-quiz-game-container #wbqg-user-setup select {
    display: block !important;
    width: 100% !important;
    /* Old padding: padding: 10px 12px !important; */
    padding-top: 10px !important;
    padding-right: 12px !important; /* Will be overridden by specific select padding-right for arrow if needed */
    padding-bottom: 10px !important;
    padding-left: 12px !important;
    margin-bottom: 12px !important;
    margin-right: 0 !important;
    border: 1px solid #cccccc !important;
    border-radius: 4px !important;
    min-width: 200px !important;
    background-color: #ffffff !important;
    color: #333333 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important; /* Attempt to remove any theme/builder box shadows */
    outline: none !important; /* Attempt to remove any theme/builder outlines */
}

/* Custom arrow for select - ensure this padding-right is dominant for the arrow */
#wp-brand-quiz-game-container #wbqg-user-setup select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.4-5.4-13.2z%22%2F%3E%3C%2Fsvg%3E') !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 10px 10px !important;
    padding-right: 35px !important; /* Explicitly set padding-right for the select for the arrow space */
}

#wp-brand-quiz-game-container #wbqg-user-setup button#wbqg-start-game {
    display: inline-block !important;
    padding: 10px 18px !important;
    background-color: #0073aa !important; /* WP blue */
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: bold !important;
    text-align: center !important;
    transition: background-color 0.2s ease !important;
    width: auto !important; /* Let it size based on content */
    min-width: 120px !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#wp-brand-quiz-game-container #wbqg-user-setup button#wbqg-start-game:hover {
    background-color: #005a87 !important;
}

/* --- Game Area --- */
#wp-brand-quiz-game-container .wbqg-player-info {
    margin-bottom: 15px !important;
    font-weight: bold !important;
    background-color: #eef2f7 !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    display: inline-block !important;
    font-size: 14px !important;
}
#wp-brand-quiz-game-container .wbqg-player-info .flag-icon {
    margin-left: 5px !important;
    vertical-align: middle !important;
}

#wp-brand-quiz-game-container #wbqg-submit-form {
    margin: 20px 0 !important;
    display: flex !important; /* Align input and button */
    align-items: center !important;
    gap: 10px !important;
}
#wp-brand-quiz-game-container #wbqg-brand-input {
    flex-grow: 1 !important; /* Input takes available space */
    padding: 10px 12px !important;
    border: 1px solid #cccccc !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    background-color: #ffffff !important;
    color: #333333 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}
#wp-brand-quiz-game-container #wbqg-submit-button {
    padding: 10px 20px !important;
    background-color: #28a745 !important; /* Green */
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: bold !important;
    transition: background-color 0.2s ease !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}
#wp-brand-quiz-game-container #wbqg-submit-button:hover {
    background-color: #218838 !important;
}
#wp-brand-quiz-game-container #wbqg-submit-button:disabled,
#wp-brand-quiz-game-container #wbqg-brand-input:disabled {
    background-color: #dddddd !important;
    border-color: #cccccc !important;
    color: #888888 !important;
    cursor: not-allowed !important;
}
#wp-brand-quiz-game-container #wbqg-brand-input:disabled {
     opacity: 0.7 !important;
}


/* --- Messages --- */
#wp-brand-quiz-game-container .wbqg-message,
#wp-brand-quiz-game-container .wbqg-error { /* General error class for setup */
    padding: 10px 15px !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    border-style: solid !important;
    border-width: 1px !important;
    width: 100% !important; /* Make messages take full width */
}
#wp-brand-quiz-game-container .wbqg-message.success {
    background-color: #d4edda !important;
    color: #155724 !important;
    border-color: #c3e6cb !important;
    display: block !important;
}
#wp-brand-quiz-game-container .wbqg-message.error,
#wp-brand-quiz-game-container p.wbqg-error { /* Ensure <p class="wbqg-error"> is also styled */
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-color: #f5c6cb !important;
    display: block !important;
}
/* Ensure setup error paragraph (which has id wbqg-setup-error) is targeted */
#wp-brand-quiz-game-container #wbqg-setup-error {
    display: none; /* Hidden by default via JS logic, but if shown: */
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-color: #f5c6cb !important;
    padding: 10px 15px !important;
    margin-top: 10px !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    border-style: solid !important;
    border-width: 1px !important;
}
#wp-brand-quiz-game-container #wbqg-setup-error:not(:empty) {
    display: block !important; /* Show if it has content */
}


/* --- Game Layout (Played Brands & Leaderboards side-by-side) --- */
#wp-brand-quiz-game-container .wbqg-game-layout {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    margin-top: 20px !important;
}
#wp-brand-quiz-game-container .wbqg-brands-played,
#wp-brand-quiz-game-container .wbqg-leaderboards {
    flex: 1 !important;
    min-width: 280px !important;
    background-color: #ffffff !important;
    padding: 15px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 5px !important;
}
#wp-brand-quiz-game-container .wbqg-brands-played h3,
#wp-brand-quiz-game-container .wbqg-leaderboards h3 {
    border-bottom: 1px solid #eeeeee !important;
    padding-bottom: 10px !important;
    margin-bottom: 10px !important;
}
#wp-brand-quiz-game-container .wbqg-leaderboards {
     display: flex !important;
     flex-direction: column !important;
     gap: 15px !important;
}
#wp-brand-quiz-game-container .wbqg-leaderboard h4 {
    margin-bottom: 8px !important;
    color: #555555 !important;
}

/* --- Lists --- */
#wp-brand-quiz-game-container #wbqg-brands-list,
#wp-brand-quiz-game-container #wbqg-leaderboard-brands,
#wp-brand-quiz-game-container #wbqg-leaderboard-volume {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    font-size: 14px !important;
}
#wp-brand-quiz-game-container #wbqg-brands-list li,
#wp-brand-quiz-game-container #wbqg-leaderboard-brands li,
#wp-brand-quiz-game-container #wbqg-leaderboard-volume li {
    padding: 6px 0 !important;
    border-bottom: 1px dashed #eeeeee !important;
    line-height: 1.6 !important;
}
#wp-brand-quiz-game-container #wbqg-brands-list li:last-child,
#wp-brand-quiz-game-container #wbqg-leaderboard-brands li:last-child,
#wp-brand-quiz-game-container #wbqg-leaderboard-volume li:last-child {
    border-bottom: none !important;
}
#wp-brand-quiz-game-container #wbqg-brands-list li strong,
#wp-brand-quiz-game-container #wbqg-leaderboard-brands li strong,
#wp-brand-quiz-game-container #wbqg-leaderboard-volume li strong {
    font-weight: bold !important;
    color: #111111 !important;
}


/* --- Flag Icons (Ensure flag-icon-css is loaded, or style them manually) --- */
#wp-brand-quiz-game-container .flag-icon {
    margin-right: 5px !important;
    box-shadow: 0 0 1px rgba(0,0,0,0.5) !important;
    border: none !important; /* Override any theme borders on spans */
    display: inline-block !important; /* Ensure it behaves well */
    vertical-align: middle !important;
}

#wp-brand-quiz-game-container p { /* Generic paragraph styling within the plugin */
    margin-bottom: 10px !important;
    line-height: 1.6 !important;
    font-size: 14px !important;
}
#wp-brand-quiz-game-container p strong {
    font-weight: bold !important;
    color: #111111 !important;
}

/* --- Country Setup --- */
#wp-brand-quiz-game-container #wbqg-country-setup {
    padding: 20px;
    border: 1px solid #e0e0e0;
    background-color: #f5f5f5;
    margin-bottom: 20px;
    border-radius: 5px;
}
#wp-brand-quiz-game-container #wbqg-country-setup h3 {
    margin-top: 0;
}
#wp-brand-quiz-game-container #wbqg-player-country-select {
    padding: 8px 10px;
    min-width: 200px;
    margin-right: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#wp-brand-quiz-game-container #wbqg-save-country-button {
    padding: 8px 15px;
    background-color: #0073aa; /* WP Blue */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#wp-brand-quiz-game-container #wbqg-save-country-button:hover {
    background-color: #005a87;
}
#wp-brand-quiz-game-container #wbqg-country-setup-message {
    margin-top: 10px;
}