/* ParallelTown — styles de base (mobile-first) */

:root {
    --bg: #0d1117;
    --bg-elevated: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #3fb950;
    --accent-strong: #2ea043;
    --danger: #f85149;
    --hp: #f85149;
    --mana: #58a6ff;
    --money: #d29922;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ */
/* Pages d'authentification                                           */
/* ------------------------------------------------------------------ */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 16px;
    background: radial-gradient(circle at 50% 0%, #14311f 0%, var(--bg) 55%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.7rem;
    text-align: center;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.auth-card .subtitle {
    margin: 4px 0 22px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-card label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.auth-card input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 12px 14px;
    font-size: 1rem;
    outline: none;
}

.auth-card input:focus {
    border-color: var(--accent);
}

.btn-primary {
    margin-top: 18px;
    background: var(--accent-strong);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 13px;
    cursor: pointer;
}

.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }

.form-error {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 8px;
    color: var(--danger);
    font-size: 0.9rem;
}

.switch {
    margin: 18px 0 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.switch a { color: var(--accent); text-decoration: none; }
.switch a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ */
/* Page de jeu                                                        */
/* ------------------------------------------------------------------ */

.game-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

#hud-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.hud-item { white-space: nowrap; }
.hud-level { color: var(--accent); font-weight: 700; }
.hud-pseudo { font-weight: 600; }
.hud-hp { color: var(--hp); }
.hud-mana { color: var(--mana); }
.hud-money { color: var(--money); }
#conn-status { margin-left: auto; cursor: default; }

#map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

#map {
    position: absolute;
    inset: 0;
    background: #1a1f26;
}

#map .leaflet-control-attribution {
    font-size: 10px;
    background: rgba(13, 17, 23, 0.75);
    color: #8b949e;
}

#map .leaflet-control-attribution a { color: #58a6ff; }

/* Marqueur du joueur */
.player-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-marker-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 5px rgba(63, 185, 80, 0.25);
}

.player-marker.other .player-marker-dot {
    background: var(--mana);
    box-shadow: 0 0 0 5px rgba(88, 166, 255, 0.25);
}

.player-tooltip {
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 11px;
    padding: 2px 6px;
}

.player-tooltip::before { display: none; }

#hud-bottom {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

#hud-bottom button {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.2rem;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text);
}

#hud-bottom button:disabled { opacity: 0.35; cursor: not-allowed; }
#hud-bottom button:not(:disabled):hover { border-color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Desktop                                                            */
/* ------------------------------------------------------------------ */

@media (min-width: 900px) {
    #hud-top { padding: 10px 18px; font-size: 0.95rem; }
    #hud-bottom { justify-content: center; gap: 24px; }
}

/* ------------------------------------------------------------------ */
/* Barre d'XP                                                         */
/* ------------------------------------------------------------------ */

#hud-xp {
    height: 4px;
    background: #21262d;
    flex-shrink: 0;
}

#hud-xp-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--mana));
    transition: width 0.3s ease-out;
}

/* ------------------------------------------------------------------ */
/* Monstres & ressources                                              */
/* ------------------------------------------------------------------ */

.monster-marker, .node-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.monster-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    transform: rotate(45deg);
    background: var(--danger);
    border: 2px solid #fff;
    box-shadow: 0 0 0 4px rgba(248, 81, 73, 0.25);
}

.monster-marker:hover .monster-dot {
    box-shadow: 0 0 0 7px rgba(248, 81, 73, 0.35);
}

.node-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--money);
    border: 2px solid #fff;
    box-shadow: 0 0 0 4px rgba(210, 153, 34, 0.25);
}

.node-marker.node-depleted .node-dot {
    background: #484f58;
    box-shadow: none;
    opacity: 0.6;
}

.node-marker.node-harvesting .node-dot {
    animation: pt-pulse 1s infinite;
}

@keyframes pt-pulse {
    50% { transform: scale(1.4); }
}

/* ------------------------------------------------------------------ */
/* Textes flottants (dégâts)                                          */
/* ------------------------------------------------------------------ */

.float-text {
    position: absolute;
    transform: translate(-50%, -50%);
    font-weight: 800;
    font-size: 15px;
    text-shadow: 0 1px 3px #000;
    pointer-events: none;
    animation: pt-float-up 1.1s forwards;
    z-index: 800;
}

.float-text.damage { color: #ffd166; }
.float-text.crit { color: #ff7b72; font-size: 19px; }
.float-text.taken { color: var(--danger); }

@keyframes pt-float-up {
    to { transform: translate(-50%, -170%); opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* Toasts                                                             */
/* ------------------------------------------------------------------ */

#toasts {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1200;
    width: min(92vw, 420px);
    pointer-events: none;
}

.toast {
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    animation: pt-toast-in 0.25s ease-out;
}

.toast span { color: var(--text-muted); }
.toast-success { border-left-color: var(--accent); }
.toast-warning { border-left-color: var(--money); }
.toast-error { border-left-color: var(--danger); }
.toast-out { opacity: 0; transition: opacity 0.4s; }

@keyframes pt-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ */
/* Bottom sheet (inventaire)                                          */
/* ------------------------------------------------------------------ */

#sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 62dvh;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.sheet-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}

#sheet-body {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    overflow-y: auto;
}

.inventory-money { margin: 0 0 8px; color: var(--money); font-weight: 600; }
.inventory-list { list-style: none; margin: 0; padding: 0; }
.inventory-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #21262d; }
.inventory-name { flex: 1; font-weight: 600; }
.inventory-qty { color: var(--text-muted); }
.inventory-stats { font-size: 0.75rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
