:root {
    --accent: #FFB46A;
    --accent-soft: #FFE27A;
    --text-main: #1F4E66;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 10px;
    background: transparent;
    font-family: Arial, sans-serif;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* ----------- BARRA CONTROLLI COMPATTA ----------- */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.5);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    
    width: 100%;
}

.controls-group {
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 11px;
    flex-wrap: wrap;
}

select, input[type="file"], input[type="text"] {
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 6px;
    border: 2px solid var(--accent-soft);
    background: #fff;
}

.btn {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: var(--accent);
    font-weight: bold;
    color: var(--text-main);
    box-shadow: 0 0 8px rgba(0,0,0,0.1);
}

.btn-small {
    padding: 3px 6px;
    font-size: 10px;
    border-radius: 999px;
    background: var(--accent);
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

/* Bottoni PV & wrapper */
.btn-hp {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    font-size: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    cursor: pointer;

    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s;
}

.hp-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: 12px;
}

.hp-label {
    font-weight: bold;
}

/* Session status */
.session-status {
    font-size: 11px;
    opacity: 0.8;
}

/* Mantieni tutti i controlli in linea per il blocco "Codice partita" */
#sessionControls {
    flex-wrap: nowrap;
}

/* ----------- TOP SECTION: 3 COLONNE ----------- */
.top-section {
    width: 100%;
    
    display: flex;
    justify-content: center;
    gap: 14px;
    align-items: flex-start;
}

.top-col {
    width: 400px;
    display: flex;
    justify-content: center;
}

/* MAPPA */
.map-outer {
    width: 400px;
    display: flex;
    justify-content: center;
}

.map-container {
    width: 350px;
    height: 225px;
    max-height: 225px;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.map-container.empty {
    background: transparent;
    box-shadow: none;
}

.map-container:not(.empty) {
    background: rgba(255,255,255,0.15);
    box-shadow: var(--card-shadow);
}

.map-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ----------- CARD GIOCATORE ----------- */
.player-card {
    width: 400px;
    height: 225px;
    background: var(--card-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    position: relative;
    display: flex;
    flex-direction: column;
}

.player-card.dead {
    box-shadow: 0 0 0 3px red, 0 6px 18px rgba(0,0,0,0.18);
    background: black;
}

/* AREA WEBCAM */
.avatar-area {
    flex: 1;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.4);
    position: relative;
}

/* CORNICE ANGOLO WEBCAM */
.cam-frame {
    position: absolute;
    top: 4px;
    left: 8px;
    right: 88px;
    bottom: 4px;
    pointer-events: none;
}

.cam-corner {
    position: absolute;
    width: 32px;
    height: 32px;
    border: 3px solid #FFB46A;
}

.cam-corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.cam-corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.cam-corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.cam-corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }

/* ICONE PERSONAGGIO */
.player-icon {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    border: 2px solid var(--accent);
    position: absolute;
    bottom: 8px;
    right: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 0 7px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 2;
}

.player-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* FOOTER CARD */
.player-footer {
    background: rgba(255,255,255,0.85);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dice-row {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-wrap: nowrap;
}

.dice-row select {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    border: 2px solid var(--accent-soft);
    background: #fff;
}

.result-row {
    font-size: 13px;
}

.critico-positivo {
    color: #2ecc71; /* verde */
    font-weight: bold;
}

.critico-negativo {
    color: #e74c3c; /* rosso */
    font-weight: bold;
}

.result-row span {
    font-weight: bold;
}

.dice-icon {
    font-size: 20px;
}

.rolling {
    animation: rollDice 0.45s ease;
}

@keyframes rollDice {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(20deg); }
    60% { transform: rotate(-20deg); }
    100% { transform: rotate(0deg); }
}

/* DISPOSIZIONE GIOCATORI */
.players-section {
    width: 100%;
    
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.players-row {
    display: flex;
    justify-content: center;
    gap: 14px;
}

/* ---- OGGETTI ---- */
.oggetti-box {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 120px;
    height: 56px;
    resize: none;
    font-size: 12px;
    font-family: Arial, sans-serif;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    border: 2px dashed var(--accent-soft);
    overflow: hidden;
}


.td-wrapper input:checked + span {
    color: #e74c3c;
    text-decoration: line-through;
}

/* ---- LARGHEZZA CARD ---- */
.player-card,
.top-col,
.map-outer {
    width: 460px;
}

.cam-frame { right: 150px; }
.map-container { width: 410px; }


.trait {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: bold;
}

.trait input {
  cursor: pointer;
}


.logo-area{
  display:flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px;
}

.logo-img{
  width: 120px;
  margin-top: 10px;
}

.powered-by{
  font-size: 11px;
  margin-top: 4px;
}

/* ---- ROUND IMAGE UPLOAD ---- */
.round-upload {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px dashed var(--accent-soft);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: 0.2s;
}

.round-upload:hover {
  background: rgba(255,255,255,0.85);
}

.round-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.upload-plus {
  font-size: 32px;
  font-weight: bold;
  color: var(--text-main);
  pointer-events: none;
}

.round-upload input {
  display: none;
}

#logoUploadCell {
   padding-left: 80px;
   text-align: right;
}


.player-card.td-used {
    box-shadow:
        0 0 0 3px #9B5CFF,
        0 0 16px #9B5CFF,
        0 0 28px rgba(155,92,255,0.8),
        0 6px 18px rgba(0,0,0,0.18);
}

/* TD uguale ai PV */
.td-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 12px;
}

.td-counter .btn-hp {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    font-size: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    cursor: pointer;

    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s;
}

.td-counter .td-value {
  font-weight: bold;
  min-width: 18px;
  text-align: center;
}

/* ===== v1.4.2 layout card pulito ===== */
.stats-panel {
    position: absolute;
    top: 74px;
    right: 10px;
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.stats-panel .hp-wrapper {
    display: grid;
    grid-template-columns: 24px 22px 28px 22px;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.stats-panel .hp-label {
    text-align: left;
    font-weight: bold;
}

.dice-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.dice-row select {
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 6px;
    border: 2px solid var(--accent-soft);
    background: #fff;
}

.dice-tag {
    font-size: 12px;
    font-weight: bold;
}

.player-footer {
    background: rgba(255,255,255,0.85);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-row {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hp-value {
    text-align: center;
    font-weight: bold;
    font-size: 13px;
}


/* ===== animazioni critici ===== */
.critico-positivo {
    color: #2ecc71;
    font-weight: bold;
    animation: criticoPop 0.35s ease;
}

.critico-negativo {
    color: #e74c3c;
    font-weight: bold;
    animation: criticoShake 0.35s ease;
}

@keyframes criticoPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes criticoShake {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-3px); }
    50%  { transform: translateX(3px); }
    75%  { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

.btn-hp {
    width: 24px;
    height: 24px;
    padding: 0;

    border-radius: 999px;
    font-size: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f6d77a; /* 👈 giallo morbido */
    color: #333;

    border: none;
    cursor: pointer;

    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: all 0.1s ease;
}

.btn-hp:hover {
    transform: scale(1.08);
    background: #f2cc5c;
}

.btn-hp:active {
    transform: scale(0.92);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
/* label PV/TD rinominabili */
.editable-label {
    cursor: pointer;
    border-bottom: 1px dashed rgba(0,0,0,0.25);
    padding: 0 2px;
}

.editable-label:hover {
    border-bottom-color: rgba(0,0,0,0.5);
}

.label-input {
    width: 44px;
    font-size: 12px;
    text-align: center;
    border: 1px solid var(--accent-soft);
    border-radius: 6px;
    padding: 1px 3px;
    background: #fff;
    color: var(--text-main);
}
.master-notes {
    height: 120px;
}

/* ===== terzo contatore giocatori v1.7.1 ===== */

/* Riduce leggermente solo gli appunti dei giocatori, non quelli del master */
.player-card:not([data-role="master"]) .oggetti-box {
    height: 46px;
}

/* Un filo più compatto per ospitare tre righe */
.stats-panel {
    top: 62px;
    gap: 4px;
}

.stats-panel .hp-wrapper {
    gap: 3px;
}

/* Stato a zero del terzo contatore */
.player-card.extra-used {
    box-shadow:
        0 0 0 3px #00C2FF,
        0 0 16px #00C2FF,
        0 0 28px rgba(0,194,255,0.75),
        0 6px 18px rgba(0,0,0,0.18);
}

/* ===== voce + webcam nativa WebRTC dentro ogni riquadro v1.9.11 =====
   Nessun servizio esterno incorporato: il video rimane confinato nello spazio webcam della card. */
.card-voice-slot {
    position: absolute;
    top: 4px;
    left: 8px;
    right: 142px;
    bottom: 4px;
    z-index: 5;
    display: block;
    border-radius: 10px;
    overflow: hidden;
    background: transparent;
    pointer-events: none;
}

.card-voice-slot.active {
    background: #111;
    pointer-events: auto;
}

.card-voice-slot.voice-slot-current {
    box-shadow: inset 0 0 0 2px rgba(0, 194, 255, 0.85);
}

.card-voice-placeholder {
    display: none;
}

.voice-video-grid {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    grid-auto-rows: minmax(58px, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
    padding: 0;
    background: #111;
}

.voice-tile {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #111;
}

.voice-tile video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    background: #000;
}

.voice-tile.audio-only video {
    opacity: 0;
}

.voice-audio-avatar {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    background: radial-gradient(circle at center, rgba(255,255,255,0.22), rgba(0,0,0,0.72));
    text-shadow: 0 2px 6px rgba(0,0,0,0.85);
    pointer-events: none;
}

.voice-tile.audio-only .voice-audio-avatar {
    display: flex;
}

.voice-name {
    position: absolute;
    left: 5px;
    right: 5px;
    bottom: 4px;
    z-index: 3;
    padding: 2px 5px;
    border-radius: 999px;
    font-size: 10px;
    line-height: 1.1;
    color: #fff;
    background: rgba(0,0,0,0.55);
    text-shadow: 0 1px 2px rgba(0,0,0,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.card-voice-status {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 38px;
    z-index: 30;
    min-height: 0;
    font-size: 10px;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.85);
    pointer-events: none;
}

.card-voice-slot:not(.active) .card-voice-status {
    display: none;
}

.card-voice-status:empty {
    display: none;
}

.card-voice-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 4px;
    pointer-events: auto;
}

.voice-actions-toggle {
    min-width: 30px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(2px);
}

.card-voice-actions.call-active .voice-actions-toggle {
    background: #d7f7d7;
}

.card-voice-actions.mic-muted .voice-actions-toggle,
.card-voice-actions.camera-muted .voice-actions-toggle {
    background: #ffd1d1;
}

.card-voice-actions.call-starting .voice-actions-toggle {
    background: #fff2bd;
}

.voice-actions-menu {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    max-width: 245px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.78);
    backdrop-filter: blur(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.card-voice-actions.open .voice-actions-menu {
    display: flex;
}

.card-voice-actions .btn-small:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.card-voice-actions .mute-card-voice-btn.muted,
.card-voice-actions .camera-card-voice-btn.muted {
    background: #ffd1d1;
}

/* Mantiene intatti dimensioni e proporzioni della card anche con chiamata attiva. */
.player-card.voice-call-active {
    width: 460px;
    height: 225px;
}

.player-card.voice-call-active .avatar-area {
    min-height: 0;
}

.player-card.voice-call-active .card-voice-slot {
    top: 4px;
    left: 8px;
    right: 142px;
    bottom: 4px;
}

.player-card.voice-call-active .player-footer {
    padding-top: 4px;
    padding-bottom: 4px;
    gap: 2px;
}

/* La cornice e i controlli della scheda restano sopra al video, ma senza modificare il layout. */
.cam-frame {
    z-index: 7;
}

.oggetti-box,
.stats-panel {
    z-index: 8;
}

.player-icon {
    z-index: 9;
}



/* ===== micro-fix webcam v1.9.11 =====
   Il riquadro video usa quasi tutta l'area superiore della card,
   lasciando comunque liberi i controlli dadi nel footer. */
