:root {
    --bg: #070b1f;
    --bg-2: #101a45;
    --panel: rgba(16, 26, 69, 0.78);
    --panel-border: rgba(242, 193, 78, 0.35);
    --text: #eef1ff;
    --muted: #9aa5d6;
    --gold: #f2c14e;
    --gold-2: #ffe08a;
    --correct: #2e9e5b;
    --partial: #d98a1c;
    --wrong: #b8374a;
    --bg-image: url(images/background.jpg)
}

@font-face {
    font-family: 'KHFont';
    src: url(fonts/Kingdom_Hearts_Font.ttf);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background-image: var(--bg-image);
    background-position-y: 6rem;
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
    line-height: 1.5;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--gold-2);
}

/* Ciel étoilé en arrière-plan */
.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 28% 72%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 44% 34%, #ffe9a8 50%, transparent 51%),
        radial-gradient(1px 1px at 61% 83%, #fff 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 77% 22%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 90% 58%, #ffe9a8 50%, transparent 51%),
        radial-gradient(1px 1px at 6% 90%, #fff 50%, transparent 51%),
        radial-gradient(ellipse at 50% 0%, var(--bg-2) 0%, var(--bg) 70%);
}

/* En-tête */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(7, 11, 31, 0.85);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-family: KHFont;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-decoration: none;
    color: var(--text);
}

.modes-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.mode-link {
    background-color: #171f43;
    text-decoration: none;
    color: var(--muted);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid transparent;
    font-size: 0.75rem;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.archives {
    background-color: #2b3c99;
}

.mode-link p {
    margin-top: 6px;
    margin-bottom: 6px;
}

.mode-link:hover {
    color: #1a1400;
    border-color: var(--panel-border);
    background: linear-gradient(135deg, var(--gold-2), var(--gold))
}

.mode-link.active {
    color: #1a1400;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    font-weight: 700;
}

.lang-switch {
    display: flex;
    gap: 0.25rem;
}

.lang-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    cursor: pointer;
}

.lang-btn:hover {
    color: var(--text);
}

.lang-btn.active {
    color: #1a1400;
    background: var(--gold);
    border-color: var(--gold);
}

.content {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0rem 1rem 3rem;
}

.footer {
    text-align: center;
    color: var(--muted);
    background-color: rgba(7, 11, 31, 0.85);
    font-size: 0.8rem;
    padding: 0.25rem 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Accueil */
.hero {
    text-align: center;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 6rem;
    font-family: KHFont;
    margin: 0.5rem 0;
    letter-spacing: 0.06em;
    text-shadow: 0 0 24px rgba(242, 193, 78, 0.45);
}

.hero p {
    color: var(--muted);
    max-width: 560px;
    margin: 0 auto;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1rem;
}

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.25rem 0.5rem 1.25rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.mode-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
    box-shadow: 0 8px 28px rgba(242, 193, 78, 0.18);
}

.mode-card h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--gold-2);
}

.mode-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.75rem;
    flex: 1;
    text-align: center;
}

.mode-icon {
    font-size: 2rem;
}

.mode-count {
    font-size: 0.8rem;
    color: var(--muted);
}

.item-icon {
    margin-left: auto;
    /* pousse l'icône tout à droite */
    opacity: 0;
    /* invisible, mais elle garde sa place */
    transform: translateX(-4px);
    transition: opacity 0.15s, transform 0.15s;
}

.mode-card:hover .item-icon,
.mode-card:focus-visible .item-icon {
    /* focus-visible : même effet au clavier */
    opacity: 1;
    transform: none;
}

/* État du jour sur l'accueil */
.today-summary {
    min-height: 1.5rem;
    text-align: center;
    color: var(--gold-2);
    font-weight: 700;
    margin: -1rem 0 1.25rem;
}

.mode-card.done {
    border-color: var(--correct);
}

.mode-status-row {
    display: block;
    min-height: 1.7rem;
    margin-top: 0.4rem;
}

.mode-status {
    display: inline-block;
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.mode-status.done {
    background: var(--correct);
    color: #fff;
}

.mode-status.progress {
    background: var(--partial);
    color: #fff;
}

.mode-status.todo {
    color: var(--muted);
    font-weight: 400;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

h1:focus {
    outline: none;
}

.legend {
    margin-top: 2rem;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend h3 {
    margin: 0 0 0.5rem;
    color: var(--gold-2);
}

.legend ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 4px;
    vertical-align: -2px;
    margin-right: 0.4rem;
}

.swatch.correct {
    background: var(--correct);
}

.swatch.partial {
    background: var(--partial);
}

.swatch.wrong {
    background: var(--wrong);
}

.arrow-demo {
    color: var(--gold-2);
    margin-right: 0.4rem;
}

/* Page de jeu */
.play-head {
    text-align: center;
    margin-bottom: 1.25rem;
}

.play-head h1 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--gold-2);
}

.play-head p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.archive-picker {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    margin: 0 auto 1.25rem;
}

.archive-picker label {
    color: var(--muted);
}

.archive-picker-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.archive-picker input {
    padding: 0.6rem 0.75rem;
    color: var(--text);
    background: rgba(7, 11, 31, 0.9);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
}

.archive-error {
    margin: 0.5rem 0;
    color: var(--wrong);
    text-align: center;
}

.guess-box {
    position: relative;
    max-width: 450px;
    margin: 0 auto 0.75rem;
}

.guess-input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    color: var(--text);
    background: rgba(7, 11, 31, 0.9);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    outline: none;
}

.guess-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.2);
}

.guess-input:disabled {
    opacity: 0.6;
}

.suggestions {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0.25rem;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 5;
    background: #0d1538;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    max-height: min(320px, 50vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.suggestions:nth-child(odd) button {
    background: #1d264d;
}


.suggestions button {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.suggestions span {
    font-size: 1rem;
}

.suggestions button:hover,
.suggestions button:focus-visible {
    background: rgba(242, 193, 78, 0.18);
    outline: none;
}

/* Portraits (images par défaut si le fichier du personnage n'existe pas) */
.portrait {
    display: block;
    flex: none;
    object-fit: contain;
    border-radius: 8px;
    background: #0b1230;
}

.portrait.sm {
    width: 64px;
    height: 64px;
    border-radius: 6px;
}

.portrait.md {
    width: 100px;
    height: 100px;
    margin: 0 auto 0.3rem;
}

.portrait.lg {
    width: 150px;
    height: 150px;
    margin: 0 auto 0.75rem;
    border: 2px solid var(--gold);
}

.counter {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem;
}

.victory {
    max-width: 520px;
    margin: 0 auto 1rem;
    padding: 1.25rem;
    text-align: center;
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(46, 158, 91, 0.25), var(--panel));
    border: 1px solid var(--correct);
}

.victory h2 {
    margin: 0 0 0.5rem;
    color: var(--gold-2);
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.btn {
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1400;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.08);
}

/* Tableau des essais */
/* Le défilement horizontal n'est activé que sur petit écran : sur grand écran,
   un conteneur "overflow" couperait les infobulles des en-têtes. */
.table-wrap {
    padding-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .table-wrap {
        overflow-x: auto;
    }
}

.guess-table {
    width: 100%;
    min-width: 560px;
    border-collapse: separate;
    border-spacing: 6px;
    text-align: center;
}

.guess-table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gold-2);
    padding: 0.25rem;
}

/* Infobulles des en-têtes (survol, focus clavier ou toucher) */
.hint {
    position: relative;
    display: inline-block;
    cursor: help;
    outline: none;
}

.hint-icon {
    opacity: 0.7;
    font-size: 0.85em;
}

.hint:hover .hint-icon,
.hint:focus .hint-icon {
    opacity: 1;
}

.tip {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: max-content;
    max-width: 240px;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    color: var(--text);
    background: #0d1538;
    border: 1px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
}

.hint:hover .tip,
.hint:focus .tip,
.hint:focus-within .tip {
    visibility: visible;
    opacity: 1;
}

/* Dernière colonne : on aligne l'infobulle à droite pour qu'elle ne sorte pas de l'écran */
.guess-table thead th:last-child .tip {
    left: auto;
    right: 0;
    transform: none;
}

/* Petit écran : l'infobulle devient un bandeau fixe en bas (non coupé par le défilement du tableau) */
@media (max-width: 640px) {

    .tip,
    .guess-table thead th:last-child .tip {
        position: fixed;
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        width: auto;
        max-width: none;
    }
}

.name-cell {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.6rem 0.5rem;
    font-weight: 700;
    min-width: 110px;

}

.name-field {
    font-size: 0.8rem;
}

.cell {
    border-radius: 10px;
    padding: 0.6rem 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    animation: reveal 0.5s ease backwards;
}

.cell.correct {
    background: var(--correct);
}

.cell.partial {
    background: var(--partial);
}

.cell.wrong {
    background: var(--wrong);
}

.arrow {
    margin-left: 0.3rem;
    font-size: 0.85rem;
    opacity: 0.95;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: rotateX(90deg) scale(0.9);
    }

    to {
        opacity: 1;
        transform: rotateX(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cell {
        animation: none;
    }

    .mode-card {
        transition: none;
    }
}

/* Erreur Blazor */
#blazor-error-ui {
    color-scheme: light only;
    background: #fff3b0;
    color: #222;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Une erreur est survenue."
}

/* More tactile interactions across the page */
:root {
    --panel: rgba(13, 22, 57, 0.88);
    --panel-border: rgba(242, 193, 78, 0.42);
    --glow: 0 0 24px rgba(242, 193, 78, 0.2);
}

.sky {
    background-size: 100% 100%;
}

.topbar {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.24);
    transition: background-color 0.2s, border-color 0.2s;
}

.brand {
    transition: color 0.15s;
}

.brand:hover {
    color: var(--gold-2);
}

.mode-link {
    position: relative;
    overflow: hidden;
    transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.mode-link:hover {
    transform: translateY(-1px);
}

.mode-link:active,
.mode-card:active,
.btn:active {
    transform: translateY(1px);
}

.mode-link:focus-visible,
.mode-card:focus-visible,
.lang-btn:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--gold-2);
    outline-offset: 3px;
}

.mode-link img,
.mode-card img {
    transition: transform 0.15s;
}

.mode-link:hover img,
.mode-card:hover img {
    transform: scale(1.04);
}

.lang-btn {
    transition: color 0.18s, background 0.18s, border-color 0.18s, transform 0.18s;
}

.lang-btn:hover {
    color: var(--gold-2);
    border-color: var(--gold);
    transform: translateY(-1px);
}

.lang-btn.active:hover {
    color: #1a1400;
    background: var(--gold-2);
}

.mode-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.mode-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, border-color 0.15s, background-color 0.15s;
}

.mode-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, transparent, var(--gold), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.mode-card:hover,
.mode-card:focus-visible {
    transform: translateY(-5px);
    background: rgba(28, 43, 98, 0.96);
}

.mode-card:hover::before,
.mode-card:focus-visible::before {
    opacity: 1;
}

.mode-card.done {
    box-shadow: inset 0 0 22px rgba(46, 158, 91, 0.08);
}

.mode-status {
    transition: opacity 0.15s;
}

.legend {
    transition: border-color 0.15s;
}

.legend:hover {
    border-color: var(--panel-border);
}

.archive-picker input,
.guess-input {
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.archive-picker input:hover,
.guess-input:hover {
    border-color: rgba(242, 193, 78, 0.72);
}

.archive-picker input:focus,
.guess-input:focus {
    background: rgba(13, 22, 57, 0.98);
    box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.16);
}

.suggestions button {
    transition: background 0.15s, transform 0.15s, color 0.15s;
}

.suggestions button:hover,
.suggestions button:focus-visible {
    color: var(--gold-2);
    background: rgba(242, 193, 78, 0.18);
    transform: translateX(3px);
}

.btn {
    transition: filter 0.15s, transform 0.15s;
}

.btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.cell {
    transition: filter 0.15s;
}

.cell:hover {
    filter: brightness(1.08);
}

.name-cell {
    transition: border-color 0.18s, background 0.18s;
}

.guess-table tr:hover .name-cell {
    border-color: var(--gold);
    background: rgba(28, 43, 98, 0.95);
}

@media (max-width: 640px) {
    .hero h1 {
        font-size: clamp(3.5rem, 18vw, 5rem);
    }

    .topbar {
        justify-content: center;
    }

    .modes-nav {
        justify-content: center;
    }

    .mode-card:hover {
        transform: translateY(-2px);
    }
}