/* =========================================================================
   ESTILS UNIFICATS - LAZY DM
   ========================================================================= */

/* ==================== BASE / RESET ==================== */
html {
    min-height: 100%;
}

body {
    margin: 0;
    display: flex;
    background: #111;
    overflow: hidden;
}

/* ==================== LAYOUT COMÚ DE PÀGINA ==================== */
.page-dm,
.page-player {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #111;
    color: #eee;
    font-family: Arial, sans-serif;
}

.dm-layout {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #111;
}

.dm-layout>.dm-main-area {
    flex: 1 1 auto;
    min-height: 0;
}

.page-player>.dm-layout {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: auto;
}

.dm-main-area {
    width: 100vw;
    flex: 1;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 52px);
}

/* ==================== TOPBAR ==================== */
.dm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 52px;
    padding: 0 16px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    touch-action: pan-x;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    z-index: 30;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.dm-header::-webkit-scrollbar {
    height: 6px;
}

.dm-header::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.dm-header::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.dm-header-left,
.dm-header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dm-header-left {
    gap: 12px;
    padding-right: 12px;
    min-width: 0;
}

.dm-header-right {
    padding-left: 12px;
}

.dm-header>*,
.dm-header-left>*,
.dm-tabs>*,
.dm-header-right>* {
    align-self: center;
}

/* Pestanyes centrals */
.dm-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 0 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    touch-action: pan-x;
    padding: 2px 0;
}

.dm-tabs::-webkit-scrollbar {
    display: none;
}

/* Logotip */
.dm-logo {
    font-size: 1.15em;
    font-weight: bold;
    color: #d4a359;
    letter-spacing: 0.5px;
    user-select: none;
}

.dm-header .dm-logo {
    line-height: 1;
}

span.dm-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

span.dm-logo img.logo-top-bar {
    display: block;
}

/* ---------- Botons de la topbar ---------- */
.topbar-btn {
    width: auto !important;
    margin: 0 !important;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 45px;
    min-width: 36px;
    padding: 0 12px;
    box-sizing: border-box;
    flex-shrink: 0;

    font-family: inherit;
    font-size: 0.88em;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;

    color: #999;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;

    cursor: pointer;
    transition: background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.topbar-btn .tab-icon,
.topbar-btn .tab-icon img,
.topbar-btn img,
.logo-top-bar {
    display: block;
    min-width: 20px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
    flex-shrink: 0;
}

.topbar-btn:hover {
    color: #eee;
    background: rgba(255, 255, 255, 0.08);
}

#topbar-delete:hover {
    background: rgba(232, 90, 90, 0.2);
}

.topbar-btn:active {
    transform: scale(0.96);
}

.topbar-btn.tab.active,
.topbar-btn.tab.active:hover {
    color: #d4a359;
    background: rgba(212, 163, 89, 0.16);
    border-color: rgba(212, 163, 89, 0.4);
}

.topbar-btn.topbar-indicator {
    cursor: help;
}

.topbar-btn.topbar-indicator:hover {
    background: transparent;
    color: #999;
}

.topbar-btn .topbar-icon-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 35px;
    font-size: 18px;
    line-height: 1;
}

.topbar-btn.is-fullscreen {
    color: #d4a359;
    background: rgba(212, 163, 89, 0.16);
    border-color: rgba(212, 163, 89, 0.4);
}

.topbar-btn.is-fullscreen:hover {
    color: #d4a359;
    background: rgba(212, 163, 89, 0.22);
}

/* Badge de la sala */
.dm-room-badge {
    background: #252525;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #aaa;
    border: 1px solid #3a3a3a;
    line-height: 1.25;
    cursor: help;
    display: inline-block;
    user-select: none;
    -webkit-user-select: none;
}

.dm-room-badge strong {
    color: #fff;
    font-weight: 600;
}

.dm-header[data-role="player"] #topbar-permanent {
    cursor: help;
}



/* ==================== MAPA ==================== */
#map-stack {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #f4ebd8;
    min-width: 0;
    touch-action: none;
}

#map-stack canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    background: transparent;
    cursor: default;
    touch-action: none;
}

#bg {
    z-index: 1;
    cursor: default;
    background: #f4ebd8 !important;
    touch-action: none;
}

#c {
    z-index: 2;
    background: transparent !important;
    touch-action: none;
}

#overlay {
    pointer-events: none;
    z-index: 3;
    background: transparent !important;
    touch-action: none;
}

.dm-map-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.dm-map-view #map-stack {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f4ebd8;
}

.dm-map-view #map-stack canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    background: transparent;
    cursor: default;
}

/* ==================== HUD FLOTANT ==================== */
.map-floating-hud {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 54px;
    box-sizing: border-box;
    padding: 8px;
    background: rgba(26, 26, 26, 0.88);
    backdrop-filter: blur(10px);
    border-radius: 27px;
    border: 1px solid rgba(212, 163, 89, 0.35);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65);
    z-index: 99999;
    pointer-events: auto;
}

.hud-btn {
    position: relative;
    display: flex;
    align-items: center;
    height: 38px;
    min-width: 38px;
    padding: 0;
    box-sizing: border-box;
    background: #2a2a2a;
    color: #eee;
    border: 1px solid #444;
    border-radius: 19px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    justify-content: center;
    gap: 8px;
}

.hud-icon {
    display: block;
    align-items: center;
    justify-content: center;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
    font-size: 1.15rem;
}

.hud-btn:hover,
.hud-btn:focus-visible {
    z-index: 2;
    background: #d4a359;
    color: #111;
    border-color: #d4a359;
    outline: none;
}



/* ==================== PANELLS DE PESTANYA ==================== */
.dm-tab-panel {
    position: absolute;
    inset: 0;
    z-index: 1600;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: scroll;
}

.dm-tab-panel-inner {
    background: var(--pm-bg);
    border: 1px solid var(--pm-line);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
    overflow: hidden;
    animation: fadeInTab 0.18s ease-out;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.dm-tab-content-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.dm-tab-content-body h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 56px;
    border-bottom: 1px solid var(--pm-line);
    text-align: center;
    flex-shrink: 0;
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--pm-gold);
}

.dm-tab-content-body .form-group {
    margin-bottom: 14px;
}

.dm-tab-content-body label {
    display: block;
    color: var(--pm-muted);
    margin-bottom: 6px;
    font-size: 0.88em;
}

.dm-tab-content-body input[type="text"]:not(.stepper-input),
.dm-tab-content-body input[type="number"]:not(.stepper-input),
.dm-tab-content-body select {
    width: 100%;
}

.dm-tab-content-body .btn-primary,
.dm-tab-content-body .btn-secondary {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    font-size: 0.92em;
}

/* ==================== BOTONS GENERALS ==================== */
button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #444;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
}

button:hover {
    background: #555;
}



#close-zoom {
    margin-top: 10px;
    padding: 8px;
    background: #c0392b;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
    border-radius: 4px;
    border: none;
    display: none;
}

#close-zoom:hover {
    background: #e74c3c;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #c28e38;
    color: #1a1410;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
}

.btn-primary:hover {
    background: #e5b876;
}

.btn-secondary {
    padding: 10px;
    background: transparent;
    color: var(--pm-gold);
    border: 1px solid var(--pm-gold);
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: rgba(212, 163, 89, 0.12);
}

/* ==================== SELECTOR D'ICONES DEL JUGADOR ==================== */
.player-icon-wrapper {
    position: relative;
    flex-shrink: 0;
}

.player-icon-btn {
    width: 36px;
    height: 36px;
    padding: 2px;
    background: #f4ebd8;
    border: 2px solid #8b7355;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, transform 0.15s;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.player-icon-btn:hover {
    border-color: #d35400;
    transform: scale(1.08);
}

.player-icon-btn img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.player-icon-dropdown {
    position: fixed;
    background: #f4ebd8;
    border: 2px solid #8b7355;
    border-radius: 8px;
    padding: 10px;
    display: none;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    gap: 8px;
    width: min(calc(100vw - 20px), 412px);
    max-height: 80vh;
    overflow-y: auto;
}

.player-icon-dropdown.show {
    display: grid;
    grid-template-columns: repeat(auto-fit, 92px);
    justify-content: center;
}

.player-icon-option {
    width: 92px;
    height: 92px;
    box-sizing: border-box;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    background: rgba(139, 115, 85, 0.08);
    transition: all 0.2s ease;
}

.player-icon-option:hover {
    background: rgba(139, 115, 85, 0.25);
    border-color: rgba(211, 84, 0, 0.4);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.player-icon-option.selected {
    background: rgba(212, 83, 0, 0.15);
    border-color: #d35400;
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(211, 84, 0, 0.4), inset 0 0 8px rgba(211, 84, 0, 0.1);
    z-index: 2;
}

.player-icon-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ==================== POPUPS ==================== */
#monster-popup,
#initiative-popup,
#move-players-popup {
    position: fixed;
    width: auto;
    min-width: 260px;
    max-width: min(520px, calc(100vw - 24px));
    background: #f4ebd8;
    color: #2d231e;
    font-family: 'Georgia', serif;
    border: 2px solid #2d231e;
    border-radius: 4px;
    box-shadow: 5px 5px 0px rgba(45, 35, 30, 0.3), 0 10px 25px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
    max-height: calc(100vh - 40px);
}

#move-players-popup {
    z-index: 1001;
}

#monster-popup {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#initiative-popup {
    bottom: 20px;
    left: 20px;
    transform: none;
}

#initiative-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: auto;
    scrollbar-width: thin;
    /*scrollbar-color: rgba(255, 255, 255, 0.3) transparent;*/
    scrollbar-color: #2a242042 transparent;
}

#initiative-popup .popup-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.monster-info-x-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(45, 35, 30, 0.85);
    color: #f4ebd8;
    border-radius: 50%;
    font-size: 20px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 1010;
    transition: background 0.15s, transform 0.15s;
    padding: 0 0 1px 0;
    font-family: Tahoma, sans-serif !important;
    font-weight: bold !important;
}

.monster-info-x-btn:hover {
    background: #8a1c14;
    transform: scale(1.05);
}

#monster-info-img {
    width: 100%;
    height: auto;
    display: block;
    border-bottom: 2px solid #2d231e;
    filter: sepia(0.3) contrast(1.1);
    flex-shrink: 0;
    object-fit: contain;
}

.monster-info-content {
    padding: 14px;
    background-image: radial-gradient(rgba(120, 90, 60, 0.05) 1px, transparent 0);
    background-size: 4px 4px;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
}

.monster-info-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #8a1c14;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.monster-info-type-info {
    font-style: italic;
    font-size: 0.85em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    background-image: url('/public/assets/popup-info-barra.webp');
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100% auto;
    padding: 1px 14px 1px 14px;
    color: #d2c6bf;
}

#monster-info-id {
    float: right;
}

#monster-info-lvl {
    flex: 1;
    text-align: center;
}

.monster-info-stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.monster-info-images-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.monster-info-img {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.monster-info-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.monster-info-ac {
    margin: 0;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-image: url('/public/assets/badge-info-ac.svg');
    background-repeat: no-repeat;
    background-position: center top;
    background-size: 100% auto;
}

.monster-info-ac strong {
    font-family: 'Palatino', 'Merriweather', serif;
    font-size: 2.5rem;
    padding-top: 22px;
}

.monster-info-stat {
    font-size: 0.85em;
    margin: 5px 0;
    border-bottom: 1px dotted rgba(45, 35, 30, 0.3);
    padding-top: 3px;
    text-align: center;
}

.monster-info-stat span {
    font-weight: bold;
    color: #2d231e;
}

.monster-info-descripcio {
    margin-top: 12px;
    border-top: 1px solid #2d231e;
    padding-top: 4px;
}

.monster-info-descripcio span {
    font-style: italic;
    color: #6d5445;
    font-size: 0.85em;
    display: block;
    text-align: center;
    width: 100%;
}

.iniciativa-actions {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    justify-content: center;
    align-items: center;
}

.iniciativa-action-btn {
    font-size: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background: transparent;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    padding: 0;
    transition: transform 0.2s ease, filter 0.2s ease, background-color 0.2s ease;
    margin-bottom: 0 !important;
}

.iniciativa-action-btn:hover {
    transform: scale(1.2) translateY(-2px);
}

.iniciativa-action-btn.mort:hover {
    background-color: rgba(45, 35, 30, 0.15);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.iniciativa-action-btn.resuscitar:hover {
    background-color: rgba(39, 174, 96, 0.2);
    filter: drop-shadow(0 4px 6px rgba(39, 174, 96, 0.5));
}

.iniciativa-action-btn.delete:hover {
    background-color: rgba(192, 57, 43, 0.2);
    filter: drop-shadow(0 4px 6px rgba(192, 57, 43, 0.5));
}

.iniciativa-action-btn:active {
    transform: scale(0.95);
}

/* ==================== INICIATIVA ==================== */
.popup-drag-bar {
    width: 100%;
    height: 28px;
    background: rgba(45, 35, 30, 0.85);
    cursor: grab;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.popup-drag-bar .drag-dots {
    color: rgba(244, 235, 216, 0.5);
    font-size: 12px;
    letter-spacing: 3px;
}

.popup-drag-bar:active {
    cursor: grabbing;
}

.popup-title-iniciativa {
    font-size: 1.2em;
    font-weight: bold;
    color: #8a1c14;
    margin: 3px 0 2px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 4px;
    text-align: center;
}

.popup-type-iniciativa {
    font-style: italic;
    color: #6d5445;
    font-size: 0.85em;
    margin-bottom: 12px;
    border-bottom: 1px solid #2d231e;
    padding-bottom: 4px;
    text-align: center;
}

.init-header,
.init-row {
    font-size: 0.95em;
    border-bottom: 1px dotted #2d231e;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px 92px;
    align-items: center;
    column-gap: 4px;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.15s ease;
    min-height: 32px;
    padding: 2px 4px;
}

.init-header {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6d5445;
    font-weight: bold;
    border-bottom: 1px solid #2d231e;
    padding-top: 4px;
    padding-bottom: 4px;
    cursor: default;
}

.init-header-id,
.init-header-nom,
.init-header-total,
.init-header-actions {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.init-header-nom {
    text-align: left;
}

.init-header-total {
    text-align: left;
    overflow: clip;
    text-overflow: clip;
    cursor: pointer;
}

.init-header-total:hover {
    background-color: rgba(45, 35, 30, 0.15);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.init-header-total:active {
    transform: scale(0.95);
}

.init-header-actions {
    text-align: center;
}

.init-row:hover {
    background-color: rgba(45, 35, 30, 0.08);
}

.init-row.active-turn {
    background-color: rgba(39, 174, 96, 0.25);
    border-left: 3px solid #27ae60;
    padding-left: 6px;
}

.init-row.active-turn:hover {
    background-color: rgba(39, 174, 96, 0.35);
}

.init-player {
    color: #2980b9;
    font-weight: bold;
}

.init-enemy {
    color: #c0392b;
    font-weight: bold;
}

.init-row .iniciativa-actions {
    margin: 0 !important;
    gap: 2px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.init-row .iniciativa-action-btn {
    font-size: 18px !important;
    width: 30px !important;
    height: 30px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.init-row .iniciativa-action-btn.reorder {
    cursor: grab;
    opacity: 0.8;
    color: #6d5445;
}

.init-row .iniciativa-action-btn.reorder:hover {
    background-color: rgba(45, 35, 30, 0.08);
    opacity: 1;
}

.init-row.dragging-row {
    opacity: 0.65;
}

.init-row.drop-target {
    background-color: rgba(39, 174, 96, 0.12);
}

.init-id-cell,
.init-name-cell,
.init-total-cell {
    display: flex;
    align-items: center;
    min-height: 30px;
    text-align: left;
}

.init-id-cell {
    font-size: 0.72em;
    opacity: 0.75;
    white-space: nowrap;
    justify-content: flex-start;
    padding-right: 0;
}

.init-name-cell {
    min-width: 0;
    flex: 1;
    justify-content: flex-start;
    gap: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.init-name-cell small {
    opacity: 0.8;
    font-size: 0.78em;
    white-space: nowrap;
}

.init-total-cell {
    justify-content: center;
    font-weight: bold;
    text-align: center;
}

.init-row-actions {
    justify-content: flex-end;
    min-width: 64px;
}

.popup-content,
#minimap-canvas {
    background-image: radial-gradient(rgba(120, 90, 60, 0.05) 1px, transparent 0);
    background-size: 4px 4px;
}

/* ==================== MENÚ CONTEXTUAL ==================== */
#custom-context-menu {
    display: none;
    position: fixed;
    z-index: 10000;
    min-width: 140px;
    background: #222;
    color: #f4ebd8;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
    font-family: Arial, sans-serif;
    font-size: 13px;
}

.ctx-item {
    padding: 8px;
    cursor: pointer;
}

.ctx-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ctx-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 120px;
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    z-index: 10001;
}

.ctx-submenu.show {
    display: block;
}

.ctx-marker-palette {
    position: fixed;
    background: transparent;
    z-index: 11000;
}

.ctx-marker-wrap {
    display: grid;
    grid-template-columns: repeat(5, 34px);
    gap: 6px;
    padding: 8px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.ctx-marker-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ctx-clear-btn {
    grid-column: 1 / span 5;
    width: 100%;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    padding: 0 8px;
}

/* ==================== MINIMAPA ==================== */

#minimap-panel {
    position: fixed;
    right: 20px;
    top: 70px;
    width: 220px;

    /* Estil idèntic a #initiative-popup */
    background: #f4ebd8;
    color: #2d231e;
    font-family: 'Georgia', serif;
    border: 2px solid #2d231e;
    border-radius: 4px;
    box-shadow: 5px 5px 0px rgba(45, 35, 30, 0.3), 0 10px 25px rgba(0, 0, 0, 0.5);

    z-index: 1000;
    overflow: hidden;
    display: none;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    user-select: none;
}

#popup-header:active {
    cursor: grabbing;
}

#popup-header {
    margin-right: auto;
}

#minimap-canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #f4ebd8;
    box-sizing: border-box;
}

#minimap-toggle {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #2980b9;
    cursor: pointer;
}

/* ==================== FEEDBACK ==================== */
.popup-feedback {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

#popup-feedback {
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}

#popup-feedback img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#popup-feedback:hover {
    opacity: 0.88;
    transform: scale(1.1);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5));
}

#popup-feedback:active {
    opacity: 0.7;
    transform: scale(0.93);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

#popup-feedback:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* ---------- Modal de feedback ---------- */
#feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    animation: feedbackFadeIn 0.18s ease;
}

@keyframes feedbackFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#feedback-modal {
    background: #1e1b18;
    border: 1px solid #3d3530;
    border-radius: 12px;
    padding: 28px 32px 24px;
    width: min(520px, 92vw);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: feedbackSlideUp 0.2s ease;
}

@keyframes feedbackSlideUp {
    from {
        transform: translateY(18px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#feedback-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #d4a359;
    font-family: Arial, sans-serif;
}

#feedback-modal-desc {
    margin: 0;
    font-size: 0.85rem;
    color: #8a8078;
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

#feedback-textarea {
    width: 100%;
    box-sizing: border-box;
    background: #141210;
    border: 1px solid #3d3530;
    border-radius: 8px;
    color: #d9d2ca;
    font-family: Arial, sans-serif;
    font-size: 0.92rem;
    padding: 12px 14px;
    resize: vertical;
    min-height: 110px;
    outline: none;
    transition: border-color 0.15s;
}

#feedback-textarea:focus {
    border-color: #c28e38;
}

#feedback-textarea::placeholder {
    color: #4d4742;
}

#feedback-char-count {
    text-align: right;
    font-size: 0.75rem;
    color: #5a544e;
    font-family: Arial, sans-serif;
    margin-top: -8px;
}

#feedback-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

#feedback-btn-cancel {
    padding: 9px 20px;
    border: 1px solid #3d3530;
    border-radius: 7px;
    background: transparent;
    color: #8a8078;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background 0.15s, color 0.15s;
}

#feedback-btn-cancel:hover {
    background: #2a2420;
    color: #c9c3bc;
}

#feedback-btn-send {
    padding: 9px 22px;
    border: none;
    border-radius: 7px;
    background: #c28e38;
    color: #1a1410;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background 0.15s, transform 0.1s;
}

#feedback-btn-send:hover:not(:disabled) {
    background: #d9a84e;
    transform: scale(1.03);
}

#feedback-btn-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#feedback-status {
    font-size: 0.83rem;
    font-family: Arial, sans-serif;
    min-height: 1.2em;
    text-align: center;
}

.feedback-status-ok {
    color: #6dbf7e;
}

.feedback-status-error {
    color: #e07070;
}

/* ==================== LANDING ==================== */
.page-landing {
    background: #111;
    color: #eee;
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    overflow-y: auto;
}

.landing-container {
    text-align: center;
    padding: 20px;
}

.landing-title {
    font-size: 3em;
    color: #d4a359;
    margin: 0 0 10px 0;
    letter-spacing: 2px;
}

.landing-logo {
    display: block;
    width: 273px;
    height: auto;
    margin: 0 auto 15px;
}

.landing-subtitle {
    color: #888;
    margin-bottom: 40px;
}

.landing-cards {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.landing-card {
    width: 220px;
    padding: 30px 20px;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 10px;
    text-decoration: none;
    color: #eee;
    transition: all 0.2s;
}

.landing-card:hover {
    border-color: #d4a359;
    transform: translateY(-4px);
}

.landing-card-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.landing-card-icon img {
    width: 94px;
    height: 94px;
    object-fit: contain;
    display: block;
    margin: 10px auto;
}

.landing-card-title {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 6px;
}

.landing-card-desc {
    color: #888;
    font-size: 0.85em;
}

/* ==================== LOGIN / DASHBOARD ==================== */
.login-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    z-index: 100;
}

.login-box {
    background: #1a1a1a;
    padding: 40px 30px;
    border-radius: 10px;
    border: 1px solid #333;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.login-title {
    color: #d4a359;
    text-align: center;
    margin: 0 0 6px 0;
    font-size: 1.8em;
    letter-spacing: 1px;
}

.login-subtitle {
    text-align: center;
    color: #888;
    margin: 0 0 25px 0;
    font-size: 0.9em;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    color: #bbb;
    margin-bottom: 4px;
    font-size: 0.85em;
}

.login-form input {
    width: 100%;
}

.login-error {
    color: #e74c3c;
    font-size: 0.85em;
    min-height: 20px;
    margin-bottom: 8px;
}

.login-back {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: #666;
    text-decoration: none;
    font-size: 0.85em;
}

.login-back:hover {
    color: #d4a359;
}

#dm-password,
#player-password {
    -webkit-text-security: disc;
}



.tab-title-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
}

/* ==================== VISTA PLAYER ==================== */

.pm-title-icon {
    font-size: 1.1em;
    margin-right: 6px;
    vertical-align: middle;
    display: inline-flex;
}

.pm-title-icon img {
    height: 40px;
}

h3#pm-title-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Barra superior del player */
.player-room-name {
    color: #d4a359;
    font-size: 1em;
}



/* ==================== GESTIÓ DE JUGADORS ==================== */
:root {
    --pm-bg: #1e1b18;
    --pm-bg-deep: #141210;
    --pm-bg-raised: #2a2420;
    --pm-line: rgba(212, 163, 89, 0.35);
    --pm-text: #f4ebd8;
    --pm-muted: #a89f91;
    --pm-gold: #d4a359;
    --pm-danger: #e74c3c;
    --pm-gap: 12px;
    --pm-pad: 20px;
    --pm-icon: 80px;
}


#player-manage-overlay {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1600;
    align-items: center;
    justify-content: center;
    animation: pm-fade 0.18s ease;
}

@keyframes pm-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#player-manage-ui {
    width: 520px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    background: var(--pm-bg);
    border: 1px solid var(--pm-line);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #eee;
    font-family: Arial, sans-serif;
    animation: pm-slide 0.2s ease;
}

@keyframes pm-slide {
    from {
        transform: translateY(14px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#player-manage-ui .pm-header,
.dm-tab-panel .pm-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 56px;
    border-bottom: 1px solid var(--pm-line);
    flex-shrink: 0;
}

#player-manage-ui .pm-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    text-align: center;
}

#player-manage-ui .pm-header h3,
.dm-tab-panel .pm-header h2 {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--pm-gold);
}

.dm-tab-panel .pm-header h2 {
    text-align: center;
}

#player-manage-ui .pm-count {
    font-size: 0.82em;
    color: var(--pm-muted);
}

#player-manage-ui .pm-close-x,
.dm-tab-panel .pm-close-x {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #5f564e;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

#player-manage-ui .pm-close-x:hover,
.dm-tab-panel .pm-close-x:hover {
    color: var(--pm-danger);
    background: rgba(231, 76, 60, 0.12);
}

#player-manage-ui .pm-body {
    padding: 16px var(--pm-pad);
    display: flex;
    flex-direction: column;
    gap: var(--pm-gap);
    min-height: 0;
}

#player-manage-ui .pm-hint {
    margin: 0;
    color: var(--pm-muted);
    font-size: 0.85em;
    line-height: 1.4;
    text-align: center;
}

#player-manage-ui .pm-table {
    background: var(--pm-bg-deep);
    border: 1px solid #2a2420;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: 400px;
    min-height: 0;
    overflow: hidden;
}

#player-manage-ui .pm-thead {
    display: grid;
    grid-template-columns: var(--pm-icon) 1fr 92px auto;
    column-gap: var(--pm-gap);
    align-items: center;
    padding: 9px 14px;
    background: var(--pm-bg);
    border-bottom: 1px solid var(--pm-line);
    font-size: 0.8em;
    font-weight: 700;
    color: var(--pm-muted);
    flex: 0 0 auto;
}

#player-manage-ui .pm-thead span {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
}

#player-manage-ui .pm-thead span:last-child {
    min-width: 32px;
}

#player-manage-ui .pm-rows {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 0;
}

#player-manage-ui .pm-row {
    display: grid;
    grid-template-columns: var(--pm-icon) 1fr 92px auto;
    column-gap: var(--pm-gap);
    align-items: center;
    padding: 12px 14px;
    box-sizing: border-box;
    min-height: 0;
    margin: 0;
    flex: 0 0 auto;
    transition: background 0.15s ease;
}

#player-manage-ui .pm-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

#player-manage-ui .pm-row+.pm-row {
    border-top: 1px solid rgba(61, 53, 48, 0.4);
}

#player-manage-ui .pm-row.pm-new {
    animation: pm-new 1.2s ease;
}

@keyframes pm-new {

    0%,
    40% {
        background: rgba(212, 163, 89, 0.22);
    }

    100% {
        background: transparent;
    }
}

#player-manage-ui .pm-row>*,
#player-manage-ui .pm-thead>* {
    align-self: center;
    margin: 0;
}

#player-manage-ui .pm-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--pm-muted);
    font-size: 0.9em;
    line-height: 1.5;
}

/* ---------- Icona ---------- */
#player-manage-ui .pm-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--pm-icon);
    height: var(--pm-icon);
    margin: 0;
    box-sizing: border-box;
}

#player-manage-ui .pm-icon-btn {
    position: relative;
    width: var(--pm-icon);
    height: var(--pm-icon);
    padding: 4px;
    background: var(--pm-bg-raised);
    border: 2px solid #8b7355;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    color: var(--pm-muted);
    font-size: 0.8em;
    transition: border-color 0.2s, transform 0.15s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    margin: 0;
    align-self: center;
    flex-shrink: 0;
}

#player-manage-ui .pm-icon-btn:hover,
#player-manage-ui .pm-icon-btn:focus-visible {
    border-color: var(--pm-gold);
    transform: scale(1.06);
    outline: none;
}

#player-manage-ui .pm-icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    pointer-events: none;
}

/* ---------- Desplegable d'icones ---------- */
#player-manage-ui .pm-icon-menu {
    position: fixed;
    background: #f4ebd8;
    border: 2px solid #8b7355;
    border-radius: 10px;
    padding: 12px;
    display: none;
    z-index: 9999;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    gap: 8px;
    width: min(calc(100vw - 20px), 560px);
    max-height: 70vh;
    overflow-y: auto;
}

#player-manage-ui .pm-icon-menu.show {
    display: grid;
    grid-template-columns: repeat(auto-fill, 96px);
    justify-content: center;
}

#player-manage-ui .pm-icon-opt {
    width: 96px;
    height: 96px;
    box-sizing: border-box;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    background: rgba(139, 115, 85, 0.08);
    color: #5a4630;
    font-size: 0.75em;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

#player-manage-ui .pm-icon-opt:hover {
    background: rgba(139, 115, 85, 0.28);
    border-color: rgba(211, 84, 0, 0.45);
    transform: translateY(-2px);
}

#player-manage-ui .pm-icon-opt.selected {
    background: rgba(212, 83, 0, 0.18);
    border-color: #d35400;
    box-shadow: 0 0 12px rgba(211, 84, 0, 0.4);
}

#player-manage-ui .pm-icon-opt img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ---------- Nom ---------- */
#player-manage-ui .pm-name {
    display: block;
    width: 100%;
    min-width: 0;
    height: 33px;
    padding: 0 12px;
    background: #1a1714;
    border: 1px solid var(--pm-line);
    color: var(--pm-text);
    border-radius: 6px;
    font-size: 1.05em;
    font-weight: 700;
    text-align: center;
    box-sizing: border-box;
    font-family: inherit;
    line-height: normal;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#player-manage-ui .pm-name:focus {
    outline: none;
    border-color: var(--pm-gold);
    box-shadow: 0 0 0 2px rgba(212, 163, 89, 0.2);
}

#player-manage-ui .pm-name.pm-invalid {
    border-color: var(--pm-danger);
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.25);
}

/* ---------- DEX amb fletxes amunt / avall ---------- */
.stepper-wrap {
    display: flex;
    align-items: stretch;
    height: 33px;
    box-sizing: border-box;
    border: 1px solid var(--pm-line);
    border-radius: 6px;
    overflow: hidden;
    -background: #1a1714;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.stepper-wrap:focus-within {
    border-color: var(--pm-gold);
    box-shadow: 0 0 0 2px rgba(212, 163, 89, 0.2);
}

.stepper-btn-wrap {
    display: flex;
    flex-direction: column;
    width: 28px;
    flex-shrink: 0;
    border-left: 1px solid var(--pm-line);
}

.stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    max-width: none;
    background: #2a2420;
    border: none;
    border-radius: 4px;
    color: #d4a359;
    font-size: 10px;
    font-weight: bold;
    font-family: inherit;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: background 0.15s;
    border-top: 1px solid #3d3530;
}

.stepper-btn:hover {
    background: #3a3029;
}

.stepper-btn:active {
    background: #4a3d33;
}

.stepper-btn:focus-visible {
    outline: 2px solid #d4a359;
    outline-offset: 2px;
}

.stepper-input {
    display: block;
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    text-align: center;
    box-sizing: border-box;
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    color: #f4ebd8;
    font-size: 1.05em;
    font-weight: 700;
    font-family: inherit;
    line-height: normal;
    appearance: textfield;
    -moz-appearance: textfield;
}

.stepper-input:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Eliminar (dos tocs) ---------- */
#player-manage-ui .pm-delete-x {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: transparent;
    border: none;
    color: #a05a4e;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

#player-manage-ui .pm-delete-x:hover {
    color: #fff;
    background: #c0392b;
}

#player-manage-ui .pm-delete-x.armed {
    color: #fff;
    background: #c0392b;
    font-size: 12px;
}

/* ---------- Missatge d'estat ---------- */
#player-manage-ui .pm-msg {
    margin: 0;
    font-size: 0.82em;
    color: var(--pm-danger);
    text-align: center;
}

#player-manage-ui .pm-msg:empty {
    display: none;
}

/* ---------- Peu ---------- */
#player-manage-ui .pm-footer {
    display: flex;
    gap: var(--pm-gap);
    padding: 14px var(--pm-pad);
    border-top: 1px solid var(--pm-line);
    flex-shrink: 0;
}

#player-manage-ui .pm-footer button {
    padding: 11px 14px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.92em;
    font-weight: 700;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s, transform 0.1s;
}

#player-manage-ui .pm-btn-secondary {
    flex: 1;
    background: transparent;
    border: 1px solid var(--pm-gold);
    color: var(--pm-gold);
}

#player-manage-ui .pm-btn-secondary:hover {
    background: rgba(212, 163, 89, 0.12);
}

#player-manage-ui .pm-btn-primary {
    flex: 0 0 120px;
    background: #c28e38;
    border: none;
    color: #1a1410;
}

#player-manage-ui .pm-btn-primary:hover {
    background: #d9a84e;
}

/* ---------- Aïllament d'estils globals ---------- */
#player-manage-ui button,
#player-manage-ui input {
    margin: 0;
    min-width: 0;
    min-height: 0;
    max-width: none;
    text-transform: none;
    letter-spacing: normal;
    box-sizing: border-box;
}

#player-manage-ui button:focus-visible {
    outline: 2px solid var(--pm-gold);
    outline-offset: 2px;
}



/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    #player-manage-ui {
        --pm-icon: 64px;
        --pm-gap: 8px;
        --pm-pad: 14px;
    }

    #player-manage-ui .pm-thead,
    #player-manage-ui .pm-row {
        grid-template-columns: var(--pm-icon) 1fr 84px auto;
        padding-left: 10px;
        padding-right: 10px;
    }

    #player-manage-ui .stepper-btn-wrap {
        width: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {

    #player-manage-overlay,
    #player-manage-ui,
    #player-manage-ui .pm-row.pm-new {
        animation: none;
    }
}

/* ==================== INPUTS ==================== */

input,
textarea,
select {
    width: 100%;
    padding: 9px 12px;
    background: var(--pm-bg-deep);
    border: 1px solid var(--pm-line);
    color: var(--pm-text);
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 0.92em;
    transition: border-color 0.15s, box-shadow 0.15s;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4a359' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}


input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--pm-gold);
    box-shadow: 0 0 0 2px rgba(212, 163, 89, 0.2);
}

/* ---------- Drag bar amb botons dins ---------- */
.popup-drag-bar--with-actions {
    position: relative;
    justify-content: center;
}

.popup-drag-bar--with-actions .drag-dots {
    pointer-events: none;
}

.popup-drag-actions {
    position: absolute;
    right: 6px;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
}

.popup-drag-actions .popup-share-btn,
.popup-drag-actions .popup-x-btn {
    position: static;
    width: 28px;
    height: 28px;
    font-size: 25px;
    line-height: 1;
    background: transparent;
    color: rgba(244, 235, 216, 0.5);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
    margin: 0px 0 0 0;
    font-family: Tahoma, sans-serif;
    font-weight: bold;
}

.popup-drag-actions .popup-x-btn {
    padding: 0 0 4px 0;
}

.popup-drag-actions .popup-share-btn img {
    width: 25px;
    height: 25px;
    object-fit: contain;
    pointer-events: none;
    padding: 0;
    margin: 0px 0 0 0;
}

.popup-drag-actions .popup-x-btn:hover {
    color: #db4343;
    transform: scale(1.08);
}

.popup-drag-actions .popup-share-btn:hover {
    background: rgba(212, 163, 89, 0.5);
    transform: scale(1.08);
}

.popup-drag-actions .popup-share-btn.active {
    background: #1e8449;
    color: #d4a359;
    color: #fff;
}

.popup-drag-actions .popup-share-btn.active:hover {
    background: #2ecc71;
    border-color: #2ecc71;
    transform: scale(1.08);
}

/* ==================== INICIATIVA: CAPÇALERA AMB BOTÓ DE RETIRADA ==================== */
.popup-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    margin-bottom: 2px;
}

.popup-title-row .popup-title-iniciativa {
    margin: 0;
    padding: 0;
}

.popup-title-spacer {
    width: 28px;
    flex-shrink: 0;
}

.popup-retrow-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #8a1c14;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.popup-retrow-btn:hover {
    background: rgba(138, 28, 20, 0.15);
    transform: scale(1.1);
}

/* ==================== MOURE JUGADORS ==================== */

/* Llista de checkboxes */
#move-players-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0 12px 0;
    max-height: 40vh;
    overflow-y: auto;
}

.move-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 0.95em;
    padding: 0 0 0 85px;
}

.move-player-row:hover {
    background: rgba(45, 35, 30, 0.08);
}

.move-player-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #8a1c14;
}

.move-player-row img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 50%;
    background: rgba(45, 35, 30, 0.08);
    flex-shrink: 0;
}

.move-player-row span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

}

/* Botons d'acció */
.move-players-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    background: #4A413A;
    padding: 8px;
}

.move-players-actions .btn-primary {
    flex: 1;
    margin: 0;
    font-size: 0.9em;
    padding: 3px 7px 3px 7px;
}

.move-players-actions .btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: black;
    color: #8a8078;
    border: 1px solid !important;
    border-color: #3d3530;
}