/* --- Variables -- */
:root {
    --primary: #a7c7e7;
    --secondary: #fce1e4;
    --accent: #fdfd96;
    --background: #f8f8f8;
    --text-color: #3a3a3a;
    --title-color: #0e67b1;
    --light: #ffffff;
    --accent-green:#C1E1C1;
    --border-radius: 0.5rem;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- Fonts --- */
.pacifico-regular {
  font-family: "Pacifico", cursive;
  font-weight: 400;
  font-style: normal;
}

.material-symbols-outlined {
  font-variation-settings:
  'FILL' 0,
  'wght' 400,
  'GRAD' 0,
  'opsz' 24
}

/* --- Base Styles -- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--background);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2 {
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
}

p {
    margin-bottom: 1rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* --- Navbar --- */
.navbar {
    background-color: var(--light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}   

.navbar-right {
    display: flex;
    align-items: right;
    gap: 0.75rem;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--title-color);
    font-family: 'Pacifico';
}

.brand-sword {
    font-size: 1.2rem;
    vertical-align: middle;
    margin: 0 0.1rem;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

#langSelect {
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
    background-color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
}

body.dark {
    background-color: #111827;
    color: #e5e7eb;
}

body.dark .navbar {
    background-color: #1f2937;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

body.dark .navbar-brand {
    color: #f8fafc;
}

body.dark .container {
    background-color: #1f2937;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

body.dark button {
    color: #000000;
}

body.dark .btn-primary {
    background-color: #3b82f6;
    color: #ffffff;
}

body.dark .btn-secondary {
    background-color: #10b981;
    color: #ffffff;
}

body.dark .name-btn {
    background-color: #3b82f6;
    color: #ffffff;
}

body.dark #name1Btn.name-btn.king-female {
    background-color: #f472b6;
    color: #1f1f1f;
}

body.dark #name2Btn.name-btn {
    background-color: #34d399;
    color: #1f1f1f;
}

body.dark .vs {
    color: var(--accent);
}

body.dark #winnerText {
    background-color: #fbbf24;
    color: #111827;
}

body.dark .kings-list li {
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark footer {
    color: #cbd5e1;
}

/* --- Main Content & Screens --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--light);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* --- Buttons --- */
button {
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    margin: 0.5rem;
    color: var(--text-color);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-color);
}

.btn-secondary {
    background-color: var(--accent-green);
    color: var(--text-color);
}
.name-btn {
    background-color: var(--primary);
    font-size: 1.5rem;
    min-width: 250px;
    flex: 1;
    padding: 1.5rem;
    line-height: 1.2;
}

/* --- Screen Specifics --- */
#genderScreen {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
}

#genderScreen h1 {
    width: 100%;
}
#genderScreen h2 {
    width: 100%;
}

#genderScreen button {
    font-size: 1.5rem;
    min-width: 250px;
    flex: 1;
    padding: 1.5rem;
    line-height: 1.2;
}

#btnMale {
    background-color: var(--primary);
}

#btnFemale {
    background-color: var(--secondary);
}

#name1Btn.name-btn.king-female {
    background-color: var(--secondary);
}

#name2Btn.name-btn {
    background-color: var(--accent-green);
}

/* --- Progress Bar --- */
.progress-container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 1.25rem;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
    margin: 0.35rem 0 0;
}

body.dark .progress-bar-bg {
    background-color: #374151;
}

body.dark .progress-bar-fill {
    background-color: #3b82f6;
}

body.dark .progress-text {
    color: #9ca3af;
}

/* Crown Animation */
@keyframes crown-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.king-btn {
    position: relative;
}

.king-btn::before {
    content: '👑';
    position: absolute;
    top: -1.1rem;
    left: 0.6rem;
    rotate: -20deg;
    font-size: 1.75rem;
    animation: crown-bounce 1s ease-in-out infinite;
}

.battle-arena {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 2rem;
    gap: 1rem;
}

.vs {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    background-color: var(--text-color);
    border-radius: 50%;
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px var(--text-color), 0 0 0 6px var(--accent);
}

.battle-controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.battle-controls button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.winner-controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

#winnerText {
    font-size: 2.25rem;
    color: var(--text-color);
    margin-bottom: 2rem;
    font-weight: bold;
    padding: 1rem 2rem;
    background-color: var(--accent);
    border-radius: var(--border-radius);
}

.kings-list {
    list-style: none;
    padding: 0;
    text-align: center;
    margin-top: 2rem;
    width: 100%;
    max-width: 400px;
}

.kings-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.kings-list li:last-child {
    border-bottom: none;
}

/* --- Era Chips --- */
.era-filters {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    width: 100%;
}

.era-chip {
    padding: 0.45rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 700;
    background-color: var(--accent-green);
    border-radius: 2rem;
    margin: 0;
    min-width: unset;
    transition: background-color 0.15s, opacity 0.15s;
}

.era-chip.excluded {
    background-color: #e0e0e0;
    color: #999;
    text-decoration: line-through;
}

body.dark .era-chip {
    background-color: #10b981;
    color: #fff;
}

body.dark .era-chip.excluded {
    background-color: #374151;
    color: #6b7280;
}

/* --- Filter Screen --- */
.filter-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #888;
    margin: 0;
    width: 100%;
    text-align: left;
}

body.dark .filter-label {
    color: #6b7280;
}

#filterScreen {
    gap: 1rem;
}

#filterScreen h2 {
    margin-bottom: 0;
}

.letter-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    width: 100%;
}

.letter-chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 700;
    background-color: var(--primary);
    border-radius: 2rem;
    margin: 0;
    min-width: unset;
    transition: background-color 0.15s, opacity 0.15s;
}

.letter-chip.excluded {
    background-color: #e0e0e0;
    color: #999;
    text-decoration: line-through;
    opacity: 0.6;
}

.name-list-wrapper {
    position: relative;
    width: 100%;
}

.name-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
}

.name-chip {
    padding: 0.3rem 0.7rem;
    font-size: 0.9rem;
    font-weight: 500;
    background-color: var(--primary);
    border-radius: 2rem;
    margin: 0;
    min-width: unset;
    transition: background-color 0.15s, opacity 0.15s;
}

.name-chip.excluded {
    background-color: #e0e0e0;
    color: #999;
    text-decoration: line-through;
    opacity: 0.6;
}

.filter-controls {
    position: sticky;
    bottom: 0;
    background-color: var(--light);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.07);
    padding: 0.5rem 0 0.25rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    width: 100%;
}

.filter-controls #filterCount {
    font-size: 0.8rem;
    color: #888;
    margin: 0;
}

.filter-controls-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

.filter-controls-buttons #btnStartGame {
    flex: 1;
    min-width: 140px;
}

.name-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-family: inherit;
    background-color: var(--background);
    color: var(--text-color);
}

.name-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(167, 199, 231, 0.35);
}

.btn-ghost {
    background-color: #e5e7eb;
    color: var(--text-color);
}

body.dark .btn-ghost {
    background-color: #374151;
    color: #e5e7eb;
}

.btn-danger {
    background-color: #fecaca;
    color: #7f1d1d;
}

body.dark .letter-chip {
    background-color: #3b82f6;
    color: #fff;
}

body.dark .letter-chip.excluded {
    background-color: #374151;
    color: #6b7280;
}

body.dark .name-chip {
    background-color: #2563eb;
    color: #fff;
}

body.dark .name-chip.excluded {
    background-color: #374151;
    color: #6b7280;
}

body.dark .btn-danger {
    background-color: #7f1d1d;
    color: #fecaca;
}

body.dark .filter-controls {
    background-color: #1f2937;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

body.dark .filter-controls #filterCount {
    color: #6b7280;
}

body.dark .name-search {
    background-color: #374151;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
}

body.dark .name-list {
    border-color: rgba(255, 255, 255, 0.1);
}


/* --- Cookie Banner --- */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--light);
    border-top: 1px solid #ddd;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    z-index: 9999;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.cookie-banner p {
    margin: 0;
    font-size: 0.9rem;
    text-align: left;
    flex: 1;
    min-width: 200px;
}

.cookie-banner a {
    color: var(--title-color);
}

.cookie-banner-btns {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cookie-banner-btns button {
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

body.dark .cookie-banner {
    background-color: #1f2937;
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* --- Static Pages --- */
.static-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--light);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.static-page h1 {
    text-align: left;
    color: var(--title-color);
    margin-bottom: 0.5rem;
}

.static-page h2 {
    text-align: left;
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--title-color);
}

.static-page p {
    text-align: left;
    margin-bottom: 0.75rem;
}

.static-page ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.static-page li {
    margin-bottom: 0.25rem;
}

.static-page a {
    color: var(--title-color);
}

.static-page .updated {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1.5rem;
}

body.dark .static-page {
    background-color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark .static-page h1,
body.dark .static-page h2 {
    color: #93c5fd;
}

body.dark .static-page a {
    color: #93c5fd;
}

/* --- Navbar brand as link --- */
a.navbar-brand {
    text-decoration: none;
}

/* --- Footer links --- */
footer a {
    color: #888;
}

body.dark footer a {
    color: #cbd5e1;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 1rem;
    margin-top: auto;
    font-size: 0.9rem;
    color: #888;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    main {
        padding: 0;
        justify-content: flex-start;
    }

    .container {
        margin: 0;
        padding: 1.5rem 1rem;
        box-shadow: none;
        border-radius: 0;
        background-color: transparent;
    }

    .filter-controls {
        background-color: var(--background);
    }

    body.dark .filter-controls {
        background-color: #111827;
    }

    .static-page {
        margin: 0;
        padding: 1.5rem 1rem;
        box-shadow: none;
        border-radius: 0;
    }

    .cookie-banner {
        padding: 1rem;
    }

    .battle-arena {
        flex-direction: column;
    }

    .name-btn {
        width: 100%;
        font-size: 1.3rem;
        min-width: unset;
        padding: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    #winnerText {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        flex-direction: row;
        gap: 0.5rem;
        padding: 1rem;
    }

    #genderScreen button {
        width: 100%;
    }
}