:root {
  --color-background: #120627;
  --color-text: #ffffff;
  --color-text-muted: rgba(255, 255, 255, 0.7);
  --color-text-soft: rgba(255, 255, 255, 0.5);

  --color-primary: #9b30ff;
  --color-primary-dark: #6a0dad;
  --color-primary-light: #b96cff;

  --color-topbar-campaign-start: #120627;
  --color-topbar-campaign-end: #1e0a35;
  --gradient-topbar-campaign: linear-gradient(135deg, var(--color-topbar-campaign-start), var(--color-topbar-campaign-end));

  --color-primary-hover: rgba(155, 48, 255, 0.12);
  --color-primary-border: rgba(155, 48, 255, 0.4);
  --color-primary-shadow: rgba(155, 48, 255, 0.25);

  --color-primary-active: rgba(155, 48, 255, 0.18);
  --color-primary-active-border: rgba(155, 48, 255, 0.5);
  --color-primary-active-shadow: rgba(155, 48, 255, 0.4);

  --color-surface: rgba(255, 255, 255, 0.05);
  --color-surface-hover: rgba(255, 255, 255, 0.08);
  --color-surface-strong: rgba(255, 255, 255, 0.12);

  --color-profile-surface: rgba(255, 255, 255, 0.08);
  --color-profile-surface-hover: rgba(255, 255, 255, 0.12);
  --color-profile-border: rgba(255, 255, 255, 0.15);

  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-strong: rgba(255, 255, 255, 0.2);

  --color-danger: #ff4d6d;
  --color-danger-dark: #b3003c;
  --color-success: #2ecc71;
  --color-success-dark: #1e9e57;
  --gradient-success: linear-gradient(135deg, var(--color-success), var(--color-success), var(--color-success-dark));


  --gradient-primary: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  --gradient-danger: linear-gradient(135deg, var(--color-danger), var(--color-danger-dark));

  --shadow-card: 0 0 15px rgba(0, 0, 0, 0.3);
  --shadow-button: 0 4px 10px rgba(0, 0, 0, 0.3);
  --shadow-top-bar: 0 2px 5px rgba(0, 0, 0, 0.3);
  --shadow-toast: 0 0 15px rgba(0, 0, 0, 0.4);
  --shadow-primary-hover: 0 4px 12px var(--color-primary-shadow);
  --shadow-primary-active: 0 0 15px var(--color-primary-active-shadow);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 15px;
  --radius-pill: 20px;

  --blur-glass: blur(6px);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 20px;
  --space-xl: 32px;

  /* Layout responsivo */
  --app-vh: 1vh;                /* recalculado pelo JS no celular */
  --app-padding: 20px;
  --tap-target: 44px;           /* area minima de toque */
  --panel-left: 300px;
  --panel-right: 320px;
  --sidebar-width: 260px;
  --map-sidebar-width: 190px;

  --color-ammo: #9a9a9a;
  --color-ammo-empty: #3a3a3a;
  --color-life: #ff4d6d;
  --color-life-track: #7a1f2e;
  --color-stamina: #ff9500;
  --color-stamina-track: #7a4a00;
  --color-special: #ffd60a;
  --color-special-track: #7a6d00;
  --color-fe-start: #ffffff;
  --color-fe-end: #3a8fdd;
  --color-honra-start: #e63946;
  --color-honra-mid: #9a9a9a;
  --color-honra-end: #ffffff;
  --color-icon-hover: rgba(255, 255, 255, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}


html,
body {
  width: 100%;
  height: 100%;
}

body {
  /* 100vh no celular conta a barra do navegador; --app-vh vem do JS. */
  min-height: calc(var(--app-vh, 1vh) * 100);
  background-color: var(--color-background);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Sem rolagem no fundo enquanto um modal ou a gaveta estao abertos. */
body.modal-open,
body.drawer-open {
  overflow: hidden;
}

img,
video {
  max-width: 100%;
}

/* Enquanto os fragmentos nao chegam, so a splash aparece. */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  text-align: center;
  background: var(--color-background);
  color: var(--color-text-muted);
}

.app-splash-icon {
  font-size: 40px;
  color: var(--color-primary-light);
}

.app-splash-text {
  font-size: 14px;
}

.app-splash-hint {
  font-size: 12px;
  max-width: 420px;
  color: var(--color-text-soft);
  line-height: 1.5;
}

.app-splash-error .app-splash-icon {
  color: var(--color-danger);
}

.top-bar {
  width: 100%;
  height: 60px;
  flex-shrink: 0;
  background: var(--gradient-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px; 
  box-shadow: var(--shadow-top-bar);
}

.top-bar.dark-mode {
  background: var(--gradient-topbar-campaign);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.menu-icon:hover {
  background: var(--color-icon-hover);
}

.menu-icon:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 20px;
  color: var(--color-text);
  opacity: 0.95;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

.brand-home-button {
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.brand-home-button:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-primary-hover);
}

.brand-home-button:active {
  transform: scale(0.97);
}

.brand-home-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.title {
  font-size: 18px;
  margin: 0;
  color: var(--color-text);
  line-height: 1;
}

.top-right {
  display: flex;
  align-items: center;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-profile-surface);
  border: 1px solid var(--color-profile-border);
  backdrop-filter: var(--blur-glass);
}

.user-profile:hover {
  background: var(--color-profile-surface-hover);
  cursor: pointer; 
}

.user-name {
  font-size: 13px;
  opacity: 0.9;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  object-fit: cover; 
}

.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--panel-left) minmax(0, 1fr) var(--panel-right);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "left middle right"
    "characters soundtrack right";

  padding: var(--app-padding);
  gap: var(--app-padding);
  align-items: stretch;
  align-content: stretch;
  overflow-y: auto;
}

.left-panel {
  grid-area: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 15px;
  align-self: start;
  min-width: 0;
}

.btn {
  padding: 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  background: var(--gradient-primary);
  transition: 0.2s;
  box-shadow: var(--shadow-button);
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-create {
  width: 100%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
}

.create-icon {
  font-size: 28px;
}

.create-desc {
  font-size: 11px;
  opacity: 0.8;
}

.join-panel {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px;
  width: 100%;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
}

.join-label {
  font-size: 13px;
  margin-bottom: 8px;
  display: block;
}

.join-input-row {
  display: flex;
  gap: 8px;
}

.join-input {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-surface-strong);
  color: var(--color-text);
  font-size: 13px;
  outline: none;
}

.join-input::placeholder {
  color: var(--color-text-soft);
}

.btn-enter {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-primary);
  color: var(--color-text);
  cursor: pointer;
}

.invite-error {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-danger);
  opacity: 0.9;
}

.middle-panel {
  grid-area: middle;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch; 
  gap: 20px;
  align-self: start;
}

.btn-maps {
  width: 100%;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center; 
  gap: 5px;
}

.maps-icon {
  font-size: 28px;
}

.maps-desc {
  font-size: 11px;
  opacity: 0.8;
}

.btn-characters {
  grid-area: characters;
  width: 100%;
  height: 100%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
}

.characters-icon {
  font-size: 28px;
}

.characters-desc {
  font-size: 11px;
  opacity: 0.8;
}

.btn-soundtrack {
  grid-area: soundtrack;
  width: 100%;
  height: 100%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
}

.soundtrack-icon {
  font-size: 28px;
}

.soundtrack-desc {
  font-size: 11px;
  opacity: 0.8;
}

.btn-characters:hover, .btn-soundtrack:hover {
  background: var(--color-surface-hover);
  opacity: 1;
}

.right-panel {
  grid-area: right;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.campaign-box {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px; 
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
  display: flex;
  flex-direction: column;
  min-height: 0; 
}

.campaign-box-master {
  flex: 0 0 auto;
}

.campaign-box-player {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.panel-title {
  font-size: 13px;
  opacity: 0.7;
  margin: 10px 0 5px 0;
}

.campaign-section {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 10px;
  border: 1px solid var(--color-border);
}

.campaign {
  display: flex;
  align-items: center; 
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: 0.2s;
}

.campaign:hover {
  background: var(--color-surface-hover);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 30%;
  object-fit: cover;
}

.info {
  display: flex;
  flex-direction: column;
}

.name {
  font-weight: bold;
  font-size: 14px;
}

.details {
  font-size: 12px; 
  opacity: 0.7;
}

/* Popups de aviso: cor e icone por status, canto inferior ou topo.
   Entrada e saida so com animacao de CSS. */

#toast-container,
#toast-container-top {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

#toast-container {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  align-items: flex-end;
}

#toast-container-top {
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

.toast {
  --toast-color: var(--color-danger);

  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--toast-color) 45%, transparent);
  border-left: 3px solid var(--toast-color);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--toast-color) 16%, transparent), transparent 55%),
    #1a0f2e;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-toast);
  cursor: pointer;
  pointer-events: auto;
  animation: toast-in-bottom 0.25s ease;
}

#toast-container-top .toast {
  animation: toast-in-top 0.25s ease;
}

.toast-leaving {
  animation: toast-out 0.25s ease forwards !important;
}

.toast-success { --toast-color: var(--color-success); }
.toast-error   { --toast-color: var(--color-danger); }
.toast-warn    { --toast-color: #ffb020; }
.toast-info    { --toast-color: #3a8fdd; }

.toast-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 15px;
  color: var(--toast-color);
}

.toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toast-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--toast-color);
}

.toast-text {
  overflow-wrap: anywhere;
}

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

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

@keyframes toast-out {
  to { opacity: 0; transform: scale(0.95); }
}

/*Tela de criar campanha*/

.screen {
  display: none;
  flex: 1;
  min-height: 0;
}

.screen.active-screen {
  display: flex;
  flex-direction: column;
}

.create-campaign-layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

/* Botao que abre a lista de sessoes quando ela vira gaveta (tablet/celular). */
.sessions-sidebar-toggle {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-sm) var(--space-md) 0;
  padding: 10px 14px;
  min-height: var(--tap-target);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
}

.sessions-sidebar-toggle:hover {
  background: var(--color-surface-hover);
}

.sessions-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  border-radius: 0;
  padding: 15px;
  display: flex; 
  flex-direction: column;
  gap: 10px;
  box-shadow: none;
  backdrop-filter: var(--blur-glass);
  height: 100%;
  min-height: 0;
}

.sidebar-title {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.sessions-list {
  flex: 1;
  min-height: 0;
  display: flex; 
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.sessions-list::-webkit-scrollbar, .campaign-content::-webkit-scrollbar {
  width: 8px;
}

.sessions-list::webkit-scrollbar-track, .campaign-content::webkit-scrollbar-track {
  background: transparent;
}

.sessions-list::-webkit-scrollbar-thumb, .campaign-content::-webkit-scrollbar-thumb {
  background: var(--color-surface-strong);
  border-radius: var(--radius-pill);
}

.sessions-list::webkit-scrollbar-thumb:hover, .campaign-content::webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.sessions-list, .campaign-content {
  scrollbar-width: thin;
  scrollbar-color: var(--color-surface-strong) transparent;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.session-thumb {
  width: 96px;
  height: 54px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-strong);
}

.session-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.session-title {
  font-size: 13px; 
  font-weight: bold;
}

.session-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: allipsis;
  white-space: nowrap;
}

.session-item:hover {
  background: var(--color-surface-strong);
  border-color:var(--color-border-strong);
}

.session-item-active {
  background: var(--color-primary-active);
  border: 1px solid var(--color-primary-active-border);
  box-shadow: var(--shadow-primary-active);
}

.campaign-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
  padding: 0;
  overflow-y: auto;
}

.campaign-header {
  --campaign-accent-start: #7a0f1f;
  --campaign-accent-end: #d62839;

  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 0;
  background: linear-gradient(135deg, var(--campaign-accent-start), var(--campaign-accent-end));
  box-shadow: var(--shadow-card);
}

.campaign-header-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.campaign-header-icon i {
  font-size: 30px;
  color: var(--color-text);
}

.campaign-header-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.campaign-header-title {
  margin: 0;
  font-size: 28px; 
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.campaign-header-subtitle {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
}

.campaign-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 4px;
}

.campaign-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text);
}

.meta-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

.meta-dot-active {
  background: #5cff72;
  box-shadow: 0 0 8px rgba(92, 255, 114, 0.5);
}

.mestrar-row {
  display: flex;
  justify-content: flex-end;
  padding: 10px 24px 0;
  margin-top: -30px;
}

.btn-mestrar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: var(--gradient-success);
  border: 1px solid var(--color-success-dark);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-button);
}

.btn-mestrar:hover {
  filter: brightness(0.85);
  opacity: 1;
}

.btn-mestrar:active {
  transform: scale(0.96);
}

.btn-mestrar:focus-visible {
  outline: 2px solid var(--color-success);
  outline-offset: 2px;
}

.campaign-sections {
  flex: 1;
  min-height: 0;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 14px;
  color: var(--color-text-muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.management-card { 
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  min-height: 140px;
  display: flex; 
  flex-direction: column;
  gap: 6px; 
  cursor: pointer;
  transition: 0.2s;
}

.management-card:hover {
  background: var(--color-surface-hover);
}

.management-card-icon {
  font-size: 18px;
  color: var(--color-text);
}

.management-card-title {
  font-size: 14px; 
  font-weight: bold;
}

.management-card-desc {
  font-size: 12px; 
  color: var(--color-text-muted);
  flex: 1;
  margin-top: var(--space-sm);
}

.management-card-badge {
  align-self: flex-start; 
  font-size: 11px;
  padding: 3px 8px; 
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border-strong);
  margin-top: var(--space-sm);
}

/*Tela de mestrar*/

.hidden {
  display: none;
}

.mestrar-page {
  flex:1;
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.character-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.character-name {
  font-size: 15px;
  font-weight: bold;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label { 
  width: 55px;
  font-size: 12px; 
  color: var(--color-text-muted);
}

.stat-bar {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
}

.stat-bar-draggable {
  overflow: visible;
  position: relative;
}

.stat-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #111;
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  font-size: 10px;
  color: var(--color-text);
  z-index: 2;
  user-select: none;
}

.stat-handle:active {
  cursor: grabbing;
}

.stat-spacer {
  margin-top: 10px;
}

.stat-value-pct {
  width: 42px;
  font-size: 12px;
  text-align: right;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.pct-input {
  display: none;
  width: 42px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-text-muted);
  color: var(--color-text);
  font-size: 12px;
  text-align: center;
  -moz-appearance: textfield;
}

.pct-input::-webkit-outer-spin-button,
.pct-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.stat-value-pct.editing .pct-text { display: none; }
.stat-value-pct.editing .pct-input { display: inline-block; }

.stat-value {
  width: 40px;
  font-size: 12px;
  text-align: right;
  color: var(--color-text-muted);
  cursor: pointer;
}

.stat-input-current {
  display: none;
  width: 40px;
  background: transparent; 
  border: none;
  border-bottom: 1px solid var(--color-text-muted);
  color: var(--color-text);
  font-size: 12px;
  text-align: center;
  -moz-appearance: textfield;
}

.stat-input-current::-webkit-outer-spin-button, .stat-input-current::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stat-value.editing .stat-text {
  display: none;
}

.stat-value.editing .stat-input-current {
  display: inline-block;
}

.section-title-mini {
  font-size: 12px;
  color: var(--color-text-muted);
  opacity: 0.7;
}

.btn-icon-mini {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.btn-icon-mini:hover {
  color: var(--color-text);
  background: var(--color-icon-hover);
}

.money-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.money-item {
  display: flex;
  align-items: center;
  gap: 6px;
}


/*Tela de mapas*/

.maps-page {
  flex: 1;
  min-height: 0;
  padding: 20px;
  background-color: var(--color-background);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
}

.maps-placeholder {
  flex: 1;
  margin-top: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.maps-page-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.maps-placeholder h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.maps-placeholder p {
  font-size: 14px;
  opacity: 0.7;
}

/* Tela de trilhas sonoras */

.soundtrack-page {
  flex: 1;
  min-height: 0;
  padding: 20px;
  background-color: var(--color-background);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
}

.soundtrack-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.soundtrack-search-row {
  display: flex;
  gap: 8px;
}

.soundtrack-search-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 14px;
  outline: none;
}

.soundtrack-search-input::placeholder {
  color: var(--color-text-soft);
}

.btn-filter {
  width: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

.btn-filter:hover {
  background: var(--color-surface-hover);
}

.soundtrack-search-row {
  position: relative;
}

.filter-dropdown {
  display: none;
  position: absolute;
  top: 48px;
  right: 0; 
  flex-direction: column; 
  background: var(--color-background);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  z-index: 100;
}

.filter-dropdown.open {
  display: flex; 
}

.filter-option {
  padding: 10px 16px; 
  background: transparent; 
  border: none; 
  color: var(--color-text);
  text-align: left; 
  cursor: pointer; 
  font-size: 13px; 
}

.filter-option:hover { 
  background: var(--color-surface-hover);
}

.filter-option.active { 
  background: var(--color-primary-active);
}

.btn-create-library {
  align-self: flex-start;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  backdrop-filter: var(--blur-glass);
  overflow: hidden;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
}

.library-header:hover {
  background: var(--color-surface-hover);
}

.library-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-name {
  font-size: 14px;
  font-weight: bold;
}

.library-chevron {
  transition: transform 0.2s;
  color: var(--color-text-muted);
}

.library-item.open .library-chevron {
  transform: rotate(90deg);
}

.library-body {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}

.library-item.open .library-body {
  display: flex;
}

.library-empty {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 8px 4px;
}

/* Modal */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 10000;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--color-background);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  width: min(360px, 100%);
  max-height: calc(var(--app-vh, 1vh) * 100 - var(--space-xl));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-title {
  font-size: 16px;
  margin-bottom: 16px;
}

.modal-label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 14px;
  outline: none;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  border: none;
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
}

.btn-confirm {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-primary);
  color: var(--color-text);
  cursor: pointer;
  box-shadow: var(--shadow-button);
}

.btn-confirm:hover {
  opacity: 0.9; 
}

/* Playlist dentro da biblioteca */
.playlist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playlist-header {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  font-size: 13px;
  cursor: pointer;
}

.playlist-header:hover {
  background: var(--color-surface-strong);
}

.playlist-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.playlist-header-left i {
  color: var(--color-text-muted);
}

.playlist-header-right {
  display: flex;
  align-items: center;
  gap: 6px; 
}

.playlist-chevron {
  color: var(--color-text-muted);
  font-size: 12px; 
  transition: transform 0.2s;
}

.playlist-item.open .playlist-chevron {
  transform: rotate(90deg);
}

.playlist-body { 
  display: none; 
  flex-direction: column;
  gap: 8px;
  padding: 8px 4px 0 12px;
}

.playlist-item.open .playlist-body {
  display: flex; 
}

.btn-create-playlist {
  align-self: flex-start;
  margin-top: 8px; 
  padding: 8px 14px; 
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-field-hidden {
  display: none;
}

.track-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-track {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: var(--color-text);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-track:hover {
  opacity: 0.85;
}

.btn-create-track {
  align-self: flex-start;
  margin-top: 6px;
  padding: 6px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-toolbar-small {
  align-self: flex-start;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-edit-mode.active {
  box-shadow: var(--shadow-primary-active);
}

/* Modo de edição */
.library-header-right { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}

.btn-icon-edit, .btn-icon-delete {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius : var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 13px;
}

.btn-icon-edit:hover {
  color: var(--color-primary-light);
  background: var(--color-primary-hover);
}

.btn-icon-delete:hover {
  color: var(--color-danger);
  background: rgba(255, 77, 109, 0.12);
}

.btn-icon-add {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px; 
  border-radius: var(--radius-sm);
  color: var(--color-primary-light);
  font-size: 14px; 
}

.btn-icon-add:hover {
  background: var(--color-primary-hover);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-item .btn-track {
  flex: 0 0 auto;
}
/*Tela de login*/

.top-bar.hidden-bar {
  display: none;
}

.auth-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background:
    radial-gradient(circle at 20% 20%, rgba(155, 48, 255, 0.18), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(106, 13, 173, 0.20), transparent 55%),
    var(--color-background);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--blur-glass);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.auth-brand-icon {
  font-size: 32px;
  color: var(--color-primary-light);
}

.auth-brand-title {
  font-size: 30px;
  letter-spacing: 1px;
}

.auth-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.auth-label {
  font-size: 13px;
  color: var(--color-text-muted);
}

.auth-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input-wrapper:focus-within {
  border-color: var(--color-primary-border);
  box-shadow: var(--shadow-primary-hover);
}

.auth-input-wrapper.input-error {
  border-color: var(--color-danger);
}

.auth-input-icon {
  font-size: 14px;
  color: var(--color-text-soft);
}

.auth-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 14px;
  padding: 12px 0;
}

.auth-input::placeholder {
  color: var(--color-text-soft);
}

.auth-toggle-password {
  background: transparent;
  border: none;
  color: var(--color-text-soft);
  cursor: pointer;
  font-size: 14px;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
}

.auth-toggle-password:hover {
  color: var(--color-text);
  background: var(--color-icon-hover);
}

.auth-error {
  min-height: 18px;
  font-size: 13px;
  color: var(--color-danger);
}

.btn-auth {
  width: 100%;
  justify-content: center;
  background: var(--gradient-primary);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-auth:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary-active);
}

.btn-auth:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

.auth-link {
  background: none;
  border: none;
  color: var(--color-primary-light);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.auth-link:hover {
  color: var(--color-text);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  padding: var(--space-sm);
  margin-left: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.btn-logout:hover {
  background: var(--color-icon-hover);
}

/*Tela de cadastro*/

.auth-layout {
  overflow-y: auto;
}

.auth-field-error {
  font-size: 12px;
  color: var(--color-danger);
  min-height: 15px;
}

#register-screen .auth-card {
  gap: var(--space-sm);
  margin: auto;
}

#register-screen .auth-form {
  gap: var(--space-sm);
}

#register-screen .auth-input {
  padding: 10px 0;
}

/*Rolador de dados*/

.dice-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--color-primary-border);
  background: var(--gradient-primary);
  color: var(--color-text);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  z-index: 9000;
  display: none;
  transition: transform 0.15s, box-shadow 0.2s;
}

/* A visibilidade por rota fica no bloco responsivo, no fim do arquivo. */

.dice-fab:hover {
  transform: translateY(-2px) rotate(-12deg);
  box-shadow: var(--shadow-primary-active);
}

.dice-box {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.dice-result {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
}

.dice-total-pop {
  animation: dice-pop 0.22s ease-out;
}

@keyframes dice-pop {
  from { transform: scale(0.7); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.dice-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.dice-history-header .btn-icon-mini {
  width: auto;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.dice-history {
  margin-top: var(--space-sm);
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.dice-history-empty {
  font-size: 12px;
  color: var(--color-text-soft);
  text-align: center;
  padding: var(--space-sm);
}

/*Sessões*/

.session-bar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) 15px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.session-bar.visible {
  display: flex;
}

.session-bar .master-only {
  display: none;
}

.session-bar.is-master .master-only {
  display: inline-flex;
}

.session-bar-info {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  min-width: 0;
}

.session-bar-name {
  font-size: 15px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-bar-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-active);
  border: 1px solid var(--color-primary-active-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.session-bar-actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.btn-session-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-session-action:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-border);
  color: var(--color-text);
}

.campaign-clickable {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: inherit;
  transition: background 0.2s, border-color 0.2s;
}

.campaign-clickable:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary-border);
}

.campaign-initial {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.campaign-empty {
  font-size: 13px;
  color: var(--color-text-soft);
  padding: var(--space-md);
  text-align: center;
}

.invite-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.invite-copy-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.invite-copy-row .modal-input {
  flex: 1;
  min-width: 0;
}

.invite-code-text {
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 2px;
}

.invite-status {
  margin-top: var(--space-md);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
}

.invite-status-off {
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.modal-actions-stack {
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 320px;
  overflow-y: auto;
}

.member-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.member-row .info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.maps-placeholder-hint {
  font-size: 12px;
  color: var(--color-text-soft);
  margin-top: var(--space-md);
}

/*Fichas dinâmicas*/

.mestrar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.mestrar-title {
  font-size: 18px;
}

.mestrar-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.character-meta {
  display: block;
  font-size: 11px;
  color: var(--color-text-soft);
  margin-bottom: var(--space-sm);
}

.character-readonly {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  color: var(--color-text-soft);
}

.character-card-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.btn-bar-edit {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-soft);
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.2s, color 0.2s;
}

.stat-row:hover .btn-bar-edit,
.btn-bar-edit:focus-visible {
  opacity: 1;
}

.btn-bar-edit:hover {
  background: var(--color-icon-hover);
  color: var(--color-text);
}

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

.stat-input-live {
  width: 52px;
}

.modal-textarea {
  min-height: 72px;
  resize: vertical;
  font-family: inherit;
}

.character-field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.character-field {
  min-width: 0;
}

.character-field .modal-input {
  width: 100%;
}

.bar-color-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.bar-color-picker {
  width: 44px;
  height: 34px;
  padding: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.bar-color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bar-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: transform 0.15s;
}

.bar-color-swatch:hover {
  transform: scale(1.15);
}

/*Mapa interativo*/

.session-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-text-soft);
}

.session-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-soft);
}

.session-status[data-state="live"] .session-status-dot {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.session-status[data-state="reconnecting"] .session-status-dot {
  background: var(--color-special);
}

.session-status[data-state="polling"] .session-status-dot {
  background: var(--color-danger);
}

.map-panel[hidden],
.map-stage[hidden],
.map-empty[hidden],
.map-master-tools[hidden] {
  display: none;
}

/* display fica por conta das regras de rota, no fim do arquivo. */
.map-panel {
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-xs) 15px;
  border-bottom: 1px solid var(--color-border);
}

.map-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.map-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 var(--space-xs);
}

.map-master-tools {
  display: flex;
  gap: var(--space-xs);
}

.map-master-tools .btn-icon-mini {
  width: auto;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.map-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.map-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 40px),
    var(--color-background);
  touch-action: none;
}

.map-stage-panning {
  cursor: grabbing;
}

.map-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.map-image {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.map-token-layer {
  position: absolute;
  inset: 0;
}

.map-token {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.map-token-dragging {
  cursor: grabbing;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1.12);
}

.map-token-locked {
  cursor: default;
  opacity: 0.85;
}

.map-token-initials {
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.map-token-label {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.7);
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
}

.map-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  color: var(--color-text-soft);
  font-size: 13px;
}

.map-empty i {
  font-size: 32px;
  opacity: 0.5;
}

.map-sidebar {
  width: var(--map-sidebar-width);
  flex-shrink: 0;
  padding: var(--space-sm);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
}

/* No desktop a lista de mapas fica sempre visivel; o botao e so do celular. */
.map-sidebar-toggle {
  display: none;
}

.map-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.map-list-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.map-list-row.is-active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active-border);
}

.map-list-name {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-list-name:hover {
  color: var(--color-text);
}

/*Seleção de ficha*/

.character-card.is-selected {
  border-color: var(--color-primary-border);
  box-shadow: var(--shadow-primary-hover);
}

.character-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-size: 12px;
  color: var(--color-text-muted);
}

.btn-show-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: 11px;
  cursor: pointer;
}

.btn-show-all:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

/*Abas da sessão*/

.session-tabs {
  display: flex;
  gap: 2px;
  margin: 0 auto;
}

.session-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--color-text-soft);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.session-tab:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.session-tab.is-active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active-border);
  color: var(--color-text);
}

/*
  Mapa e rolagens sao paineis da sessao, nao paginas soltas: so aparecem nas
  rotas de mesa/jogador e com a aba correspondente escolhida. Assim, sair da
  sessao para "Trilhas" ou "Meus personagens" nao deixa o mapa cobrindo a tela.
*/
.map-panel,
.roll-log-panel {
  display: none;
}

body[data-route="mesa"][data-session-tab="map"] .map-panel:not([hidden]),
body[data-route="jogador"][data-session-tab="map"] .map-panel:not([hidden]) {
  display: flex;
}

body[data-route="mesa"][data-session-tab="rolls"] .roll-log-panel,
body[data-route="jogador"][data-session-tab="rolls"] .roll-log-panel {
  display: flex;
}

body[data-route="mesa"][data-session-tab="map"] .screen.active-screen,
body[data-route="jogador"][data-session-tab="map"] .screen.active-screen,
body[data-route="mesa"][data-session-tab="rolls"] .screen.active-screen,
body[data-route="jogador"][data-session-tab="rolls"] .screen.active-screen {
  display: none;
}

body:not([data-route="mesa"]):not([data-route="jogador"]) .session-tabs {
  display: none;
}

.roll-log-panel {
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--color-surface);
}

.roll-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) 15px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.roll-entry {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.roll-entry-secret {
  border-style: dashed;
  border-color: var(--color-special);
}

.roll-entry-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.roll-entry-who {
  font-size: 13px;
  font-weight: bold;
}

.roll-entry-notation {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
  color: var(--color-text-soft);
}

.roll-entry-total {
  font-size: 22px;
  font-weight: bold;
  color: var(--color-primary-light);
}

.roll-entry-detail {
  display: flex;
  gap: var(--space-sm);
  margin-top: 2px;
  font-size: 11px;
}

.roll-entry-group {
  min-width: 68px;
  font-family: monospace;
  color: var(--color-text-soft);
}

.roll-entry-values {
  color: var(--color-text-muted);
}

.roll-entry-tag {
  display: inline-block;
  margin-top: var(--space-xs);
  font-size: 10px;
  color: var(--color-special);
}

.dice-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.dice-quick {
  flex: 1;
  min-width: 62px;
  padding: 6px 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
}

.dice-quick:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-border);
  color: var(--color-text);
}

.dice-notation-input {
  font-family: monospace;
  font-size: 16px;
  letter-spacing: 1px;
}

.dice-hint {
  margin-top: var(--space-xs);
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-soft);
}

.dice-hint code {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--color-surface-strong);
  font-size: 11px;
}

.dice-secret-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.dice-secret-row[hidden] {
  display: none;
}

.my-character-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.my-character-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.my-character-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.my-character-session {
  flex: 1;
  font-size: 15px;
  font-weight: bold;
}

.my-character-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}

.my-character-row .info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/*Grade do mapa*/

.map-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
}

.map-grid[hidden] {
  display: none;
}

.grid-size-input {
  width: 62px;
  padding: 4px 6px;
  font-size: 11px;
}

.btn-icon-mini.is-active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active-border);
  color: var(--color-text);
}

/*Ficha completa*/

.sheet-empty {
  display: block;
  font-size: 11px;
  color: var(--color-text-soft);
  padding: 2px 0 var(--space-xs);
}

.attribute-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
}

.attribute-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 2px;
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

button.attribute-box:hover {
  border-color: var(--color-primary-border);
}

.attribute-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-soft);
}

.attribute-value {
  font-size: 17px;
  font-weight: bold;
  line-height: 1;
}

.attribute-mod {
  font-size: 10px;
  color: var(--color-primary-light);
}

.weapon-row,
.item-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 3px 0;
  font-size: 12px;
}

.weapon-row.is-equipped .weapon-row-name {
  color: var(--color-primary-light);
  font-weight: bold;
}

.weapon-row-name,
.item-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weapon-row-damage,
.item-row-weight {
  font-size: 11px;
  color: var(--color-text-soft);
  font-family: monospace;
}

.weapon-row-ammo {
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-muted);
}

.item-row-qty {
  min-width: 26px;
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-soft);
}

/*Lista de personagens*/

.roster {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

/*Estados vazios*/

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-lg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state-icon {
  font-size: 26px;
  color: var(--color-primary-light);
  opacity: 0.55;
}

.empty-state-title {
  font-size: 15px;
  font-weight: bold;
}

.empty-state-hint {
  font-size: 12px;
  color: var(--color-text-soft);
  max-width: 320px;
}

.empty-state-action {
  margin-top: var(--space-xs);
}

/*Resultado do dado*/

.dice-result {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md);
  text-align: center;
}

.dice-result[hidden] {
  display: none;
}

.dice-result-notation {
  display: block;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--color-text-soft);
}

.dice-result-total {
  display: block;
  font-size: 42px;
  font-weight: bold;
  line-height: 1.1;
  color: var(--color-primary-light);
}

.dice-result-detail {
  display: block;
  font-size: 11px;
  font-family: monospace;
  color: var(--color-text-muted);
}

.dice-total-pop {
  animation: dice-pop 0.22s ease-out;
}

/*Ajustes de respiro*/

.mestrar-page {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.mestrar-header {
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.character-card {
  min-width: 0;
}

.card-grid {
  gap: var(--space-md);
}


/* ==========================================================================
   Menu de navegacao (gaveta)
   Atalho unico para trocar de pagina em qualquer tamanho de tela. No celular
   e a forma principal de navegar, ja que os cartoes grandes da home ficam
   longe depois da rolagem.
   ========================================================================== */

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 11000;
  animation: nav-fade 0.2s ease;
}

.nav-backdrop[hidden] {
  display: none;
}

@keyframes nav-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 86vw);
  z-index: 11001;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  background: var(--color-background);
  border-right: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-card);
  transform: translateX(-100%);
  /* visibility tira o menu fechado do foco por teclado, coisa que o
     translate sozinho nao faz. */
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-drawer.open {
  transform: none;
  visibility: visible;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.nav-drawer-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 16px;
  font-weight: bold;
}

.nav-drawer-title i {
  color: var(--color-primary-light);
}

.nav-drawer-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.nav-drawer-avatar {
  width: 36px;
  height: 36px;
}

.nav-drawer-user-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-drawer-links,
.nav-drawer-session,
.nav-drawer-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-drawer-session {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.nav-drawer-session[hidden] {
  display: none;
}

.nav-drawer-footer {
  margin-top: auto;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: var(--tap-target);
  padding: 0 var(--space-md);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.nav-link i {
  width: 18px;
  text-align: center;
}

.nav-link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-link.is-active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active-border);
  color: var(--color-text);
}

.nav-link-danger {
  color: var(--color-danger);
}

.nav-link-danger:hover {
  background: rgba(255, 77, 109, 0.12);
  color: var(--color-danger);
}


/* ==========================================================================
   Ajustes gerais de responsividade
   ========================================================================== */

/* As paginas rolam por dentro: o body fica travado como casca do app. */
.maps-page,
.soundtrack-page {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Abas da sessao roláveis quando nao cabem lado a lado. */
.session-tabs {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.session-tabs::-webkit-scrollbar {
  display: none;
}

/* O botao de dados aparece so onde existe ficha/mesa. */
.dice-fab {
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

body[data-route="mesa"] .dice-fab,
body[data-route="jogador"] .dice-fab,
body[data-route="campanha"] .dice-fab {
  display: block;
}

.dice-box {
  width: min(420px, 100%);
  max-width: 100%;
  max-height: calc(var(--app-vh, 1vh) * 100 - var(--space-xl));
}

#toast-container {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  max-width: calc(100vw - 40px);
}

.top-bar {
  padding-left: calc(15px + env(safe-area-inset-left, 0px));
  padding-right: calc(15px + env(safe-area-inset-right, 0px));
}

.top-right {
  gap: var(--space-xs);
  min-width: 0;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

/* Quebra palavras longas em vez de estourar a largura no celular. */
.campaign-header-title,
.mestrar-title,
.character-name,
.roster-name,
.library-name,
.map-list-name,
.my-character-session {
  overflow-wrap: anywhere;
}


/* ==========================================================================
   Desktop compacto e tablet deitado (ate 1199px)
   ========================================================================== */

@media (max-width: 1199px) {
  :root {
    --app-padding: 16px;
    --panel-left: 250px;
    --panel-right: 280px;
    --sidebar-width: 220px;
  }

  .main {
    grid-template-columns: minmax(0, 1fr) var(--panel-right);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "left right"
      "middle right"
      "characters right"
      "soundtrack right";
  }

  .btn-maps {
    min-height: 150px;
  }

  .campaign-header {
    padding: 18px;
  }
}


/* ==========================================================================
   Tablet em pe (ate 899px)
   Aqui a interface deixa de ser "tres colunas" e vira uma coluna so.
   ========================================================================== */

@media (max-width: 899px) {
  :root {
    --app-padding: 14px;
    --map-sidebar-width: 100%;
  }

  /* --- Home em coluna unica --- */
  .main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas:
      "left"
      "right"
      "middle"
      "characters"
      "soundtrack";
    /* As linhas passam a ter a altura do conteudo e quem rola e a .main. */
    align-content: start;
  }

  .left-panel,
  .middle-panel,
  .right-panel {
    align-self: stretch;
    height: auto;
    /* min-height:0 deixaria a linha encolher menos que o conteudo e as
       campanhas invadiriam o cartao de baixo. */
    min-height: auto;
  }

  /* Sem coluna fixa nao existe mais painel com rolagem propria. */
  .campaign-box,
  .campaign-box-master,
  .campaign-box-player {
    flex: 0 0 auto;
    min-height: auto;
    overflow-y: visible;
  }

  .btn-create,
  .btn-maps,
  .btn-characters,
  .btn-soundtrack {
    min-height: 110px;
    padding: 18px;
  }

  /* --- Tela de campanha: lista de sessoes vira gaveta --- */
  .create-campaign-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    position: relative;
  }

  .sessions-sidebar-toggle {
    display: inline-flex;
    align-self: flex-start;
  }

  .sessions-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 9000;
    width: min(280px, 85vw);
    background: var(--color-background);
    border-right: 1px solid var(--color-border-strong);
    box-shadow: var(--shadow-card);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }

  .sessions-sidebar.is-open {
    transform: none;
    visibility: visible;
  }

  .campaign-header {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  /* --- Mapa: lista de mapas vira painel sobreposto --- */
  .map-sidebar-toggle {
    display: inline-flex;
  }

  .map-body {
    position: relative;
  }

  .map-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(240px, 80%);
    z-index: 20;
    background: var(--color-background);
    border-left: 1px solid var(--color-border-strong);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }

  .map-sidebar.is-open {
    transform: none;
    visibility: visible;
  }

  .map-toolbar {
    flex-wrap: wrap;
    row-gap: var(--space-xs);
  }

  /* --- Barra da sessao em duas linhas --- */
  .session-bar {
    flex-wrap: wrap;
    row-gap: var(--space-sm);
  }

  .session-tabs {
    order: 3;
    width: 100%;
    margin: 0;
    justify-content: flex-start;
  }

  .session-bar-actions {
    flex-shrink: 1;
  }
}


/* ==========================================================================
   Celular (ate 599px)
   ========================================================================== */

@media (max-width: 599px) {
  :root {
    --app-padding: 12px;
  }

  /* --- Topo --- */
  .top-bar {
    height: 56px;
  }

  .title {
    font-size: 16px;
  }

  .user-profile {
    padding: 4px;
    background: transparent;
    border-color: transparent;
    backdrop-filter: none;
  }

  .user-name {
    display: none;
  }

  .user-avatar {
    width: 30px;
    height: 30px;
  }

  .btn-logout {
    min-width: var(--tap-target);
    min-height: var(--tap-target);
    margin-left: 0;
  }

  /* --- Home --- */
  .btn-create,
  .btn-maps,
  .btn-characters,
  .btn-soundtrack {
    min-height: 96px;
    padding: 14px;
    gap: 4px;
  }

  .create-icon,
  .maps-icon,
  .characters-icon,
  .soundtrack-icon {
    font-size: 24px;
  }

  .create-desc,
  .maps-desc,
  .characters-desc,
  .soundtrack-desc {
    font-size: 11px;
    max-width: 32ch;
  }

  .join-input-row {
    flex-wrap: wrap;
  }

  .join-input {
    flex: 1 1 100%;
    min-height: var(--tap-target);
  }

  .btn-enter {
    flex: 1 1 100%;
    min-height: var(--tap-target);
  }

  .campaign-box {
    padding: 14px;
  }

  /* --- Barra da sessao --- */
  .session-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .session-bar-info {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }

  .session-bar-actions {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  /* Só o icone: o rotulo nao cabe em tres botoes lado a lado. */
  .session-bar-actions .btn-session-action span,
  .map-master-tools .btn-icon-mini span,
  .roll-log-panel .map-toolbar .btn-icon-mini span {
    display: none;
  }

  .session-bar-actions .btn-session-action {
    flex: 1;
    justify-content: center;
    min-height: var(--tap-target);
  }

  .session-tab {
    flex: 1;
    justify-content: center;
    min-height: 38px;
    padding: 6px 10px;
  }

  /* --- Fichas --- */
  .mestrar-header {
    flex-direction: column;
    align-items: stretch;
  }

  .mestrar-header .btn-session-action {
    justify-content: center;
    min-height: var(--tap-target);
  }

  .roster-row > .campaign-initial { grid-area: avatar; }
  .roster-row > .roster-info { grid-area: info; }
  .roster-row > .roster-bars { grid-area: bars; }
  .roster-row > .roster-weapon { grid-area: weapon; text-align: left; }

  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .attribute-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-label {
    width: 46px;
    font-size: 12px;
  }

  .weapon-row,
  .item-row {
    flex-wrap: wrap;
    row-gap: var(--space-xs);
  }

  .my-character-group-header {
    flex-wrap: wrap;
  }

  /* --- Trilhas sonoras --- */
  .soundtrack-toolbar {
    margin: var(--space-md) 0;
  }

  .toolbar-actions-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
  }

  .btn-create-library,
  .btn-toolbar-small {
    align-self: stretch;
    justify-content: center;
    min-height: var(--tap-target);
    padding: 10px;
  }

  .btn-create-library {
    grid-column: 1 / -1;
  }

  .soundtrack-search-input {
    min-height: var(--tap-target);
  }

  .btn-filter {
    min-width: var(--tap-target);
    min-height: var(--tap-target);
  }

  .filter-dropdown {
    right: 0;
    left: auto;
  }

  /* --- Modais viram folha de baixo para cima --- */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    max-height: calc(var(--app-vh, 1vh) * 92);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    animation: modal-slide-up 0.22s ease;
  }

  @keyframes modal-slide-up {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }

  .character-field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions,
  .modal-actions-stack {
    flex-direction: column-reverse;
    gap: var(--space-sm);
  }

  .modal-actions .btn-secondary,
  .modal-actions .btn-confirm,
  .modal-actions-stack .btn-secondary,
  .modal-actions-stack .btn-confirm {
    width: 100%;
    min-height: var(--tap-target);
  }

  /* Fonte >= 16px evita o zoom automatico do iOS ao focar um campo. */
  .modal-input,
  .auth-input,
  .join-input,
  .soundtrack-search-input {
    font-size: 16px;
  }

  .dice-quick-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dice-quick {
    min-height: var(--tap-target);
  }

  .dice-fab {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
  }

  #toast-container {
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .toast {
    min-width: 0;
  }

  /* --- Login e cadastro --- */
  .auth-layout {
    padding: var(--space-md);
    align-items: flex-start;
  }

  .auth-card {
    padding: var(--space-lg);
    margin: auto 0;
  }

  .btn-auth {
    min-height: var(--tap-target);
  }
}


/* ==========================================================================
   Celular pequeno (ate 380px)
   ========================================================================== */

@media (max-width: 380px) {
  .session-tab span {
    display: none;
  }

  .character-field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .attribute-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .campaign-header-meta {
    flex-wrap: wrap;
  }
}


/* ==========================================================================
   Celular deitado: sobra pouca altura, entao tudo encolhe
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
  .top-bar {
    height: 48px;
  }

  .auth-layout {
    align-items: flex-start;
    padding: var(--space-sm);
  }

  .auth-card {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .auth-brand-icon {
    font-size: 22px;
  }

  .modal-box {
    max-height: calc(var(--app-vh, 1vh) * 96);
  }
}


/* ==========================================================================
   Telas de toque e preferencias do sistema
   ========================================================================== */

@media (hover: none) {
  /* Sem mouse nao existe hover: o lapis das barras fica sempre visivel. */
  .btn-bar-edit {
    opacity: 1;
  }

  .btn-icon-mini,
  .btn-icon-edit,
  .btn-icon-delete,
  .btn-icon-add,
  .btn-bar-edit {
    min-width: 34px;
    min-height: 34px;
  }

  .stat-bar-draggable {
    touch-action: none;
  }

  .map-token {
    touch-action: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .top-bar,
  .session-bar,
  .nav-drawer,
  .nav-backdrop,
  .dice-fab,
  #toast-container {
    display: none !important;
  }

  body {
    overflow: visible;
    height: auto;
  }
}


/* ==========================================================================
   FICHA DE PERSONAGEM E HUD DA MESA
   Bloco unico com a aparencia da tela de personagens dentro da sessao.
   Fica no fim do arquivo de proposito: sobrescreve o que veio antes.
   ========================================================================== */

/* --- tokens da tela ------------------------------------------------------ */

:root {
  /* auto-fit + min/max: com poucas fichas as colunas vazias colapsam e as
     que sobraram crescem ate o maximo, em vez de deixar meia tela vazia. */
  --sheet-min: 340px;
  --sheet-max: 520px;
  --party-min: 270px;
  --party-max: 400px;

  --hp-ok: #4cd964;
  --hp-warn: #ffb020;
  --hp-danger: #ff4d6d;
  --hp-empty: #6b6b7b;
}

.mestrar-page {
  max-width: 1600px;
  gap: var(--space-lg);
}

.mestrar-header {
  align-items: center;
  gap: var(--space-lg);
}

.mestrar-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Botao de acao principal do cabecalho, para nao competir com os secundarios */
.btn-session-primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: var(--color-text);
  font-weight: 600;
  min-height: 36px;
  padding: 0 14px;
}

.btn-session-primary:hover {
  background: var(--gradient-primary);
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-primary-hover);
  color: var(--color-text);
}

/* --- busca do roster ----------------------------------------------------- */

.roster-toolbar {
  position: relative;
  display: flex;
  align-items: center;
}

.roster-toolbar[hidden] {
  display: none;
}

.roster-search-icon {
  position: absolute;
  left: 12px;
  font-size: 12px;
  color: var(--color-text-soft);
  pointer-events: none;
}

.roster-search-input {
  width: 240px;
  max-width: 100%;
  min-height: 36px;
  padding: 0 12px 0 32px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.roster-search-input::placeholder {
  color: var(--color-text-soft);
}

.roster-search-input:focus {
  border-color: var(--color-primary-border);
  box-shadow: 0 0 0 3px var(--color-primary-hover);
}

.roster-search-input::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.5;
}

/* --- HUD do grupo -------------------------------------------------------- */

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--party-min), var(--party-max)));
  justify-content: start;
  gap: var(--space-md);
}

.party-frame {
  --hp-color: var(--hp-ok);

  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--hp-color);
  border-radius: var(--radius-md);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--hp-color) 8%, transparent), transparent 45%),
    var(--color-surface);
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.party-frame[data-hp="warn"]   { --hp-color: var(--hp-warn); }
.party-frame[data-hp="danger"] { --hp-color: var(--hp-danger); }
.party-frame[data-hp="empty"]  { --hp-color: var(--hp-empty); }
.party-frame[data-hp="none"]   { --hp-color: var(--color-border-strong); }

.party-frame:hover {
  transform: translateY(-2px);
  border-color: var(--color-primary-border);
  border-left-color: var(--hp-color);
  box-shadow: var(--shadow-primary-hover);
}

.party-frame.is-selected {
  border-color: var(--color-primary);
  border-left-color: var(--hp-color);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--hp-color) 10%, transparent), transparent 45%),
    var(--color-primary-active);
  box-shadow: var(--shadow-primary-active);
}

/* Ficha zerada fica visivelmente fora de combate. */
.party-frame[data-hp="empty"] .party-avatar,
.party-frame[data-hp="empty"] .party-name {
  opacity: 0.55;
}

.party-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.party-avatar,
.sheet-avatar {
  --avatar-hue: 270;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(
    135deg,
    hsl(var(--avatar-hue) 65% 45%),
    hsl(calc(var(--avatar-hue) + 35) 70% 32%)
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.party-avatar {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.party-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.party-name {
  font-size: 14px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-owner {
  font-size: 11px;
  color: var(--color-text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-weapon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  min-width: 0;
  max-width: 48%;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  font-size: 11px;
  color: var(--color-text-muted);
}

.party-weapon span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-vitals {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.party-main-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.party-bar-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-soft);
  width: 52px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-track {
  flex: 1;
  height: 9px;
  min-width: 0;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.party-track-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

.party-bar-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
}

.party-mini-bars {
  display: flex;
  gap: 4px;
  padding-left: calc(52px + var(--space-sm));
}

.party-mini-bar {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.party-mini-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

/* --- grade de fichas ----------------------------------------------------- */

#character-cards,
#player-character-cards {
  grid-template-columns: repeat(auto-fit, minmax(var(--sheet-min), var(--sheet-max)));
  justify-content: start;
  align-items: start;
}

.character-card {
  --hp-color: var(--hp-ok);

  position: relative;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-color: var(--color-border);
  background: var(--color-surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.character-card[data-hp="warn"]   { --hp-color: var(--hp-warn); }
.character-card[data-hp="danger"] { --hp-color: var(--hp-danger); }
.character-card[data-hp="empty"]  { --hp-color: var(--hp-empty); }
.character-card[data-hp="none"]   { --hp-color: var(--color-border-strong); }

/* Fita de estado no topo: da para ler a situacao da ficha de longe. */
.character-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--hp-color);
  opacity: 0.85;
}

.character-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-primary-active);
}

/* --- cabecalho da ficha -------------------------------------------------- */

.sheet-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--hp-color) 10%, transparent),
    transparent 60%
  );
}

.sheet-avatar {
  width: 42px;
  height: 42px;
  font-size: 17px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 0 2px color-mix(in srgb, var(--hp-color) 55%, transparent);
}

.sheet-ident {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.character-name {
  font-size: 16px;
  font-weight: bold;
  line-height: 1.2;
}

.character-meta {
  font-size: 11px;
  color: var(--color-text-soft);
  margin: 0;
}

.sheet-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.character-readonly {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-soft);
  margin: 0;
}

/* --- barras vitais ------------------------------------------------------- */

.sheet-vitals {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.stat-label {
  width: 58px;
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 12px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.2s ease;
  box-shadow: 0 0 8px -1px currentColor;
}

/* Brilho de alerta quando a barra chega no vermelho. */
.stat-row[data-level="danger"] .stat-bar {
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 1px color-mix(in srgb, var(--hp-danger) 55%, transparent);
}

.stat-row[data-level="danger"] .stat-text,
.stat-row[data-level="empty"] .stat-text {
  color: var(--hp-danger);
  font-weight: 600;
}

.stat-row[data-level="empty"] .stat-bar-fill {
  opacity: 0.4;
}

.stat-bar-draggable {
  overflow: visible;
}

.stat-handle {
  width: 16px;
  height: 16px;
  border-width: 3px;
  background: var(--color-background);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.stat-spacer {
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px dashed var(--color-border);
}

/* Pilula com − valor + : dano e cura sem abrir nada. */
.stat-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  border: 1px solid var(--color-border);
}

.stat-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.stat-step:hover:not(:disabled) {
  background: var(--color-primary-active);
  color: var(--color-text);
}

.stat-step:disabled {
  opacity: 0.25;
  cursor: default;
}

.stat-value,
.stat-value-pct {
  width: 56px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--color-text);
  cursor: pointer;
}

.stat-value-pct {
  width: 48px;
}

.stat-input-current,
.pct-input {
  width: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-bar-edit {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

/* --- secoes dobraveis ---------------------------------------------------- */

.sheet-section {
  border-bottom: 1px solid var(--color-border);
}

.sheet-section:last-of-type {
  border-bottom: none;
}

.sheet-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0 10px 0 4px;
}

.sheet-section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-height: 40px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}

.sheet-section-toggle:hover .section-title-mini {
  color: var(--color-text);
}

.sheet-chevron {
  font-size: 10px;
  color: var(--color-text-soft);
  transition: transform 0.2s ease;
}

.sheet-section:not([data-open]) .sheet-chevron {
  transform: rotate(-90deg);
}

.sheet-section:not([data-open]) .sheet-section-body {
  display: none;
}

.sheet-section-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px 14px;
}

.section-title-mini {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-soft);
  transition: color 0.2s;
}

.sheet-empty {
  font-size: 12px;
  color: var(--color-text-soft);
  font-style: italic;
}

/* --- atributos ----------------------------------------------------------- */

.attribute-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.attribute-box {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.attribute-box:hover {
  border-color: var(--color-primary-border);
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* O quadrado inteiro rola o teste. */
.attribute-roll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  padding: 8px 4px 7px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.attribute-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attribute-value {
  font-size: 18px;
  font-weight: bold;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.attribute-mod {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary-light);
  font-variant-numeric: tabular-nums;
}

/* Dadinho que aparece no hover avisando que da para rolar dali. */
.attribute-roll-cue {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 9px;
  color: var(--color-primary-light);
  opacity: 0;
  transition: opacity 0.2s;
}

.attribute-box:hover .attribute-roll-cue {
  opacity: 1;
}

.attribute-edit {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-soft);
  font-size: 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}

.attribute-box:hover .attribute-edit,
.attribute-edit:focus-visible {
  opacity: 1;
}

.attribute-edit:hover {
  background: var(--color-icon-hover);
  color: var(--color-text);
}

/* --- armas e inventario -------------------------------------------------- */

.weapon-row,
.item-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
}

/* A arma ocupa duas linhas: identidade em cima, dano/munição embaixo. */
.weapon-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.weapon-main,
.weapon-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.weapon-meta {
  flex-wrap: wrap;
  padding-left: 34px;
}

.weapon-row.is-equipped {
  border-color: var(--color-primary-border);
  background: var(--color-primary-hover);
}

.weapon-equip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

button.weapon-equip:hover {
  background: var(--color-icon-hover);
  color: var(--color-text);
}

.weapon-row.is-equipped .weapon-equip {
  color: var(--color-primary-light);
}

.weapon-row-name,
.item-row-name {
  flex: 1;
  min-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weapon-row.is-equipped .weapon-row-name {
  font-weight: 600;
}

/* Dano clicavel: rola direto no log da mesa. */
.weapon-roll {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 4px 11px;
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-pill);
  background: var(--gradient-primary);
  color: var(--color-text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, filter 0.2s;
}

.weapon-roll:hover {
  filter: brightness(1.15);
  box-shadow: var(--shadow-primary-hover);
  transform: translateY(-1px);
}

.weapon-roll:active {
  transform: none;
}

.weapon-row-damage,
.item-row-weight {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--color-text-soft);
  font-variant-numeric: tabular-nums;
}

.weapon-ammo {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-strong);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.weapon-ammo.is-empty {
  background: color-mix(in srgb, var(--hp-danger) 22%, transparent);
  color: var(--hp-danger);
}

.item-row-qty {
  flex-shrink: 0;
  min-width: 30px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-soft);
}

/* --- dinheiro ------------------------------------------------------------ */

.money-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-sm);
}

/* Rotulo em cima e valor embaixo: "Recompensa $500,00" nao cabe numa linha
   so na largura de uma ficha. */
.money-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon value";
  align-items: center;
  column-gap: var(--space-sm);
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
}

.money-item i {
  grid-area: icon;
  color: var(--color-text-soft);
  font-size: 14px;
}

.money-label {
  grid-area: label;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-soft);
}

.money-text {
  grid-area: value;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* --- rodape da ficha ----------------------------------------------------- */

.character-card-actions {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: 10px 16px 14px;
  border-top: 1px solid var(--color-border);
}

.character-filter-bar {
  grid-column: 1 / -1;
}

/* --- responsivo ---------------------------------------------------------- */

@media (max-width: 899px) {
  :root {
    --sheet-min: 300px;
    --sheet-max: 1fr;
    --party-min: 240px;
    --party-max: 1fr;
  }
}

@media (max-width: 599px) {
  :root {
    --sheet-min: 100%;
    --party-min: 100%;
  }

  .mestrar-header-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .roster-search-input {
    width: 100%;
  }

  .sheet-header {
    padding: 12px;
  }

  .sheet-vitals,
  .sheet-section-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .stat-label {
    width: 48px;
  }

  /* Sem hover no toque, os botoes de editar ficam sempre a vista. */
  .attribute-edit,
  .attribute-roll-cue {
    opacity: 1;
  }

  .party-weapon {
    max-width: 100%;
  }
}

@media (hover: none) {
  .attribute-edit,
  .attribute-roll-cue {
    opacity: 1;
  }

  .stat-step {
    width: 28px;
    height: 28px;
  }
}


/* ==========================================================================
   Animacoes de botao (so CSS), player embutido e melhorias do mapa
   ========================================================================== */

button {
  -webkit-tap-highlight-color: transparent;
}

/* Aperto uniforme em todos os botoes de acao. */
.btn:active,
.btn-confirm:active,
.btn-secondary:active,
.btn-auth:active,
.btn-session-action:active,
.btn-icon-mini:active,
.dice-quick:active,
.nav-link:active,
.stat-step:active,
.weapon-roll:active,
.attribute-roll:active,
.party-frame:active {
  transform: scale(0.97);
}

.btn-confirm {
  transition: transform 0.12s, filter 0.2s, box-shadow 0.2s;
}

.btn-confirm:hover {
  filter: brightness(1.12);
  box-shadow: var(--shadow-primary-hover);
}

.btn-secondary {
  transition: transform 0.12s, background 0.2s;
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
}

/* --- player de musica embutido (iframe) --- */

.player-box {
  width: min(720px, 100%);
}

.player-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--color-border);
}

.player-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-open-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

/* --- mapa: campo da grade, CTA e area de soltar arquivo --- */

.grid-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 11px;
  color: var(--color-text-soft);
}

.grid-size-input {
  width: 44px;
  padding: 3px 4px;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 12px;
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}

.grid-size-input::-webkit-outer-spin-button,
.grid-size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.map-empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--space-sm);
}

.map-empty-cta[hidden] {
  display: none;
}

.map-empty-hint {
  font-size: 12px;
  color: var(--color-text-soft);
}

.map-empty-hint[hidden] {
  display: none;
}

.map-body.is-dropping::after {
  content: "Solte a imagem para enviar o mapa";
  position: absolute;
  inset: 8px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-primary-light);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-primary) 18%, rgba(0, 0, 0, 0.65));
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}


/* ==========================================================================
   Sessoes de jogo (encontros) dentro da campanha
   ========================================================================== */

.play-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.play-status:empty {
  display: none;
}

.play-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.play-chip.is-live {
  color: var(--color-text);
}

.play-chip-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
  animation: play-pulse 1.6s ease-in-out infinite;
}

@keyframes play-pulse {
  50% { opacity: 0.45; }
}

.play-action {
  width: auto;
  padding: 6px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.play-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.play-row {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.18);
}

.play-row.is-live {
  border-left-color: var(--color-success);
}

.play-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.play-row-title {
  font-size: 13px;
  font-weight: 600;
}

.play-row-when {
  font-size: 11px;
  color: var(--color-text-soft);
  font-variant-numeric: tabular-nums;
}

.play-row-notes {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}


/* ==========================================================================
   Confirmacao, aprimoramento de atributo e zona de perigo
   ========================================================================== */

.confirm-box {
  width: min(400px, 100%);
}

.confirm-head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.confirm-icon {
  font-size: 20px;
  color: var(--color-primary-light);
}

.confirm-danger .confirm-icon {
  color: var(--color-danger);
}

.confirm-title {
  margin: 0;
}

.confirm-message {
  margin-bottom: var(--space-lg);
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.confirm-message[hidden] {
  display: none;
}

.confirm-danger .btn-confirm {
  background: var(--gradient-danger);
  border-color: var(--color-danger);
}

/* --- atributo aprimorado ------------------------------------------------- */

.attribute-box[data-boost] {
  border-color: var(--attr-color, var(--color-primary-light));
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--attr-color, var(--color-primary)) 22%, transparent), transparent 70%),
    rgba(0, 0, 0, 0.22);
}

.attribute-box[data-boost="down"] {
  border-color: var(--attr-color, var(--color-danger));
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--attr-color, var(--color-danger)) 20%, transparent), transparent 70%),
    rgba(0, 0, 0, 0.22);
}

/* Cor escolhida pelo mestre vale mesmo sem bencao. */
.attribute-box[style*="--attr-color"] {
  border-color: color-mix(in srgb, var(--attr-color) 60%, var(--color-border));
}

.attribute-box[style*="--attr-color"] .attribute-mod {
  color: var(--attr-color);
}

.attribute-boost-mark {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 10px;
  color: var(--attr-color, var(--color-primary-light));
}

.attribute-box[data-boost="down"] .attribute-boost-mark {
  color: var(--attr-color, var(--color-danger));
}

.attribute-boost-btn {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-primary-light);
  font-size: 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}

.attribute-box:hover .attribute-boost-btn,
.attribute-boost-btn:focus-visible,
.attribute-box[data-boost] .attribute-boost-btn {
  opacity: 1;
}

.attribute-boost-btn:hover {
  background: var(--color-icon-hover);
}

/* Com a varinha na esquerda, o dado de "da para rolar" sai de baixo dela. */
.attribute-box:has(.attribute-boost-btn) .attribute-roll-cue {
  top: auto;
  bottom: 4px;
  left: 5px;
}

/* --- modal de aprimorar -------------------------------------------------- */

.boost-subtitle {
  margin: -8px 0 var(--space-md);
  font-size: 12px;
  color: var(--color-text-soft);
}

.boost-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: var(--space-sm);
}

.boost-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  color: var(--color-text-soft);
  font-family: inherit;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.12s;
}

.boost-option i {
  font-size: 13px;
}

.boost-option:hover {
  border-color: var(--color-primary-border);
  color: var(--color-text);
}

.boost-option.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-active);
  color: var(--color-text);
}

.boost-option[data-boost="-1"].is-active,
.boost-option[data-boost="-2"].is-active {
  border-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 22%, transparent);
}

.boost-hint {
  margin-bottom: var(--space-lg);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.boost-color-clear {
  padding: 6px 10px;
  font-size: 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* --- dinheiro editavel --------------------------------------------------- */

.money-item.is-editable {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.money-item.is-editable:hover,
.money-item.is-editable:focus-visible {
  border-color: var(--color-primary-border);
  background: var(--color-primary-hover);
  outline: none;
}

.money-input {
  grid-area: value;
  display: none;
  width: 100%;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--color-primary-light);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: none;
}

.money-item.editing .money-text { display: none; }
.money-item.editing .money-input { display: block; }

/* --- zona de perigo ------------------------------------------------------ */

.danger-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: var(--space-md) 0 var(--space-lg);
  padding: var(--space-md);
  border: 1px solid color-mix(in srgb, var(--color-danger) 35%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-danger) 8%, transparent);
}

.danger-zone-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-danger);
}

.danger-zone-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-target);
  border: 1px solid color-mix(in srgb, var(--color-danger) 45%, transparent);
  border-radius: var(--radius-sm);
}

.danger-zone-action[hidden] {
  display: none;
}

.danger-zone-action:hover {
  background: color-mix(in srgb, var(--color-danger) 18%, transparent);
}

.danger-zone-hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-soft);
}

@media (max-width: 599px) {
  .boost-scale {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .attribute-boost-btn {
    opacity: 1;
  }
}
