@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
  --bg: #10151c;
  --bg-alt: #151c25;
  --panel: #1b2430;
  --ink: #e6edf5;
  --muted: #98a7b7;
  --accent: #4e89ff;
  --accent-hover: #3f74db;
  --accent-soft: #22364f;
  --border: #2d3846;
  --danger: #d97373;
  --danger-soft: #3b2428;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: radial-gradient(circle at top right, #1a2430, var(--bg));
  background-repeat: no-repeat;
  background-size: cover;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", "Segoe UI", Tahoma, sans-serif;
  background: transparent;
  color: var(--ink);
}

h1,
h2,
h3,
h4 {
  font-family: "Cinzel", Georgia, "Times New Roman", serif;
  letter-spacing: 0.02em;
}

.app {
  width: 100%;
  max-width: 1500px;
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  padding: 0.35rem 0;
  margin-bottom: 0.5rem;
  background: transparent;
  border: none;
  box-shadow: none;
}

.app-logo {
  display: block;
  width: min(54vw, 540px);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

body.page-login .app-logo {
  display: none;
}

body.page-login .header-bar {
  margin-bottom: 0;
  padding: 0;
}

#pageLogin {
  max-width: 420px;
  margin: 0.45rem auto 0;
}

.login-logo {
  width: min(75vw, 468px);
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.2rem auto 0.7rem;
}

body.login-awe-active {
  overflow-x: clip;
}

body.login-awe-active::before,
body.login-awe-active::after {
  content: "";
  position: fixed;
  inset: -15vh -20vw;
  pointer-events: none;
  z-index: 4;
}

body.login-awe-active::before {
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 239, 176, 0.16), transparent 48%),
    radial-gradient(circle at 18% 50%, rgba(134, 205, 255, 0.11), transparent 44%),
    radial-gradient(circle at 82% 52%, rgba(121, 147, 255, 0.11), transparent 44%);
  animation: login-awe-sky 1150ms ease-out both;
}

body.login-awe-active::after {
  background: linear-gradient(
    112deg,
    transparent 0%,
    rgba(255, 244, 200, 0.04) 32%,
    rgba(255, 244, 200, 0.34) 46%,
    rgba(255, 244, 200, 0.05) 62%,
    transparent 100%
  );
  transform: translateX(-120vw) skewX(-18deg);
  animation: login-awe-sweep 920ms cubic-bezier(0.16, 0.76, 0.24, 1) 170ms both;
}

body.page-login.login-awe-active #pageLogin,
body.page-login.login-awe-active .login-logo {
  animation: login-awe-exit 520ms ease-in both;
}

body.login-awe-active.page-player #pagePlayerHome,
body.login-awe-active #pageWelcome {
  animation: login-awe-rise 950ms cubic-bezier(0.12, 0.78, 0.16, 1) 120ms both;
}

body.login-awe-active.page-player .player-waiting-image,
body.login-awe-active #pageWelcome .app-footer-logo {
  animation: login-awe-artifact 1450ms ease-out 220ms both;
}

body.login-awe-active.page-player #playerLiveWrap {
  animation: login-awe-panel 920ms ease-out 240ms both;
}

@keyframes login-awe-sky {
  0% {
    opacity: 0;
    filter: blur(10px);
  }
  36% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    filter: blur(0);
  }
}

@keyframes login-awe-sweep {
  0% {
    transform: translateX(-120vw) skewX(-18deg);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: translateX(122vw) skewX(-18deg);
    opacity: 0;
  }
}

@keyframes login-awe-exit {
  0% {
    opacity: 1;
    filter: saturate(1);
    transform: translateY(0) scale(1);
  }
  70% {
    opacity: 0.95;
    transform: translateY(-6px) scale(1.015);
  }
  100% {
    opacity: 0;
    filter: saturate(1.3);
    transform: translateY(-18px) scale(1.03);
  }
}

@keyframes login-awe-rise {
  0% {
    opacity: 0;
    transform: translateY(26px) scale(0.985);
    filter: brightness(0.88) saturate(1.2);
  }
  60% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1) saturate(1);
  }
}

@keyframes login-awe-artifact {
  0% {
    opacity: 0;
    transform: scale(0.92) rotate(-1.5deg);
    filter: blur(3px) saturate(1.35);
  }
  48% {
    opacity: 1;
    transform: scale(1.03) rotate(0.4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    filter: blur(0) saturate(1);
  }
}

@keyframes login-awe-panel {
  0% {
    opacity: 0;
    transform: translateY(30px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.login-awe-active::before,
  body.login-awe-active::after,
  body.page-login.login-awe-active #pageLogin,
  body.page-login.login-awe-active .login-logo,
  body.login-awe-active.page-player #pagePlayerHome,
  body.login-awe-active #pageWelcome,
  body.login-awe-active.page-player .player-waiting-image,
  body.login-awe-active #pageWelcome .app-footer-logo,
  body.login-awe-active.page-player #playerLiveWrap {
    animation: none !important;
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.grid.six {
  grid-template-columns: repeat(6, minmax(50px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: none;
}

.main-sections {
  display: flex;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
  gap: 0.45rem;
  align-items: center;
  padding: 0;
  margin-bottom: 0;
}

.main-sections button.active {
  background: var(--accent);
}

.user-menu {
  position: relative;
  margin-left: 0.7rem;
  align-self: center;
}

.user-menu::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: max(100%, 9rem);
  height: 14px;
}

.user-menu-name {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 1.9rem;
  padding: 0;
  border: none;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.95rem;
  cursor: default;
  user-select: none;
}

.user-menu-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(10, 18, 30, 0.75);
  object-fit: cover;
  object-position: center;
  display: inline-block;
}

.user-menu-popover {
  position: absolute;
  top: calc(100% + 0.12rem);
  right: 0;
  min-width: 9rem;
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease;
  z-index: 20;
}

.user-menu:hover .user-menu-popover,
.user-menu:focus-within .user-menu-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.user-menu.force-closed .user-menu-popover,
.user-menu.force-closed:hover .user-menu-popover,
.user-menu.force-closed:focus-within .user-menu-popover {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

@media (max-width: 900px) {
  .header-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }

  .main-sections {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .user-menu {
    margin-left: 0;
  }
}

@media (max-width: 680px) {
  .app-logo {
    width: min(90vw, 420px);
  }
}

.nav-pane {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  margin: 0 0 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.nav-pane button {
  padding: 0;
  font-size: 0.9rem;
  background: transparent;
  color: var(--muted);
  border: none;
  text-decoration: underline;
}

.nav-pane button:hover {
  background: transparent;
  color: var(--ink);
}

.nav-pane button:disabled {
  color: #657486;
  cursor: default;
}

.nav-sep {
  color: #6e7f90;
}

.row,
.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.between {
  justify-content: space-between;
}

.panel-header-actions {
  align-items: center;
  margin-bottom: 0.6rem;
}

.panel-header-actions h3 {
  margin: 0;
}

.add-icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  min-width: 2.15rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.add-icon-btn span {
  display: inline-block;
  transform: translateY(-1px);
}

.stacked-form {
  display: grid;
  gap: 0.5rem;
}

.welcome-header {
  align-items: flex-start;
  gap: 1rem;
}

.welcome-header h2 {
  margin: 0;
}

#pageWelcome .welcome-header {
  margin-bottom: 0.6rem;
}

.welcome-create-form {
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.welcome-create-form input {
  min-width: 220px;
}

#monsterSearchInput {
  width: min(420px, 100%);
  margin: 0.25rem 0 0.55rem;
}

#scenarioSearchInput {
  width: min(420px, 100%);
  margin: 0.2rem 0 0.55rem;
}

.admin-hero h2 {
  margin-bottom: 0.25rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 1rem;
}

.admin-panel h3 {
  margin: 0;
}

.admin-form-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: #18212c;
  margin-bottom: 0.7rem;
}

.admin-form-card label {
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-search {
  width: min(250px, 100%);
  margin: 0;
}

.admin-campaign-list {
  margin: 0;
  max-height: 220px;
  overflow: auto;
}

.admin-row {
  align-items: center;
  gap: 0.6rem;
}

.admin-user-item {
  display: grid;
  gap: 0.55rem;
}

.admin-row-main {
  font-weight: 600;
}

.admin-meta {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  margin-left: auto;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #3a4a5d;
  background: #1d2a39;
  color: #d6e3f1;
  font-size: 0.75rem;
}

.admin-badge-active {
  border-color: #426a56;
  background: #223b31;
  color: #d7f3e4;
}

.admin-badge-inactive {
  border-color: #6f4a4a;
  background: #382425;
  color: #f5d8d8;
}

.admin-dice-skin-options {
  display: grid;
  gap: 0.55rem;
  margin: 0.3rem 0 0.5rem;
}

.admin-dice-skin-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.78rem;
  border: 1px solid #3b495b;
  border-radius: 10px;
  background: #17212d;
}

.admin-dice-skin-option input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: #4e89ff;
}

.admin-dice-skin-option span {
  font-weight: 600;
}

.admin-dice-skin-option:has(input:checked) {
  border-color: #4d749f;
  background: #1b2b3f;
}

.admin-dice-skin-option:has(input:disabled) {
  opacity: 0.88;
}

.monster-form-actions {
  margin: 0.1rem 0 0.35rem;
}

#monsterForm .monster-readonly-view {
  display: none;
}

#monsterForm .monster-edit-fields {
  display: grid;
  gap: 0.62rem;
}

#monsterForm .monster-edit-fields input,
#monsterForm .monster-edit-fields select,
#monsterForm .monster-edit-fields textarea {
  width: 100%;
}

#monsterForm .monster-edit-fields .hint {
  margin: 0.1rem 0 0.15rem;
}

#monsterForm .monster-edit-fields .legendary-actions {
  display: block;
}

#monsterForm .monster-edit-fields .legendary-actions label {
  margin-right: 0.75rem;
}

#monsterForm.monster-form-readonly .monster-edit-fields {
  display: none;
}

#monsterForm.monster-form-readonly .monster-readonly-view {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

#monsterForm.monster-form-readonly #monsterTokenImagePreview {
  display: none !important;
}

.monster-readonly-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.monster-readonly-meta {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  grid-column: 1;
}

.monster-readonly-row {
  display: grid;
  gap: 0.16rem;
}

.monster-readonly-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.monster-readonly-value {
  font-size: 0.98rem;
  color: var(--ink);
}

.monster-readonly-token {
  grid-column: 2;
  width: 11rem;
  height: 11rem;
  justify-self: center;
  align-self: start;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #3b4f66;
  background: #121b28;
}

#monsterImagePreview {
  margin-bottom: 0.9rem;
}

#deleteMonsterBtn {
  background: #7d3942;
  border-color: #964b54;
  color: #f8edf0;
  padding: 0.45rem 0.6rem;
  line-height: normal;
  font-weight: inherit;
}

#deleteMonsterBtn:hover {
  background: #94424c;
}

input,
select,
textarea,
button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
}

input,
select,
textarea {
  background: var(--bg-alt);
  color: var(--ink);
}

.condition-select {
  width: 8.4rem;
  min-width: 8.4rem;
  max-width: 8.4rem;
  font-size: 0.86rem;
  padding-right: 1.35rem;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #f5f8ff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

.list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.list li {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
}

.campaign-overview-row {
  padding: 0.6rem 0.7rem !important;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.campaign-overview-row:hover {
  border-color: #4a6281;
  background: #1a2533;
}

.campaign-overview-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.8fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.campaign-overview-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.campaign-player-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.12rem 0.36rem;
  border-radius: 999px;
  border: 1px solid #334658;
  background: #192430;
  font-size: 0.78rem;
  color: #d6e3f1;
}

.campaign-player-icon {
  width: 1rem;
  height: 1rem;
  object-fit: contain;
  flex: 0 0 auto;
}

.campaign-scenario-count {
  text-align: right;
  color: #b4c2d1;
  font-size: 0.86rem;
  white-space: nowrap;
}

.run-tone-pc {
  background: #1d2b3c;
}

.run-tone-npc {
  background: #1d3328;
}

.run-tone-enemy {
  background: #352127;
}

.run-down {
  background: #6b2f37 !important;
  border-color: #8f4a52 !important;
}

.run-defeated {
  opacity: 0.5;
}

.run-defeated .combatant-name > span:last-child {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.monster-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.monster-list-avatar {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #3b4f66;
  background: #121b28;
  flex: 0 0 auto;
}

.scenario-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.scenario-shared-dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 999px;
  background: #ff3b3b;
  box-shadow: 0 0 0.35rem rgba(255, 59, 59, 0.8);
  flex: 0 0 auto;
}

.legendary-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  background: #6a3f10;
  color: #f7e8cf;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.encounter-action-btn {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.encounter-action-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  position: relative;
}

.encounter-action-icon-map {
  border: 2px solid #d7e5f7;
  border-radius: 1px;
  background:
    linear-gradient(90deg, transparent 0 28%, #d7e5f7 28% 34%, transparent 34% 66%, #d7e5f7 66% 72%, transparent 72%),
    linear-gradient(180deg, transparent 0 30%, #d7e5f7 30% 36%, transparent 36% 64%, #d7e5f7 64% 70%, transparent 70%);
}

.encounter-action-icon-edit {
  width: 12px;
  height: 12px;
  background: transparent;
}

.encounter-action-icon-edit::before {
  content: "";
  position: absolute;
  width: 1px;
  height: 1px;
  left: 0;
  top: 0;
  background: transparent;
  box-shadow:
    8px 0 0 #d7e5f7,
    9px 0 0 #d7e5f7,
    7px 1px 0 #d7e5f7,
    8px 1px 0 #d7e5f7,
    9px 1px 0 #d7e5f7,
    6px 2px 0 #d7e5f7,
    7px 2px 0 #d7e5f7,
    9px 2px 0 #d7e5f7,
    10px 2px 0 #d7e5f7,
    5px 3px 0 #d7e5f7,
    6px 3px 0 #d7e5f7,
    10px 3px 0 #d7e5f7,
    11px 3px 0 #d7e5f7,
    4px 4px 0 #d7e5f7,
    5px 4px 0 #d7e5f7,
    11px 4px 0 #d7e5f7,
    3px 5px 0 #d7e5f7,
    4px 5px 0 #d7e5f7,
    10px 5px 0 #d7e5f7,
    11px 5px 0 #d7e5f7,
    2px 6px 0 #d7e5f7,
    3px 6px 0 #d7e5f7,
    9px 6px 0 #d7e5f7,
    10px 6px 0 #d7e5f7,
    1px 7px 0 #d7e5f7,
    2px 7px 0 #d7e5f7,
    8px 7px 0 #d7e5f7,
    9px 7px 0 #d7e5f7,
    0 8px 0 #d7e5f7,
    1px 8px 0 #d7e5f7,
    7px 8px 0 #d7e5f7,
    8px 8px 0 #d7e5f7,
    0 9px 0 #d7e5f7,
    6px 9px 0 #d7e5f7,
    7px 9px 0 #d7e5f7,
    0 10px 0 #d7e5f7,
    5px 10px 0 #d7e5f7,
    6px 10px 0 #d7e5f7,
    1px 11px 0 #d7e5f7,
    2px 11px 0 #d7e5f7,
    3px 11px 0 #d7e5f7,
    4px 11px 0 #d7e5f7,
    5px 11px 0 #d7e5f7;
}

.encounter-action-icon-edit::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 1px;
  left: 8px;
  top: 10px;
  background: #d7e5f7;
  box-shadow:
    1px 1px 0 #d7e5f7,
    2px 1px 0 #d7e5f7;
}

.encounter-action-icon-initiative {
  width: 0;
  height: 0;
  border-left: 9px solid #d7e5f7;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  margin-left: 2px;
}

.delete-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid #8f4a52;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  font-weight: bold;
}

.delete-btn:hover {
  background: var(--danger-soft);
}

.selectable li {
  cursor: pointer;
}

.selectable li.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-switch {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.run-view {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--bg-alt);
}

.run-split {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(560px, 760px);
  gap: 1rem;
  align-items: start;
}

#pageScenarioRun.scenario-map-layout .run-split {
  grid-template-columns: minmax(0, 1fr);
}

body.page-run #activeMonsterImageWrap {
  position: sticky;
  top: 0.9rem;
  align-self: start;
}

body.page-run .run-page {
  width: calc(100vw - 2rem);
  max-width: none;
  margin-left: calc(50% - 50vw + 1rem);
  margin-right: calc(50% - 50vw + 1rem);
}

body.page-player #pagePlayerHome {
  width: calc(100vw - 2rem);
  max-width: none;
  margin-left: calc(50% - 50vw + 1rem);
  margin-right: calc(50% - 50vw + 1rem);
}

body.page-player #playerLiveWrap {
  margin-bottom: 0;
}

.subpanel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.settings-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
}

.settings-section-head h3 {
  margin: 0;
}

.analytics-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
}

.analytics-controls {
  display: grid;
  gap: 0.35rem;
  max-width: 420px;
  margin-bottom: 0.7rem;
}

.analytics-controls label {
  font-size: 0.82rem;
  color: var(--muted);
}

.analytics-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
}

.analytics-main-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: stretch;
}

.analytics-conditions-panel {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 0.6rem 0.7rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.analytics-conditions-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
}

.analytics-conditions-panel .list {
  margin-bottom: 0;
  flex: 1 1 auto;
}

@media (max-width: 980px) {
  .analytics-main-row {
    grid-template-columns: 1fr;
  }
}

.analytics-encounter-counters {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 0.45rem;
}

.analytics-encounter-counter {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 0.45rem 0.6rem;
  min-width: 150px;
  text-align: right;
}

.analytics-encounter-counter h4 {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}

.analytics-encounter-counter strong {
  display: block;
  margin-top: 0.18rem;
  font-size: 1.06rem;
  color: var(--text);
}

.analytics-metric {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 0.55rem 0.65rem;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.analytics-metric h4 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.analytics-metric strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.9rem;
  line-height: 1.1;
  color: var(--text);
}

.analytics-pc-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.analytics-pc-rank {
  min-width: 2rem;
  color: var(--muted);
  font-weight: 700;
}

.analytics-pc-token {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10, 20, 32, 0.6);
}

.analytics-podium-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.analytics-podium-left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.analytics-podium-medal {
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0d1520;
}

.analytics-podium-gold {
  border-color: #c9a64a !important;
  background: rgba(201, 166, 74, 0.12) !important;
}

.analytics-podium-gold .analytics-podium-medal {
  background: linear-gradient(180deg, #f7d777, #c79c33);
}

.analytics-podium-silver {
  border-color: #98a7b6 !important;
  background: rgba(152, 167, 182, 0.11) !important;
}

.analytics-podium-silver .analytics-podium-medal {
  background: linear-gradient(180deg, #d9e2ea, #8ea0b1);
}

.analytics-podium-bronze {
  border-color: #a57a4d !important;
  background: rgba(165, 122, 77, 0.12) !important;
}

.analytics-podium-bronze .analytics-podium-medal {
  background: linear-gradient(180deg, #d1a073, #99613a);
}

.player-turn-resources {
  margin-left: auto;
  display: inline-flex;
  gap: 0.32rem;
  flex-wrap: wrap;
}

.player-turn-resource-btn {
  border: 1px solid rgba(101, 186, 124, 0.85);
  background: rgba(40, 98, 57, 0.78);
  color: #eefcf1;
  border-radius: 8px;
  font-size: 0.75rem;
  padding: 0.18rem 0.48rem;
  line-height: 1.1;
  cursor: pointer;
}

.player-turn-resource-btn.used {
  border-color: rgba(194, 98, 110, 0.88);
  background: rgba(125, 43, 54, 0.84);
  color: #ffeef0;
}

.edit-add-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(560px, 2.3fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.add-enemy-form {
  align-content: start;
}

.add-combatant-library-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.add-combatant-library-item {
  width: 100%;
  text-align: left;
  padding: 0.38rem 0.52rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.add-combatant-library-item.active {
  border-color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary) 20%, var(--panel-2));
}

.add-combatant-library-item:hover {
  border-color: var(--primary);
}

.add-enemy-form label,
.add-enemy-form legend,
#monsterForm label,
#monsterForm legend {
  font-size: 0.82rem;
  color: var(--muted);
}

.add-enemy-form fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0;
  padding: 0.45rem 0.6rem;
}

#monsterForm fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0;
  padding: 0.45rem 0.6rem;
}

.legendary-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.legendary-actions label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.enemy-preview-panel {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: static;
}

#enemyMonsterPreview {
  width: 100%;
  max-height: calc((72vh - 4rem) * 0.6);
  object-fit: contain;
  align-self: center;
}

@media (max-width: 1100px) {
  .edit-add-layout {
    grid-template-columns: 1fr;
  }

  .enemy-preview-panel {
    position: static;
  }

  #enemyMonsterPreview {
    max-height: 36vh;
  }
}

.combatant-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.combatant-row input[type="number"] {
  width: 85px;
}

.run-controls {
  margin-bottom: 1.1rem;
}

.run-controls #resetCombatBtn {
  margin-left: auto;
}

.run-combat-layout {
  display: block;
}

.run-map-mode {
  display: grid;
  grid-template-columns: minmax(280px, 25%) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

#runMapWrap {
  margin-bottom: 0.3rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.run-map-mode #runMapWrap {
  order: 2;
  position: relative;
  z-index: 1;
  margin-bottom: 0;
}

#runMapViewport {
  position: relative;
  --map-token-size: 44px;
  width: 100%;
  height: calc(100vh - 14.5rem);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1420;
  cursor: grab;
  touch-action: none;
}

#runMapViewport.is-dragging {
  cursor: grabbing;
}

.run-map-token-size-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.run-map-token-size-controls label {
  font-size: 0.8rem;
  color: var(--muted);
}

.run-map-token-size-controls input[type="range"] {
  width: 160px;
}

.run-map-token-size-controls input[type="number"] {
  width: 3.9rem;
  padding: 0.12rem 0.28rem;
  border-radius: 6px;
  border: 1px solid rgba(126, 152, 176, 0.4);
  background: rgba(12, 25, 38, 0.62);
  color: #d7e5f7;
  font-size: 0.8rem;
}

.map-touch-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 8;
  padding: 0.5rem 0.45rem;
  border-radius: 16px;
  border: 1px solid rgba(121, 145, 168, 0.3);
  background: rgba(8, 17, 29, 0.75);
  box-shadow: 0 10px 22px rgba(2, 8, 14, 0.35);
  backdrop-filter: blur(3px);
}

.map-tool-btn {
  width: 2.35rem;
  height: 2.35rem;
  min-width: 2.35rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: 1px solid rgba(126, 152, 176, 0.32);
  background: rgba(16, 29, 44, 0.75);
  color: #d9e8f7;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 140ms ease, border-color 140ms ease, background 140ms ease;
}

.map-tool-btn:hover,
.map-tool-btn:focus-visible {
  opacity: 0.98;
  background: rgba(22, 39, 58, 0.92);
  border-color: rgba(163, 193, 222, 0.55);
}

.map-tool-btn[aria-pressed="true"] {
  opacity: 0.98;
  background: rgba(65, 39, 42, 0.9);
  border-color: rgba(218, 126, 126, 0.62);
  color: #ffe5e5;
}

.map-tool-icon {
  width: 1.2rem;
  height: 1.2rem;
  display: block;
}

#runMapFogEraseBtn .map-tool-icon {
  width: 1.38rem;
  height: 1.38rem;
}

.map-touch-controls-dm {
  top: auto;
  bottom: 0.7rem;
  left: 0.7rem;
}

.map-fog-brush-controls {
  position: absolute;
  left: 4.15rem;
  bottom: 0.7rem;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.4rem 0.6rem;
  min-width: 200px;
  padding: 0.48rem 0.62rem;
  border-radius: 12px;
  border: 1px solid rgba(121, 145, 168, 0.3);
  background: rgba(8, 17, 29, 0.75);
  box-shadow: 0 10px 22px rgba(2, 8, 14, 0.35);
  backdrop-filter: blur(3px);
}

.map-fog-brush-controls label {
  grid-column: 1 / 3;
  font-size: 0.74rem;
  color: #bfd4e9;
  letter-spacing: 0.02em;
}

.map-fog-brush-controls input[type="range"] {
  width: 100%;
}

.map-fog-brush-controls input[type="number"] {
  width: 4.4rem;
  padding: 0.16rem 0.3rem;
  border-radius: 6px;
  border: 1px solid rgba(126, 152, 176, 0.4);
  background: rgba(12, 25, 38, 0.62);
  color: #e4effa;
  font-size: 0.84rem;
}

.map-fog-brush-shape-group {
  grid-column: 1 / 3;
  display: inline-flex;
  gap: 0.38rem;
}

.map-fog-brush-shape-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.map-fog-brush-shape-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(126, 152, 176, 0.42);
  background: rgba(12, 25, 38, 0.62);
  color: #dbe9f7;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.map-fog-brush-shape-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.map-fog-brush-shape-group input[type="radio"]:checked + .map-fog-brush-shape-btn {
  border-color: rgba(111, 152, 255, 0.9);
  background: rgba(72, 124, 240, 0.28);
  color: #eef6ff;
}

.map-fog-brush-shape-group input[type="radio"]:focus-visible + .map-fog-brush-shape-btn {
  outline: 2px solid rgba(136, 181, 255, 0.7);
  outline-offset: 1px;
}

.run-map-fog-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 1.5px solid rgba(255, 245, 219, 0.92);
  background: rgba(255, 231, 173, 0.1);
  box-shadow: 0 0 0 1px rgba(7, 15, 22, 0.75), inset 0 0 0 1px rgba(7, 15, 22, 0.45);
  pointer-events: none;
  z-index: 9;
}

.run-map-fog-cursor.is-square {
  border-radius: 4px;
}

#runMapViewport.drag-locked,
.player-map-viewport.drag-locked {
  cursor: default;
}

#runMapViewport.fog-paint-mode {
  cursor: crosshair;
}

#runMapViewport.drag-locked .run-map-token,
.player-map-viewport.drag-locked .player-map-token {
  cursor: default;
}

#runMapScene {
  position: absolute;
  top: 0;
  left: 0;
}

.run-map-fog-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  pointer-events: none;
  opacity: 0.58;
  z-index: 2;
}

#runMapTokens {
  position: absolute;
  inset: 0;
  z-index: 3;
}

#runMapPings,
#playerMapPings {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.map-ping-marker {
  position: absolute;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
}

.map-ping-core,
.map-ping-wave {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  pointer-events: none;
}

.map-ping-core {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 170, 170, 0.98);
  color: rgba(125, 8, 8, 1);
  font-size: 1.08rem;
  line-height: 1;
  font-weight: 900;
  border: 3px solid rgba(112, 12, 12, 1);
  box-shadow:
    0 0 0 2px rgba(255, 120, 120, 0.78),
    0 0 30px rgba(255, 52, 52, 0.98),
    0 0 56px rgba(220, 25, 25, 0.82);
}

.map-ping-wave {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 58, 58, 0.98);
  box-shadow: 0 0 14px rgba(255, 44, 44, 0.86);
  animation: map-ping-wave 980ms ease-out forwards;
}

@keyframes map-ping-wave {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.38);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(6.6);
  }
}

.run-map-token {
  --token-scale: 1;
  --token-size-effective: calc(var(--map-token-size) * var(--token-scale));
  position: absolute;
  transform: translate(-50%, -50%);
  width: var(--token-size-effective);
  height: var(--token-size-effective);
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #7db0ff;
  background: rgba(10, 20, 32, 0.86);
  box-shadow: 0 0 0 2px rgba(5, 12, 20, 0.5);
  cursor: grab;
  z-index: 4;
  overflow: visible;
}

.run-map-token.token-pc {
  border-color: #7db0ff;
  background: rgba(10, 20, 32, 0.86);
}

.run-map-token.token-enemy {
  border-color: #d66c6c;
  background: rgba(48, 20, 24, 0.88);
}

.run-map-token.token-npc {
  border-color: #63b78a;
  background: rgba(20, 40, 30, 0.88);
}

.run-map-token.is-dragging {
  cursor: grabbing;
}

.run-map-token.reveal-moment-token,
.player-map-token.reveal-moment-token {
  animation: reveal-token-bloom 1450ms cubic-bezier(0.14, 0.78, 0.18, 1) 1;
}

.run-map-token.token-fade-out,
.player-map-token.token-fade-out {
  pointer-events: none;
  animation: map-token-fade-out 240ms ease-in forwards;
}

.run-map-token-icon {
  width: calc(var(--token-size-effective) * 0.9);
  height: calc(var(--token-size-effective) * 0.9);
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.run-map-token-icon.token-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 999px;
  image-rendering: auto;
}

.run-map-token-name {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  max-width: none;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(8, 13, 20, 0.82);
  border: 1px solid rgba(66, 84, 105, 0.7);
  color: #e6edf5;
  font-size: clamp(0.45rem, calc(-0.3rem + (var(--token-size-effective) * 0.03)), 3rem);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
  pointer-events: none;
}

.run-map-token.token-pc.is-active {
  border-width: 3px;
  animation: none;
  box-shadow:
    0 0 0 2px rgba(5, 12, 20, 0.5),
    0 0 0 3px rgba(74, 132, 196, 1),
    0 0 34px rgba(240, 254, 255, 1),
    0 0 70px rgba(170, 223, 255, 1);
}

.run-map-token.token-enemy.is-active {
  border-width: 3px;
  animation: token-glow-pulse-red 1.9s ease-in-out infinite;
  box-shadow:
    0 0 0 2px rgba(20, 5, 8, 0.5),
    0 0 0 3px rgba(158, 62, 69, 1),
    0 0 26px rgba(255, 228, 228, 1),
    0 0 56px rgba(234, 124, 124, 1);
}

.run-map-token.token-npc.is-active {
  border-width: 3px;
  animation: none;
  box-shadow:
    0 0 0 2px rgba(5, 20, 12, 0.5),
    0 0 0 3px rgba(62, 136, 96, 1),
    0 0 34px rgba(242, 255, 248, 1),
    0 0 70px rgba(142, 222, 178, 1);
}

#runMapImage {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  user-select: none;
  pointer-events: none;
  object-fit: unset;
}

.run-map-mode #runInitiativeWrap {
  order: 1;
  position: relative;
  z-index: 6;
  max-height: calc(78vh + 1.8rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.run-map-mode #runOrderList {
  font-size: 0.78rem;
  min-width: 0;
}

.run-map-mode #runOrderList li {
  padding: 0.3rem 0.38rem;
  min-width: 0;
}

.run-map-mode .run-order-init {
  width: 30px !important;
  padding: 0.22rem 0.3rem;
  text-align: center;
}

.run-map-mode .combatant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "left vis"
    ". controls";
  gap: 0.22rem 0.45rem;
  min-width: 0;
  align-items: start;
}

.run-map-mode li.map-character-single-line .combatant-row {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "left controls";
  align-items: center;
}

.run-map-mode .run-order-init-readonly {
  height: 1.65rem;
  font-size: 0.76rem;
}

.run-map-mode .run-order-hp {
  width: 54px !important;
}

.run-map-mode .run-order-delta {
  width: 40px !important;
}

.run-map-mode .combatant-right {
  grid-area: controls;
  justify-self: end;
  gap: 0.2rem;
  min-width: 0;
  flex-wrap: nowrap;
  align-items: center;
  max-width: 100%;
}

.run-map-mode .condition-select {
  width: 6.2rem;
  min-width: 6.2rem;
  max-width: 6.2rem;
  font-size: 0.78rem;
}

.run-map-mode .reaction-btn.reaction-die {
  width: 1.7rem !important;
  min-width: 1.7rem !important;
  max-width: 1.7rem !important;
  height: 1.7rem !important;
  min-height: 1.7rem !important;
  max-height: 1.7rem !important;
  flex: 0 0 1.7rem;
  font-size: 0.82rem !important;
}

.run-map-mode .legendary-btn {
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.64rem;
}

.run-header-actions {
  align-items: center;
  gap: 0.55rem;
}

.run-title-row {
  align-items: center;
  gap: 0.45rem;
}

.run-scenario-shared-dot {
  width: 1.12rem;
  height: 1.12rem;
  box-shadow: 0 0 0.5rem rgba(255, 59, 59, 0.9);
}

.combatant-right {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

.combatant-line-main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.run-map-mode .combatant-line-main {
  grid-area: left;
  min-width: 0;
  align-self: center;
}

.run-map-mode .combatant-name > span:last-child {
  white-space: nowrap;
}

.run-map-mode .map-character-condition-inline {
  margin-left: auto;
}

.combatant-visibility-inline {
  grid-area: vis;
  justify-self: end;
  align-self: center;
  position: static;
}

.run-order-init {
  width: 40px !important;
}

.edit-order-init {
  width: 2.5rem;
  min-width: 2.5rem;
  text-align: center;
}

#combatantEditList .combatant-row {
  align-items: center;
}

#combatantEditList .edit-combatant-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.run-order-init-readonly {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(12, 17, 24, 0.78);
  font-size: 0.95rem;
  font-weight: 600;
}

.readonly-control {
  pointer-events: none;
  cursor: default;
}

.run-order-hp {
  width: 64px !important;
}

.run-order-delta {
  width: 48px !important;
}

.reaction-btn {
  border-color: #4e8f66;
  background: #2f7f52;
  color: #ebfff2;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.reaction-btn:hover {
  background: #3a9963;
}

.reaction-btn.used {
  border-color: #8f4e56;
  background: #a14450;
  color: #ffeef0;
}

.reaction-btn.used:hover {
  background: #bb4e5b;
}

.reaction-die {
  width: 1.7rem;
  height: 1.7rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(50% 0%, 86% 18%, 100% 50%, 86% 82%, 50% 100%, 14% 82%, 0% 50%, 14% 18%);
}

.legendary-track {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  margin-left: 0.2rem;
}

.legendary-btn {
  width: 1.45rem;
  height: 1.45rem;
  border-color: #9c7d35;
  background: #7b6127;
  color: #fff4d6;
  font-size: 0.74rem;
}

.legendary-btn:hover {
  background: #94762f;
}

.legendary-btn.used {
  border-color: #4a5461;
  background: #2b333d;
  color: #b6c1d0;
}

.legendary-btn.used:hover {
  background: #36404c;
}

.enemy-damage-btn {
  background: #7d3942;
  border-color: #964b54;
}

.enemy-damage-btn:hover {
  background: #94424c;
}

.enemy-heal-btn {
  background: #2d7248;
  border-color: #3f8859;
}

.enemy-heal-btn:hover {
  background: #36875a;
}

.npc-damage-btn {
  background: #8a3f47;
  border-color: #a04f58;
}

.npc-damage-btn:hover {
  background: #a44b54;
}

.npc-heal-btn {
  background: #2f7d4f;
  border-color: #449364;
}

.npc-heal-btn:hover {
  background: #399861;
}

.visibility-toggle {
  font-size: 0.86rem;
  padding: 0.26rem 0.62rem;
  line-height: 1.2;
  background: #2f7f52;
  border-color: #4e8f66;
}

.visibility-toggle:hover {
  background: #3a9963;
}

.visibility-toggle.is-hidden {
  background: #6c727b;
  border-color: #7e8793;
}

.visibility-toggle.is-hidden:hover {
  background: #7a8390;
}

.visibility-toggle.reveal-moment-btn {
  animation: reveal-toggle-pulse 1200ms cubic-bezier(0.14, 0.78, 0.18, 1) 1;
}

.combatant-hidden-for-players {
  opacity: 0.8;
}

.reveal-moment-row {
  animation: reveal-row-flash 1250ms cubic-bezier(0.14, 0.78, 0.18, 1) 1;
}

.run-input-locked {
  cursor: pointer;
}

.field-prefix {
  color: var(--muted);
  font-size: 0.9rem;
}

.run-page .combatant-right .field-prefix {
  margin-left: 0.3rem;
}

.run-page input {
  text-align: center;
}

@keyframes reveal-row-flash {
  0% {
    background: rgba(167, 205, 244, 0);
  }
  18% {
    background: rgba(167, 205, 244, 0.2);
  }
  100% {
    background: rgba(167, 205, 244, 0);
  }
}

@keyframes reveal-toggle-pulse {
  0% {
    transform: scale(1);
  }
  38% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes reveal-token-bloom {
  0% {
    transform: translate(-50%, -50%) scale(0.55);
    filter: saturate(1.35) brightness(1.24);
  }
  22% {
    transform: translate(-50%, -50%) scale(1.18);
  }
  56% {
    transform: translate(-50%, -50%) scale(0.95);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    filter: saturate(1) brightness(1);
  }
}

@keyframes map-token-fade-out {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 14px)) scale(0.82);
  }
}

.combatant-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.combatant-icon {
  width: 2.9rem;
  height: 2.9rem;
  display: inline-block;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(10, 18, 30, 0.75);
}

.combatant-icon.token-portrait {
  object-fit: cover;
  object-position: center;
  image-rendering: auto;
}

.condition-chip {
  position: relative;
  border: none;
  background: #223044;
  color: #d7e5f7;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  margin-top: 0.22rem;
  margin-right: 0.32rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.condition-chip-readonly {
  cursor: default;
}

.condition-chip:hover::after {
  content: none;
  display: none;
}

/* In map layouts, flip tooltip direction for bottom rows so it stays visible
   instead of being clipped by the scroll container. */
.run-map-mode #runOrderList li:nth-last-child(-n + 4) .condition-chip:hover::after,
#playerLiveWrap.player-map-mode #playerLiveCombatantList li:nth-last-child(-n + 4) .condition-chip:hover::after {
  top: auto;
  bottom: 130%;
}

.condition-tooltip-floating {
  position: fixed;
  z-index: 9999;
  width: min(420px, calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  background: #0f141c;
  color: #e6edf5;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  white-space: normal;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.38);
}

.map-statblock-hover {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  background: #0f141c;
  border: 1px solid #2d3846;
  border-radius: 8px;
  padding: 0.35rem;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.42);
}

.map-statblock-hover img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 94vh;
  object-fit: contain;
  border-radius: 4px;
}

.condition-tooltip-paragraph {
  margin: 0;
}

.condition-tooltip-paragraph + .condition-tooltip-paragraph {
  margin-top: 0.48rem;
}

.condition-tooltip-lead {
  font-weight: 700;
  font-style: italic;
}

.condition-tooltip-action-label {
  font-weight: 700;
  font-style: italic;
}

.turn-active {
  border-color: #7db0ff !important;
  background: #5e86bd !important;
  box-shadow: inset 0 0 0 2px rgba(173, 208, 255, 0.45);
}

.turn-active.run-down {
  background: #6b2f37 !important;
  border-color: #8f4a52 !important;
}

.turn-active .combatant-name {
  color: #f6fbff;
  font-weight: 700;
}

.turn-active .condition-chip {
  opacity: 0.78;
}

li.map-token-hover-linked {
  border-color: #e3b861 !important;
}

li.turn-active.map-token-hover-linked {
  border-color: #e3b861 !important;
}

.status {
  display: none;
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: min(92vw, 380px);
  display: grid;
  gap: 0.45rem;
  z-index: 1200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: start;
  padding: 0.56rem 0.62rem;
  border-radius: 8px;
  border: 1px solid #3a4a5c;
  background: #172231;
  color: #e6edf5;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translateY(-8px);
  animation: toast-enter 170ms ease-out forwards;
}

.toast.toast-info {
  border-color: #3e5672;
  background: #18263a;
}

.toast.toast-success {
  border-color: #3c7053;
  background: #1a3126;
}

.toast.toast-error {
  border-color: #8f4a52;
  background: #372126;
}

.toast-message {
  font-size: 0.92rem;
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-close {
  padding: 0.1rem 0.38rem;
  min-width: 1.5rem;
  line-height: 1;
  border: 1px solid #56657a;
  background: rgba(9, 15, 24, 0.25);
  color: #dbe8f8;
}

.toast-close:hover {
  background: rgba(9, 15, 24, 0.45);
}

.toast.is-exiting {
  animation: toast-exit 160ms ease-in forwards;
}

.dice-overlay {
  position: fixed;
  right: 1.75rem;
  bottom: 1.75rem;
  z-index: 1180;
  display: grid;
  justify-items: end;
  gap: 0.7rem;
}

.dice-panel {
  width: min(92vw, 22rem);
  padding: 0.85rem 0.9rem;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.34);
}

.dice-result-toast {
  width: min(92vw, 22rem);
  padding: 0.7rem 0.85rem;
  background: linear-gradient(180deg, rgba(23, 33, 47, 0.97), rgba(16, 24, 35, 0.98));
  border: 1px solid #3e5370;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.3);
  text-align: center;
  font-family: inherit;
}

.dice-result-toast-head {
  display: block;
}

.dice-result-toast-expression {
  color: #b6c6dc;
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.dice-result-toast-total {
  color: #eff5ff;
  display: block;
  margin-top: 0.2rem;
  font-size: 1.95rem;
  line-height: 1.05;
  font-weight: 700;
  text-align: center;
}

.dice-result-toast-breakdown {
  margin-top: 0.42rem;
  color: #d5e1ef;
  font-size: 0.88rem;
  line-height: 1.35;
  opacity: 0.92;
  text-align: center;
}

.dice-panel-head {
  margin-bottom: 0.65rem;
}

.dice-panel-head h3 {
  margin: 0;
}

.dice-panel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.dice-panel-actions button:disabled {
  background: #304257;
  border-color: #49607b;
  color: #b9cbe0;
  cursor: default;
  opacity: 0.72;
}

.dice-panel-actions button:disabled:hover {
  background: #304257;
}

.dice-reset-btn {
  background: #243144;
  border-color: #4e627d;
  color: #dce8f8;
}

.dice-reset-btn:hover {
  background: #2b3a4f;
}

.dice-preset-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.62rem;
}

.dice-roll-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 calc(25% - 0.375rem);
  min-width: 0;
  padding: 0.5rem 0.4rem;
  min-height: 3rem;
  font-weight: 700;
}

.dice-roll-btn.has-pool-count::after {
  content: attr(data-pool-count);
  position: absolute;
  top: 0.18rem;
  right: 0.18rem;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.24rem;
  border-radius: 999px;
  border: 1px solid #7f9fca;
  background: #d9e8ff;
  color: #1f3f6b;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 12px rgba(5, 10, 20, 0.22);
}

.dice-roll-btn-icon {
  flex-direction: column;
  gap: 0.36rem;
  padding-block: 0.48rem 0.38rem;
}

.dice-roll-btn-icon span {
  line-height: 1;
}

.dice-roll-shape {
  width: 1.85rem;
  height: 1.85rem;
  display: block;
  fill: currentColor;
}

.dice-roll-shape-d100 {
  width: 2.3rem;
  height: 1.85rem;
}

.dice-toggle-btn {
  position: relative;
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.28));
}

.dice-toggle-btn:hover,
.dice-toggle-btn:focus-visible {
  background: transparent;
  border-color: transparent;
}

.dice-toggle-btn svg {
  display: block;
  width: 100%;
  height: 100%;
}

.dice-pool-badge {
  position: absolute;
  top: -0.15rem;
  right: -0.12rem;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  border: 1px solid #7f9fca;
  background: #d9e8ff;
  color: #1f3f6b;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(5, 10, 20, 0.28);
}

.dice-toggle-disc {
  fill: #6d6d65;
}

.dice-toggle-icon {
  fill: #74a8ff;
}

.dice-toggle-btn:hover .dice-toggle-disc,
.dice-toggle-btn:focus-visible .dice-toggle-disc {
  fill: #77776f;
}

.dice-toggle-btn:hover .dice-toggle-icon,
.dice-toggle-btn:focus-visible .dice-toggle-icon {
  fill: #8cbaff;
}

.dice-stage {
  position: fixed;
  inset: 0;
  z-index: 1170;
  overflow: hidden;
  pointer-events: none;
}

.dice-canvas-host {
  width: 100%;
  height: 100%;
}

.dice-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 52%, rgba(14, 20, 30, 0.16), rgba(14, 20, 30, 0) 58%);
}

.dice-stage .dice-box-canvas {
  width: 100% !important;
  height: 100% !important;
  opacity: 1;
  transition: opacity 220ms ease;
}

.dice-stage .dice-box-canvas--hide {
  opacity: 0;
}

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

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .toast.is-exiting {
    animation: none;
    opacity: 0;
  }
}

.monster-image {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}

#editScenarioMapPreview {
  max-height: 32vh;
  object-fit: contain;
  cursor: zoom-in;
}

#activeMonsterImage {
  cursor: zoom-in;
}

#enemyMonsterPreview {
  cursor: zoom-in;
}

#monsterTokenImagePreview,
#libraryEntryTokenImagePreview {
  max-width: 12rem;
  max-height: 12rem;
  object-fit: cover;
}

.paste-target-group {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.4rem 0.5rem 0.2rem;
}

.paste-target-group.active {
  border-color: #4d78b9;
  background: rgba(66, 109, 176, 0.16);
}

#settingsProfileSection {
  position: relative;
  min-height: 8.6rem;
  padding-right: 6.8rem;
}

#settingsPasswordSection {
  margin-top: 0;
}

#settingsPasswordSection label {
  display: block;
  margin-top: 0.5rem;
}

#settingsPasswordSection input {
  margin-top: 0.3rem;
}

#settingsPasswordSection .settings-password-row {
  margin-top: 0.55rem;
}

#settingsAccountSection .row {
  margin-bottom: 0.75rem;
}

#settingsCampaignSection .row {
  margin-bottom: 0.75rem;
}

#settingsDiceSkinSection .row {
  margin-bottom: 0.75rem;
}

#settingsProfileSection .row {
  margin-top: 0.75rem;
}

#settingsProfileImagePreview {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 4.25rem;
  height: 4.25rem;
  max-width: none;
  object-fit: cover;
  border-radius: 999px;
}

.dice-shop-cta-btn {
  margin-top: 0.9rem;
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 1rem;
  background: linear-gradient(135deg, #6f1c2d, #b1354d 54%, #db6980);
  border-color: #f1b5c1;
  color: #fff7fb;
  box-shadow:
    0 0 0 1px rgba(255, 222, 230, 0.15),
    0 0 18px rgba(219, 105, 128, 0.45),
    0 0 34px rgba(143, 29, 44, 0.35);
  animation: dice-shop-cta-glow 1.9s ease-in-out infinite;
}

.dice-shop-cta-btn:hover {
  background: linear-gradient(135deg, #7f2033, #c53f59 54%, #e87d93);
}

.settings-dice-shop-btn {
  margin-top: 0;
  width: auto;
  min-width: 0;
  padding: 0.48rem 0.78rem;
  font-size: 0.88rem;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow:
    0 0 0 1px rgba(255, 222, 230, 0.12),
    0 0 14px rgba(219, 105, 128, 0.34),
    0 0 26px rgba(143, 29, 44, 0.24);
}

.dice-overlay-shop-btn {
  margin-top: 0.8rem;
}

.dice-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.dice-shop-checkout-badge {
  display: inline-flex;
  align-items: center;
  gap: 1.04rem;
  padding: 0.8rem 1.28rem;
  border-radius: 999px;
  border: 1px solid #3b495b;
  background: linear-gradient(180deg, rgba(26, 36, 49, 0.96), rgba(18, 26, 37, 0.98));
  color: #dce8f8;
  font-size: 1.44rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
}

.dice-shop-checkout-image {
  display: block;
  height: 3.04rem;
  width: auto;
  object-fit: contain;
}

.dice-shop-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 0.85rem;
  align-content: start;
  height: 100%;
}

.dice-shop-card h3 {
  margin: 0;
}

.dice-shop-preview {
  display: flex;
  justify-content: center;
  padding: 0.6rem;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(72, 88, 112, 0.88);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 45%),
    linear-gradient(180deg, rgba(31, 41, 56, 0.96), rgba(18, 25, 35, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 14px 28px rgba(0, 0, 0, 0.2);
}

.dice-shop-preview-image {
  display: block;
  width: min(84%, 220px);
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 0.7rem;
}

.dice-shop-banner-slot {
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dice-shop-banner-slot.is-empty {
  visibility: hidden;
}

.dice-shop-special-banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.38rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 155, 89, 0.38);
  background: linear-gradient(180deg, rgba(82, 34, 19, 0.96), rgba(51, 19, 12, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 203, 167, 0.08),
    0 10px 22px rgba(14, 6, 5, 0.24);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  color: #ffd8ba;
  letter-spacing: 0.01em;
}

.dice-shop-special-banner.offer {
  border-color: rgba(255, 116, 116, 0.4);
  background: linear-gradient(180deg, rgba(118, 27, 35, 0.97), rgba(77, 16, 25, 0.98));
  color: #ffe4e6;
  font-variant-numeric: tabular-nums;
}

.dice-shop-description {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  height: 100%;
  font-size: 0.98rem;
  line-height: 1.45;
  color: #c4d2e5;
}

.dice-shop-description-lead {
  margin: 0;
  font-style: italic;
  font-weight: 700;
  color: #eef4fb;
}

.dice-shop-description-paragraph {
  margin: 0;
}

.dice-shop-description-list-title {
  margin: 0;
  margin-top: auto;
  padding-top: 0.3rem;
  font-weight: 700;
  color: #e9f2fc;
}

.dice-shop-description-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.28rem;
}

.dice-shop-description-list li {
  margin: 0;
}

.dice-shop-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.58rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid #415166;
  background: #1a2431;
  color: #d6e3f4;
}

.dice-shop-status.equipped {
  border-color: #4d749f;
  background: #1c3147;
  color: #e9f5ff;
}

.dice-shop-status.unlocked {
  border-color: #426a56;
  background: #223b31;
  color: #d7f3e4;
}

.dice-shop-status.locked {
  border-color: #6a5562;
  background: #31232d;
  color: #f0dce6;
}

.dice-shop-action-btn.owned {
  background: linear-gradient(180deg, #253141, #1a2330);
  border-color: #3b4a5e;
  color: #e5edf7;
}

.dice-shop-action-btn.owned:hover {
  background: linear-gradient(180deg, #2d3a4c, #202a38);
}

.dice-shop-action-btn.equipped {
  border-color: #4d749f;
  background: #1c3147;
  color: #dceeff;
}

.dice-shop-action-btn.locked {
  background: linear-gradient(180deg, #5a2e62, #432149);
  border-color: #8a5b92;
  color: #f7e9fb;
}

.dice-shop-action-btn.locked.special-offer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.dice-shop-action-btn.locked:hover {
  background: linear-gradient(180deg, #67356f, #4c2553);
}

.dice-shop-action-btn-label {
  white-space: nowrap;
}

.dice-shop-action-btn-old-price {
  white-space: nowrap;
  color: rgba(247, 233, 251, 0.72);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.dice-shop-action-btn-sale-price {
  white-space: nowrap;
  font-weight: 800;
  color: #fff0c8;
}

.dice-shop-action-btn:disabled {
  opacity: 0.88;
  cursor: default;
}

@keyframes dice-shop-cta-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(255, 222, 230, 0.15),
      0 0 18px rgba(219, 105, 128, 0.42),
      0 0 34px rgba(143, 29, 44, 0.32);
    transform: translateY(0);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 226, 233, 0.22),
      0 0 26px rgba(233, 124, 145, 0.56),
      0 0 42px rgba(180, 42, 66, 0.42);
    transform: translateY(-1px);
  }
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 14, 0.86);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 2rem;
}

.victory-confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1100;
  overflow: hidden;
}

.victory-confetti-piece {
  position: absolute;
  left: 50%;
  top: 38%;
  border-radius: 2px;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  animation-name: victory-confetti-burst;
  animation-timing-function: cubic-bezier(0.16, 0.84, 0.31, 0.99);
  animation-fill-mode: forwards;
}

@keyframes victory-confetti-burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 260px)) rotate(640deg);
  }
}

.campaign-action-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 14, 0.72);
  display: grid;
  place-items: center;
  z-index: 950;
  padding: 1.5rem;
}

.campaign-action-dialog {
  width: min(560px, calc(100vw - 2rem));
  margin: 0;
  border-color: #3a495c;
}

.campaign-action-head {
  margin-bottom: 0.8rem;
}

.campaign-action-head h3 {
  margin: 0;
}

.image-modal-close {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
}

.image-modal-img {
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
}

.hint {
  color: var(--muted);
  font-style: normal;
}

.hidden {
  display: none !important;
}

.app-footer-logo-wrap {
  margin-top: 1.2rem;
  padding-top: 0.6rem;
  display: flex;
  justify-content: center;
}

.app-footer-logo {
  width: min(26vw, 180px);
  max-width: 100%;
  height: auto;
  opacity: 0.86;
}

#playerLiveMapWrap {
  margin-bottom: 0.2rem;
}

#playerLiveSceneWrap {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.player-live-scene-image {
  width: 100%;
  max-height: calc(100vh - 18rem);
  object-fit: contain;
  cursor: zoom-in;
}

.scene-view-grid {
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.5fr);
}

.scene-preview-image {
  width: 100%;
  max-height: calc(100vh - 22rem);
  object-fit: contain;
  cursor: zoom-in;
}

.scene-upload-preview {
  width: 100%;
  max-height: 13rem;
  object-fit: contain;
  cursor: zoom-in;
}

#sceneList .list-row {
  justify-content: space-between;
  align-items: center;
}

#playerLiveWrap.player-map-mode {
  display: grid;
  grid-template-columns: minmax(240px, 25%) minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "initiative map";
  column-gap: 0.75rem;
  row-gap: 0.55rem;
}

#playerLiveWrap.player-map-mode > .row.between {
  grid-area: header;
}

#playerLiveInitiativeWrap {
  min-width: 0;
}

#playerLiveWrap.player-map-mode #playerLiveInitiativeWrap {
  grid-area: initiative;
  position: relative;
  z-index: 6;
  max-height: calc(100vh - 20rem);
  overflow-y: auto;
  overflow-x: hidden;
}

#playerLiveWrap.player-map-mode #playerLiveMapWrap {
  grid-area: map;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.player-map-viewport {
  position: relative;
  --map-token-size: 44px;
  width: 100%;
  height: calc(100vh - 20rem);
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1420;
  cursor: grab;
  touch-action: none;
}

.player-map-viewport.is-dragging {
  cursor: grabbing;
}

.player-map-scene {
  position: absolute;
  top: 0;
  left: 0;
}

.player-map-fog-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  object-fit: unset;
  pointer-events: none;
  opacity: 0.72;
  z-index: 2;
}

.player-map-scene .monster-image {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  object-fit: unset;
  pointer-events: none;
}

.player-map-tokens {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.player-map-token {
  --token-scale: 1;
  --token-size-effective: calc(var(--map-token-size) * var(--token-scale));
  position: absolute;
  transform: translate(-50%, -50%);
  width: var(--token-size-effective);
  height: var(--token-size-effective);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #7db0ff;
  background: rgba(10, 20, 32, 0.86);
  box-shadow: 0 0 0 2px rgba(5, 12, 20, 0.5);
  z-index: 2;
  overflow: visible;
  cursor: grab;
}

.player-map-token.is-dragging {
  cursor: grabbing;
}

.player-map-token.token-pc {
  border-color: #7db0ff;
  background: rgba(10, 20, 32, 0.86);
}

.player-map-token.token-enemy {
  border-color: #d66c6c;
  background: rgba(48, 20, 24, 0.88);
}

.player-map-token.token-npc {
  border-color: #63b78a;
  background: rgba(20, 40, 30, 0.88);
}

.player-map-token-icon {
  width: calc(var(--token-size-effective) * 0.9);
  height: calc(var(--token-size-effective) * 0.9);
  object-fit: contain;
  image-rendering: pixelated;
}

.player-map-token-icon.token-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 999px;
  image-rendering: auto;
}

.player-map-token-name {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  max-width: none;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(8, 13, 20, 0.82);
  border: 1px solid rgba(66, 84, 105, 0.7);
  color: #e6edf5;
  font-size: clamp(0.45rem, calc(-0.3rem + (var(--token-size-effective) * 0.03)), 3rem);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
  pointer-events: none;
}

.player-map-token.token-pc.is-active {
  border-width: 3px;
  animation: none;
  box-shadow:
    0 0 0 2px rgba(5, 12, 20, 0.5),
    0 0 0 3px rgba(74, 132, 196, 1),
    0 0 34px rgba(240, 254, 255, 1),
    0 0 70px rgba(170, 223, 255, 1);
}

.player-map-token.token-enemy.is-active {
  border-width: 3px;
  animation: token-glow-pulse-red 1.9s ease-in-out infinite;
  box-shadow:
    0 0 0 2px rgba(20, 5, 8, 0.5),
    0 0 0 3px rgba(158, 62, 69, 1),
    0 0 26px rgba(255, 228, 228, 1),
    0 0 56px rgba(234, 124, 124, 1);
}

.player-map-token.token-npc.is-active {
  border-width: 3px;
  animation: none;
  box-shadow:
    0 0 0 2px rgba(5, 20, 12, 0.5),
    0 0 0 3px rgba(62, 136, 96, 1),
    0 0 34px rgba(242, 255, 248, 1),
    0 0 70px rgba(142, 222, 178, 1);
}

@keyframes token-glow-pulse-blue {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(5, 12, 20, 0.5),
      0 0 0 3px rgba(74, 132, 196, 0.98),
      0 0 20px rgba(230, 250, 255, 1),
      0 0 44px rgba(154, 214, 255, 0.98);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(5, 12, 20, 0.5),
      0 0 0 3px rgba(84, 146, 212, 1),
      0 0 34px rgba(240, 254, 255, 1),
      0 0 70px rgba(170, 223, 255, 1);
  }
}

@keyframes token-glow-pulse-red {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(20, 5, 8, 0.5),
      0 0 0 3px rgba(158, 62, 69, 0.98),
      0 0 20px rgba(255, 220, 220, 1),
      0 0 44px rgba(234, 124, 124, 0.98);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(20, 5, 8, 0.5),
      0 0 0 3px rgba(176, 70, 78, 1),
      0 0 34px rgba(255, 236, 236, 1),
      0 0 70px rgba(244, 136, 136, 1);
  }
}

@keyframes token-glow-pulse-green {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(5, 20, 12, 0.5),
      0 0 0 3px rgba(62, 136, 96, 0.98),
      0 0 20px rgba(228, 255, 240, 1),
      0 0 44px rgba(122, 208, 160, 0.98);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(5, 20, 12, 0.5),
      0 0 0 3px rgba(76, 158, 114, 1),
      0 0 34px rgba(242, 255, 248, 1),
      0 0 70px rgba(142, 222, 178, 1);
  }
}

.player-waiting {
  margin-top: 2.2rem;
  min-height: 62vh;
  display: grid;
  align-content: start;
  justify-items: center;
  text-align: center;
  gap: 1rem;
}

.player-waiting-title {
  margin: 0;
  font-size: clamp(1.3rem, 2.2vw, 2rem);
  line-height: 1.2;
}

.player-waiting-image {
  display: block;
  width: min(62vw, 520px);
  max-width: 100%;
  height: auto;
  margin-top: 0.4rem;
}

@media (max-width: 860px) {
  .campaign-overview-grid {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .campaign-scenario-count {
    text-align: left;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .app-footer-logo {
    width: min(46vw, 180px);
  }

  #runMapViewport {
    min-height: 320px;
    height: calc(100vh - 16.5rem);
  }

  .player-map-viewport {
    min-height: 300px;
    height: calc(100vh - 22rem);
  }

  .map-fog-brush-controls {
    left: 0.7rem;
    right: 0.7rem;
    bottom: 4.3rem;
    min-width: 0;
  }
}
