/* =============================================================================================
   Cosmos - theme sombre : pierre, fer forge et braises.
   ============================================================================================= */
:root {
    --bone: #ddd4c4;
    --ash: #9a948a;
    --smoke: #6b675f;
    --iron-1: #3a3a3d;
    --iron-2: #2a2a2d;
    --iron-3: #1b1b1d;
    --iron-edge: #4d4d52;
    --abyss: #0a0a0b;
    --gold: #c9a35a;
    --gold-dim: #8c7344;
    --blood: #8f1d17;
    --ember: #d2512a;
    --font-title: 'Cinzel', Georgia, 'Times New Roman', serif;
    --font-text: 'EB Garamond', Georgia, 'Times New Roman', serif;
    /* Grain de pierre genere en SVG */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0 24px;
    color: var(--bone);
    font: 17px/1.45 var(--font-text);
    background-color: #0e0e0f;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(120, 118, 112, .16), transparent 70%),
        radial-gradient(ellipse 70% 40% at 50% 105%, rgba(143, 29, 23, .22), transparent 70%),
        var(--grain),
        /* Blocs de pierre */
        linear-gradient(rgba(0, 0, 0, .55) 2px, transparent 2px),
        linear-gradient(90deg, rgba(0, 0, 0, .45) 2px, transparent 2px),
        linear-gradient(180deg, #1a1a1b, #111112 60%, #0b0b0c);
    background-size: auto, auto, 220px 220px, 160px 80px, 160px 80px, auto;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Assombrit les bords de la page */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .75) 100%);
}

.site-header,
.game-main,
.welcome-main,
.site-footer {
    position: relative;
    z-index: 1;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

/* ---------------------------------------------------------------- En-tete */
.site-header {
    width: min(100%, 1140px);
    margin: 0 auto;
    padding: 30px 0 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    animation: rise-in .7s ease both;
}

.brand-mark {
    width: 74px;
    height: 74px;
    flex: none;
    background: url("../../img/logo.png") center / 92% no-repeat, radial-gradient(circle, #2d2d30, #151516);
    border: 2px solid #050505;
    box-shadow: inset 0 0 0 1px var(--iron-edge), inset 0 0 18px rgba(0, 0, 0, .9), 0 0 0 1px #2b2b2e, 0 6px 18px rgba(0, 0, 0, .7);
    filter: grayscale(1) contrast(1.15) brightness(.95);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--gold-dim);
    font: 600 11px var(--font-title);
    letter-spacing: .32em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font: 900 clamp(2.6rem, 7vw, 4.4rem)/.9 var(--font-title);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #b9b4ab;
    background: linear-gradient(180deg, #f0ebe0 0%, #a7a29a 45%, #5f5b55 52%, #9c968c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 14px rgba(0, 0, 0, .9));
}

/* ---------------------------------------------------------------- Cadres en metal */
.frame {
    position: relative;
    padding: 16px;
    background:
        var(--grain),
        linear-gradient(180deg, var(--iron-1), var(--iron-2) 40%, var(--iron-3));
    background-size: 220px 220px, auto;
    border: 1px solid #000;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .09),
        inset 0 0 0 4px #222224,
        inset 0 0 0 5px #0c0c0d,
        inset 0 0 0 6px rgba(255, 255, 255, .05),
        0 18px 50px rgba(0, 0, 0, .75);
}

/* Rivets aux quatre coins */
.rivet {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #a4a4a8, #4a4a4e 45%, #151516 75%);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .9);
}

.rivet.tl { top: 7px; left: 7px; }
.rivet.tr { top: 7px; right: 7px; }
.rivet.bl { bottom: 7px; left: 7px; }
.rivet.br { bottom: 7px; right: 7px; }

.panel-title {
    margin: 0 0 12px;
    padding-bottom: 8px;
    color: var(--gold);
    font: 700 13px var(--font-title);
    letter-spacing: .28em;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 0 1px 0 #000;
    border-bottom: 1px solid #0b0b0c;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------------------------------------------------------------- Mise en page du jeu */
.game-main,
.welcome-main {
    width: min(100%, 1140px);
    margin: 0 auto;
    flex: 1;
}

.game-main {
    display: grid;
    grid-template-columns: minmax(0, 680px) minmax(280px, 1fr);
    gap: 22px;
    align-items: start;
    animation: rise-in .8s .05s ease both;
}

.frame-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 2px 6px 12px;
}

.map-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.map-title h2 {
    margin: 0;
    overflow: hidden;
    color: var(--bone);
    font: 700 clamp(1rem, 2.4vw, 1.3rem) var(--font-title);
    letter-spacing: .08em;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 0 #000;
}

.map-coords {
    flex: none;
    padding: 2px 8px;
    color: var(--ash);
    font: 600 11px var(--font-title);
    letter-spacing: .14em;
    background: rgba(0, 0, 0, .35);
    border: 1px solid #111;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.status-dot {
    flex: none;
    color: var(--ash);
    font: 600 10px var(--font-title);
    letter-spacing: .2em;
    text-transform: uppercase;
}

.status-dot::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--ember);
    box-shadow: 0 0 10px var(--ember), 0 0 3px #ffb07a inset;
    animation: ember 2.4s ease-in-out infinite;
}

.status-dot.offline {
    color: var(--smoke);
}

.status-dot.offline::before {
    background: #3a3a3c;
    box-shadow: none;
    animation: none;
}

#wrapper {
    position: relative;
    padding: 6px;
    background: #050505;
    border: 1px solid #000;
    box-shadow: inset 0 0 0 1px #3c3c40, inset 0 0 0 3px #111, 0 0 0 1px rgba(255, 255, 255, .05);
}

/* Ombre interieure sur le canvas, comme une fenetre creusee dans la pierre */
#wrapper::after {
    content: '';
    position: absolute;
    inset: 6px;
    pointer-events: none;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, .85);
}

#game-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    background: #050505;
}

/* ---------------------------------------------------------------- Vie et compteur */
.frame-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: none;
}

.tally {
    color: var(--ash);
    font: 600 12px var(--font-title);
    letter-spacing: .1em;
}

.tally b {
    color: var(--bone);
}

.hp-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: none;
}

/* Orbe de vie : un globe de verre rempli de sang, serti dans du fer */
.hp-orb {
    position: relative;
    width: 58px;
    height: 58px;
    overflow: hidden;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 45%, #1c0605, #070101 70%);
    box-shadow: 0 0 0 2px #000, 0 0 0 4px #3e3e42, 0 0 0 5px #111, 0 4px 12px rgba(0, 0, 0, .8), inset 0 0 12px rgba(0, 0, 0, .9);
}

.hp-liquid {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 18% at 50% 0%, rgba(255, 120, 100, .45), transparent 70%),
        linear-gradient(180deg, #d0281c 0%, #8e130c 55%, #4a0603 100%);
    transform: translateY(calc((1 - var(--hp, 1)) * 100%));
    transition: transform .35s ease-out;
}

/* Reflet du verre */
.hp-orb::after {
    content: '';
    position: absolute;
    top: 8%;
    left: 20%;
    width: 38%;
    height: 26%;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, .35), transparent 70%);
    pointer-events: none;
}

.hp-orb.low {
    animation: hp-pulse 1s ease-in-out infinite;
}

.hp-text {
    color: var(--bone);
    font: 600 11px var(--font-title);
    letter-spacing: .06em;
    white-space: nowrap;
}

@keyframes hp-pulse {
    0%, 100% { box-shadow: 0 0 0 2px #000, 0 0 0 4px #3e3e42, 0 0 0 5px #111, 0 4px 12px rgba(0, 0, 0, .8); }
    50% { box-shadow: 0 0 0 2px #000, 0 0 0 4px #6a1712, 0 0 0 5px #111, 0 0 18px rgba(210, 40, 28, .6); }
}

/* ---------------------------------------------------------------- Barre d'action */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .35), rgba(0, 0, 0, .15));
    border: 1px solid #0b0b0c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 1px 0 rgba(255, 255, 255, .05);
}

.hand-slot {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.hand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hand-text .label {
    color: var(--smoke);
    font: 600 10px var(--font-title);
    letter-spacing: .22em;
    text-transform: uppercase;
}

.hand-text strong {
    color: var(--bone);
    font: 600 15px var(--font-title);
    white-space: nowrap;
}

.hand-text small {
    color: var(--ash);
    font-size: 14px;
}

.slot {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    background: radial-gradient(circle at 50% 40%, #232325, #0d0d0e 75%);
    border: 1px solid #000;
    box-shadow: inset 0 0 0 1px #3a3a3e, inset 0 0 10px rgba(0, 0, 0, .9);
}

.slot-hand {
    width: 56px;
    height: 56px;
    box-shadow: inset 0 0 0 1px var(--gold-dim), inset 0 0 0 2px #000, inset 0 0 14px rgba(0, 0, 0, .9), 0 0 12px rgba(201, 163, 90, .12);
}

.slot-hand canvas {
    width: 48px;
    height: 48px;
}

.belt {
    display: flex;
    gap: 6px;
}

.slot-empty span {
    position: absolute;
    right: 4px;
    bottom: 1px;
    color: #4d4a45;
    font: 600 10px var(--font-title);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 20px;
    margin: 12px 0 2px;
    padding: 0;
    color: var(--ash);
    font-size: 15px;
    list-style: none;
}

kbd {
    display: inline-block;
    min-width: 22px;
    margin-right: 3px;
    padding: 1px 6px;
    color: var(--bone);
    font: 600 11px var(--font-title);
    text-align: center;
    background: linear-gradient(180deg, #3b3b3f, #1d1d1f);
    border: 1px solid #000;
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 2px 0 #000;
}

/* ---------------------------------------------------------------- Colonne laterale */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

.minimap {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: min(100%, 250px);
    margin: 0 auto;
    padding: 6px;
    background: #070707;
    border: 1px solid #000;
    box-shadow: inset 0 0 0 1px #2e2e31, inset 0 0 16px rgba(0, 0, 0, .9);
}

.world-cell {
    position: relative;
    aspect-ratio: 1;
    background: repeating-linear-gradient(45deg, #121213 0 4px, #0c0c0d 4px 8px);
    border: 1px solid #000;
    opacity: .7;
}

.world-cell.known {
    background: linear-gradient(160deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .35)), var(--theme);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
    opacity: 1;
}

.world-cell.current {
    outline: 2px solid var(--gold);
    outline-offset: 1px;
    box-shadow: 0 0 14px rgba(201, 163, 90, .45), inset 0 0 0 1px rgba(255, 255, 255, .2);
    z-index: 1;
}

.world-cell.current::after {
    content: '';
    position: absolute;
    inset: 35%;
    border-radius: 50%;
    background: var(--ember);
    box-shadow: 0 0 8px var(--ember);
}

.world-players {
    position: absolute;
    top: 1px;
    right: 3px;
    color: #f1e6cf;
    font: 700 10px var(--font-title);
    text-shadow: 0 1px 2px #000;
}

.world-info {
    margin: 10px 0 0;
    color: var(--ash);
    font-size: 15px;
    text-align: center;
}

.chat-panel {
    display: flex;
    flex-direction: column;
}

.chat-log {
    height: 340px;
    margin: 0 0 10px;
    padding: 8px 10px;
    overflow-y: auto;
    list-style: none;
    background: rgba(0, 0, 0, .55);
    border: 1px solid #000;
    box-shadow: inset 0 0 0 1px #2a2a2d, inset 0 0 18px rgba(0, 0, 0, .8);
    scrollbar-width: thin;
    scrollbar-color: #4a4a4e #0b0b0c;
}

.chat-line {
    margin: 0 0 4px;
    font-size: 16px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.chat-line time {
    margin-right: 6px;
    color: #5b5850;
    font: 600 10px var(--font-title);
}

.chat-line b {
    margin-right: 6px;
    color: #b8b1a3;
    font-weight: 600;
}

.chat-line b::after {
    content: ' :';
    color: var(--smoke);
}

.chat-line.mine b {
    color: var(--gold);
}

.chat-line.system {
    color: #b0705c;
    font-style: italic;
}

.chat-form {
    display: flex;
    gap: 8px;
}

.chat-form input {
    flex: 1;
    min-width: 0;
}

/* ---------------------------------------------------------------- Formulaires et boutons */
input[type=text] {
    width: 100%;
    padding: 9px 11px;
    color: var(--bone);
    font: 17px var(--font-text);
    background: #0b0b0c;
    border: 1px solid #000;
    border-radius: 0;
    outline: 0;
    box-shadow: inset 0 0 0 1px #2e2e31, inset 0 2px 8px rgba(0, 0, 0, .9);
    transition: box-shadow .2s;
}

input[type=text]:focus {
    box-shadow: inset 0 0 0 1px var(--gold-dim), inset 0 2px 8px rgba(0, 0, 0, .9), 0 0 10px rgba(201, 163, 90, .15);
}

input::placeholder {
    color: #5b5850;
    font-style: italic;
}

.btn {
    padding: 12px 18px;
    color: #e9e2d4;
    font: 700 13px var(--font-title);
    letter-spacing: .18em;
    text-transform: uppercase;
    cursor: pointer;
    background: linear-gradient(180deg, #4a4a4f 0%, #2b2b2e 48%, #1c1c1e 52%, #2a2a2d 100%);
    border: 1px solid #000;
    border-radius: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 0 0 2px rgba(0, 0, 0, .35), 0 3px 0 #000, 0 6px 14px rgba(0, 0, 0, .6);
    text-shadow: 0 1px 0 #000;
    transition: color .2s, box-shadow .2s, transform .1s;
}

.btn:hover,
.btn:focus-visible {
    color: #fff4dc;
    outline: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 0 0 1px rgba(210, 81, 42, .7), 0 3px 0 #000, 0 0 18px rgba(210, 81, 42, .35);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 0 #000;
}

.btn-small {
    padding: 8px 12px;
    font-size: 11px;
    letter-spacing: .12em;
}

/* ---------------------------------------------------------------- Accueil */
.welcome-main {
    display: grid;
    place-items: center;
    padding-bottom: 30px;
}

.welcome-panel {
    width: min(100%, 520px);
    padding: clamp(30px, 7vw, 54px);
    text-align: left;
    animation: rise-in .8s .1s ease both;
}

.welcome-panel h2 {
    margin-bottom: 14px;
    color: var(--bone);
    font: 700 clamp(1.7rem, 5.5vw, 2.5rem)/1.1 var(--font-title);
    text-shadow: 0 2px 0 #000;
}

.welcome-copy {
    color: var(--ash);
    font-size: 18px;
}

.welcome-panel form {
    margin-top: 30px;
}

.welcome-panel label {
    display: block;
    margin-bottom: 8px;
    color: var(--gold-dim);
    font: 600 11px var(--font-title);
    letter-spacing: .22em;
    text-transform: uppercase;
}

.name-input {
    position: relative;
}

.name-input input {
    padding-right: 40px;
    font-size: 19px;
}

.name-input span {
    position: absolute;
    top: 50%;
    right: 12px;
    color: var(--smoke);
    font: 600 10px var(--font-title);
    transform: translateY(-50%);
}

.welcome-panel .btn {
    width: 100%;
    margin-top: 24px;
}

.btn span {
    margin-left: 8px;
}

/* ---------------------------------------------------------------- Pied de page */
.site-footer {
    padding: 28px 0 24px;
    color: #4f4c46;
    font: 600 10px var(--font-title);
    letter-spacing: .2em;
    text-align: center;
    text-transform: uppercase;
}

@keyframes rise-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ember {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before {
        animation: none !important;
    }
}

/* ---------------------------------------------------------------- Ecrans etroits */
@media (max-width: 1000px) {
    .game-main {
        grid-template-columns: minmax(0, 1fr);
        max-width: 680px;
    }

    .chat-log {
        height: 220px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 0 12px;
    }

    .site-header {
        padding-top: 20px;
    }

    .brand-mark {
        width: 56px;
        height: 56px;
    }

    .frame {
        padding: 12px;
    }

    #wrapper {
        padding: 3px;
    }

    .action-bar {
        flex-wrap: wrap;
    }

    .belt .slot {
        width: 34px;
        height: 34px;
    }

    .map-coords {
        display: none;
    }
}
