
    * { box-sizing: border-box; }
    body { 
      margin: 0; 
      padding: 0; 
      overflow: hidden; 
      background: #090d16; 
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
      touch-action: none; 
      user-select: none;
    }

    /* TOP MAIN CATEGORY BAR (FORCED SINGLE ROW) */
    #categoryBar {
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 10;
      display: flex;
      gap: 4px;
      flex-wrap: nowrap;
      overflow-x: auto;
      max-width: calc(100vw - 230px);
      scrollbar-width: none; /* Firefox */
      -ms-overflow-style: none; /* IE/Edge */
    }
    #categoryBar::-webkit-scrollbar { display: none; } /* Chrome/Safari */

    .cat-btn {
      background: rgba(15, 23, 42, 0.9);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #f8fafc;
      padding: 5px 8px;
      border-radius: 8px;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(0,0,0,0.4);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      white-space: nowrap;
      flex-shrink: 0;
    }

    .cat-btn.active {
      background: #2563eb;
      border-color: #60a5fa;
      box-shadow: 0 0 10px rgba(37, 99, 235, 0.7);
    }

    /* FLOATING TOOL PANELS */
    .tool-panel {
      position: absolute;
      top: 42px;
      left: 8px;
      z-index: 20;
      background: rgba(15, 23, 42, 0.95);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      padding: 10px;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.15);
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
      display: flex;
      flex-direction: column;
      gap: 8px;
      color: #f8fafc;
      font-size: 11px;
      max-width: calc(100vw - 16px);
      max-height: 75vh;
      overflow-y: auto;
    }

    .tool-panel.hidden, .player-hidden { display: none !important; }
    #combatRoundTracker {
      display:flex !important;
      visibility:visible !important;
      opacity:1 !important;
    }


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

    .header-actions {
      position: absolute; 
      top: 8px; 
      right: 8px; 
      z-index: 11;
      display: flex; 
      gap: 4px;
    }

    button, label.btn, select, input[type="number"], input[type="text"] {
      background: rgba(30, 41, 59, 0.85); 
      color: #f8fafc; 
      border: 1px solid rgba(255, 255, 255, 0.18); 
      padding: 5px 8px;
      border-radius: 8px; 
      font-size: 11px; 
      font-weight: 600; 
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 4px;
      box-shadow: 0 2px 4px rgba(0,0,0,0.3);
      white-space: nowrap;
    }

    button:active, label.btn:active { transform: scale(0.97); }

    select, input[type="number"], input[type="text"] {
      outline: none;
      appearance: none;
      -webkit-appearance: none;
    }

    select {
      background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23F8FAFC%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
      background-repeat: no-repeat;
      background-position: right 6px center;
      background-size: 8px auto;
      padding-right: 20px;
    }

    .btn-primary { background: rgba(37, 99, 235, 0.85); border-color: rgba(96, 165, 250, 0.4); }
    .btn-success { background: rgba(22, 163, 74, 0.85); border-color: rgba(74, 222, 128, 0.4); }
    .btn-warning { background: rgba(217, 119, 6, 0.85); border-color: rgba(251, 191, 36, 0.4); }
    .btn-danger { background: rgba(220, 38, 38, 0.85); border-color: rgba(248, 113, 113, 0.4); }

    .btn-mode.active { 
      background: #2563eb; 
      border-color: #60a5fa;
      box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
    }

    input[type="file"] { display: none; }

    .control-group { 
      display: inline-flex; 
      align-items: center; 
      gap: 6px; 
      background: rgba(255, 255, 255, 0.05); 
      padding: 4px 8px; 
      border-radius: 8px; 
      border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .control-group label { font-size: 11px; color: #94a3b8; font-weight: 500; }

    .map-bookmark-btn {
      background: rgba(15, 23, 42, 0.9);
      border: 1px solid rgba(96, 165, 250, 0.5);
      color: #38bdf8;
      padding: 4px 8px;
      border-radius: 6px;
      font-size: 10px;
    }

    /* CONDITIONS GRID STYLING */
    .conditions-container {
      display: flex;
      flex-direction: column;
      gap: 6px;
      width: 100%;
      background: rgba(0, 0, 0, 0.25);
      padding: 8px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      margin-top: 4px;
    }
    .conditions-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
      gap: 4px;
      max-height: 160px;
      overflow-y: auto;
    }
    .cond-chip {
      background: rgba(30, 41, 59, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 6px;
      padding: 3px 6px;
      font-size: 10px;
      display: flex;
      align-items: center;
      gap: 4px;
      cursor: pointer;
      user-select: none;
    }
    .cond-chip.active {
      background: rgba(220, 38, 38, 0.7);
      border-color: #f87171;
      color: #ffffff;
      box-shadow: 0 0 6px rgba(220, 38, 38, 0.6);
    }


    /* SHARED WEATHER OVERLAY */
    #weatherCanvas {
      position: fixed;
      inset: 0;
      width: 100%;
      height: 100%;
      z-index: 25;
      pointer-events: none;
    }

    /* 2D DICE OVERLAY CANVAS */
    #diceCanvas {
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: 100;
      pointer-events: none;
    }



    /* STAGE 70: SAFE per-sheet dice colors (isolated from attack autosave) */
    #dice3dOverlay {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100vh;
      z-index: 100500;
      pointer-events: none;
      opacity: 0;
      visibility: hidden;
      transition: opacity .14s ease;
      overflow: hidden;
    }
    #dice3dOverlay.active {
      opacity: 1;
      visibility: visible;
    }
    #dice3dOverlay canvas {
      width: 100% !important;
      height: 100% !important;
      display: block;
      pointer-events: none !important;
      filter: var(--vtt-dice-color-filter, none);
    }

    /* STAGE 70: per-character / per-monster dice color */
    .cs-dice-color-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .cs-dice-color-row select { flex: 1; min-width: 0; }
    #csDiceColorPreview {
      width: 34px;
      height: 34px;
      border-radius: 8px;
      border: 2px solid rgba(255,255,255,.38);
      background: #ffffff;
      box-shadow: 0 0 8px rgba(255,255,255,.15);
      flex: 0 0 auto;
    }

    .dice-btn {
      background: rgba(30, 41, 59, 0.9);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #f1f5f9;
      padding: 5px 8px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
    }
    .dice-btn:hover { background: rgba(37, 99, 235, 0.8); }

    .adv-btn.active {
      background: #16a34a !important;
      border-color: #4ade80 !important;
      box-shadow: 0 0 8px rgba(22, 163, 74, 0.8);
    }
    .dis-btn.active {
      background: #dc2626 !important;
      border-color: #f87171 !important;
      box-shadow: 0 0 8px rgba(220, 38, 38, 0.8);
    }

    /* SLIDING CHAT DRAWER */
    #chatToggleBtn { position: relative; }
    #chatBadge {
      display: none;
      position: absolute;
      top: -4px;
      right: -4px;
      background: #ef4444;
      color: #ffffff;
      font-size: 9px;
      font-weight: 800;
      border-radius: 10px;
      padding: 2px 5px;
      border: 1px solid #0f172a;
    }
    #oocOuterChatBadge {
      display: none;
      position: absolute;
      top: -4px;
      right: 18px;
      background: #2563eb;
      color: #ffffff;
      font-size: 9px;
      font-weight: 800;
      border-radius: 10px;
      padding: 2px 5px;
      border: 1px solid #0f172a;
    }

    #chatDrawer {
      position: fixed;
      top: 0;
      right: -340px;
      bottom: 0;
      width: min(320px, 100vw);
      height: 100dvh;
      max-height: 100dvh;
      z-index: 200000;
      background: rgba(15, 23, 42, 0.95);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-left: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    #chatDrawer.open { right: 0; }

    .chat-header {
      padding: 12px;
      background: rgba(30, 41, 59, 0.6);
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #f8fafc;
      font-weight: 700;
      font-size: 13px;
    }

    #chatMessages {
      flex: 1;
      padding: 12px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .chat-msg {
      position: relative;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 8px;
      padding: 8px 10px;
      color: #f1f5f9;
      font-size: 12px;
      word-wrap: break-word;
      user-select: text;
    }
    .chat-msg.dm { background: rgba(30, 58, 138, 0.3); border-color: rgba(96, 165, 250, 0.3); }

    .chat-msg-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 10px;
      color: #94a3b8;
      margin-bottom: 4px;
      font-weight: 600;
    }

    .chat-msg-author { color: #38bdf8; }
    .chat-msg-author.dm { color: #f59e0b; }

    .chat-msg-actions { display: flex; gap: 4px; margin-left: auto; margin-right: 6px; }
    .chat-action-btn { background: transparent; border: none; padding: 0 2px; font-size: 11px; cursor: pointer; opacity: 0.6; }
    .chat-msg-edited { font-size: 9px; color: #64748b; font-style: italic; margin-left: 4px; }
    .chat-msg-img { max-width: 100%; border-radius: 6px; margin-top: 6px; border: 1px solid rgba(255, 255, 255, 0.1); }

    .chat-input-area {
      padding: 10px;
      background: rgba(30, 41, 59, 0.6);
      border-top: 1px solid rgba(255, 255, 255, 0.1);
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .chat-input-row { display: flex; gap: 6px; }

    #chatTextInput {
      flex: 1;
      background: rgba(15, 23, 42, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.15);
      color: #f8fafc;
      padding: 8px;
      border-radius: 8px;
      font-size: 12px;
      user-select: text;
    }

    /* DM DIE LOG DRAWER */
    #dieLogDrawer {
      position: absolute;
      top: 0;
      left: -340px;
      width: 320px;
      height: 100vh;
      z-index: 30;
      background: rgba(15, 23, 42, 0.95);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-right: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: 8px 0 32px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    #dieLogDrawer.open { left: 0; }

    /* Simple Stage 16: keep the DM Die Log entirely above the turn panel. */
    #dieLogDrawer {
      position: fixed !important;
      top: 0 !important;
      bottom: auto !important;
      height: auto !important;
      max-height: none !important;
    }

    #dieLogMessages {
      flex: 1;
      padding: 12px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .dielog-entry {
      background: rgba(30, 41, 59, 0.7);
      border: 1px solid rgba(56, 189, 248, 0.2);
      border-radius: 6px;
      padding: 8px;
      color: #f1f5f9;
      font-size: 11px;
      font-family: monospace;
    }
    .dielog-header {
      display: flex;
      justify-content: space-between;
      color: #38bdf8;
      font-weight: 700;
      margin-bottom: 4px;
    }
  
    /* COLLAPSIBLE TOOLS MENU */
    #categoryBar {
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 120;
      display: flex;
      gap: 6px;
      max-width: calc(100vw - 16px);
    }

    #toolsMenuButton {
      min-width: 92px;
      font-weight: 700;
    }

    #toolsMenu {
      position: absolute;
      top: 58px;
      left: 8px;
      z-index: 130;
      width: min(340px, calc(100vw - 16px));
      max-height: 72vh;
      overflow-y: auto;
      display: none;
      padding: 10px;
      border: 1px solid rgba(148,163,184,0.28);
      border-radius: 14px;
      background: rgba(9,13,22,0.96);
      backdrop-filter: blur(14px);
      box-shadow: 0 14px 40px rgba(0,0,0,0.45);
    }

    #toolsMenu.open {
      display: block;
    }

    #toolsMenuHeader {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 8px;
      padding: 2px 2px 6px;
      font-weight: 800;
      color: #f8fafc;
    }

    #toolsMenuGrid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }

    .tool-menu-item {
      width: 100%;
      min-height: 46px;
      padding: 9px 8px;
      border-radius: 10px;
      white-space: normal;
      text-align: center;
      font-size: 13px;
      font-weight: 700;
    }

    @media (max-width: 420px) {
      #toolsMenu {
        width: calc(100vw - 16px);
      }
      #toolsMenuGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }
    /* TOOL PANEL CLOSE BUTTONS */
.panel-close-btn {
      position: absolute;
      top: 8px;
      right: 8px;
      z-index: 20;
      width: 34px;
      height: 34px;
      min-width: 34px;
      padding: 0;
      border-radius: 9px;
      font-size: 17px;
      font-weight: 800;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Stage 68: interaction panels keep their close button in a dedicated header row
       so it never sits over Wall/Fog controls on narrow phone screens. */
    /* SHEETS 286: the one standard header of a tool panel: Back, title, collapse, close, all in one sticky row with 42 px buttons (phone tap size). */
    .tool-panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      width: 100%;
      min-height: 42px;
      position: sticky;
      top: 0;
      z-index: 2147482000;
      padding-top: 2px;
      padding-bottom: 5px;
      background: linear-gradient(180deg,rgba(9,13,22,.99) 0%,rgba(9,13,22,.94) 82%,rgba(9,13,22,0) 100%);
    }
    .tool-panel-title {
      flex: 1 1 auto;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 14px;
      font-weight: 900;
      color: #f8fafc;
    }
    .panel-close-btn.panel-close-inline {
      position: static;
      flex: 0 0 42px;
      width: 42px;
      min-width: 42px;
      height: 42px;
      margin-left: auto;
    }

    /* Keep all tool windows floating over the map without changing canvas layout */
    .tool-panel {
      position: absolute;
      pointer-events: auto;
    }


    /* CHARACTER SHEET - isolated from map/token canvas controls */
    #panelCharacterSheet {
      z-index: 100001 !important;
      width: min(650px, calc(100vw - 16px));
      max-height: 78vh;
      padding: 12px;
      overflow-y: auto !important;
      overflow-x: hidden;
      touch-action: pan-y;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
    }

    .cs-title {
      font-size: 17px;
      font-weight: 800;
      padding-right: 44px;
      margin-bottom: 2px;
    }

    .cs-status {
      color: #94a3b8;
      font-size: 11px;
      margin-bottom: 6px;
    }

    /* Stage 72: reliable DM fallback for token management. */
    #tokenListBox {
      position: fixed;
      inset: 0;
      margin: auto;
      width: min(390px, calc(100% - 28px));
      max-height: calc(100vh - 28px);
      max-height: calc(100dvh - 28px);
      box-sizing: border-box;
      padding: 0;
      border: 0;
      border-radius: 12px;
      overflow: hidden;
      background: #071025;
      color: #f8fafc;
      box-shadow: 0 20px 60px rgba(0,0,0,.68);
    }
    #tokenListBox[open] { display: flex; }
    #tokenListBox::backdrop { background: rgba(2,6,23,.74); }
    .token-list-card {
      display: flex;
      flex-direction: column;
      min-height: 0;
      width: 100%;
      padding: 10px;
      border: 1px solid rgba(96,165,250,.42);
      border-radius: inherit;
      box-sizing: border-box;
    }
    .token-list-header {
      flex: none;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }
    #tokenListTitle { font-size: 15px; font-weight: 900; }
    #tokenListCount { font-size: 10px; font-weight: 800; color: #94a3b8; }
    #tokenListRows {
      display: grid;
      gap: 5px;
      min-height: 0;
      overflow-y: auto;
      overscroll-behavior: contain;
      touch-action: pan-y;
      -webkit-overflow-scrolling: touch;
    }

#characterSheetTokenMenuBtn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 38px;
      margin: 2px 0 10px;
      padding: 7px 13px;
      border: 1px solid #0e7490;
      border-radius: 10px;
      background: #082f49;
      color: #e0f2fe;
      font-size: 13px;
      font-weight: 800;
      box-shadow: 0 4px 12px rgba(0,0,0,.22);
      touch-action: manipulation;
    }


    /* Per-character combat automation switch. */
    .cs-automation-control {
      display: flex;
      align-items: center;
      gap: 6px;
      margin: 5px 0 7px;
      padding: 5px 7px;
      border: 1px solid rgba(255,255,255,.10);
      border-radius: 7px;
      background: rgba(15,23,42,.55);
    }
    .cs-automation-toggle {
      flex: 0 0 auto;
      min-width: 112px;
      padding: 5px 7px;
      border-radius: 6px;
      font-size: 10px;
      font-weight: 900;
      letter-spacing: .25px;
    }
    .cs-automation-toggle.enabled {
      border-color: rgba(34,197,94,.55);
      background: rgba(20,83,45,.62);
      color: #bbf7d0;
    }
    .cs-automation-toggle.disabled {
      border-color: rgba(245,158,11,.55);
      background: rgba(120,53,15,.60);
      color: #fde68a;
    }
    #csAutomationHint {
      min-width: 0;
      color: #94a3b8;
      font-size: 9px;
      line-height: 1.2;
    }

    /* Stage 60: show the active character name in the Character Sheet title position. */
    .cs-title.cs-character-name-highlight {
      color: #f6a821;
      font-size: 26px;
      font-weight: 900;
      line-height: 1.1;
      letter-spacing: 0.2px;
      margin: 4px 0 8px;
      padding-right: 8px;
      overflow-wrap: anywhere;
      text-shadow: 0 2px 10px rgba(246, 168, 33, 0.28);
    }

    .cs-section {
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 10px;
      padding: 9px;
      background: rgba(2, 6, 23, 0.30);
    }

    .cs-section-title {
      font-size: 12px;
      font-weight: 800;
      margin-bottom: 7px;
      color: #e2e8f0;
    }

    .cs-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 7px;
    }

    .cs-grid.cs-three {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cs-field {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .cs-field label {
      color: #94a3b8;
      font-size: 10px;
      font-weight: 700;
    }

    #panelCharacterSheet input,
    #panelCharacterSheet textarea {
      width: 100%;
      min-width: 0;
      padding: 7px 8px;
      border-radius: 7px;
      border: 1px solid rgba(255,255,255,0.18);
      background: rgba(15,23,42,0.90);
      color: #f8fafc;
      font: inherit;
      font-size: 16px;
      user-select: text;
      touch-action: manipulation;
    }

    #panelCharacterSheet input[type="number"] {
      text-align: center;
    }

    #panelCharacterSheet textarea {
      min-height: 72px;
      resize: vertical;
      line-height: 1.3;
    }

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

    .cs-ability {
      text-align: center;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 8px;
      padding: 6px;
      background: rgba(15,23,42,0.55);
    }

    .cs-ability label {
      display: block;
      font-weight: 800;
      margin-bottom: 4px;
      color: #cbd5e1;
    }

    .cs-ability input {
      padding: 6px 3px !important;
    }

    .cs-save-row {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }

    #characterSheetSaveStatus {
      color: #94a3b8;
      font-size: 11px;
    }

    .cs-roll-mode {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      margin-bottom: 8px;
    }

    .cs-roll-btn, .cs-mini-roll {
      border: 1px solid rgba(56,189,248,0.42);
      background: rgba(14,116,144,0.22);
      color: #e0f2fe;
      border-radius: 7px;
      font-weight: 800;
      cursor: pointer;
      touch-action: manipulation;
    }

    .cs-roll-btn { padding: 8px 6px; font-size: 12px; }
    .cs-mini-roll { padding: 6px 8px; font-size: 11px; white-space: nowrap; }
    #csManipulateElementsCast:disabled, #csElementalBurstCast:disabled { opacity: .45; cursor: default; }
    .cs-roll-btn.active { background: rgba(37,99,235,0.75); border-color: #60a5fa; }

    .cs-ability-mod {
      display: block;
      margin-top: 4px;
      width: 100%;
      padding: 5px 2px;
      font-size: 12px;
    }

    .cs-roll-table {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 6px;
    }

    .cs-roll-row {
      display: grid;
      grid-template-columns: minmax(0,1fr) 58px 54px;
      gap: 5px;
      align-items: center;
      padding: 5px;
      border: 1px solid rgba(255,255,255,0.10);
      border-radius: 7px;
      background: rgba(15,23,42,0.42);
    }

    .cs-roll-row span { font-size: 11px; font-weight: 700; color: #cbd5e1; }
    .cs-roll-row input { padding: 5px 3px !important; font-size: 14px !important; }

    .cs-inline-roll {
      display: grid;
      grid-template-columns: minmax(0,1fr) auto;
      gap: 5px;
      align-items: center;
    }


    .cs-attack-list { display:grid; gap:7px; }
    .cs-attack-row {
      display:grid;
      grid-template-columns:minmax(100px,1.35fr) 58px auto minmax(88px,1fr) auto minmax(86px,.9fr);
      gap:5px; align-items:center; padding:6px;
      border:1px solid rgba(255,255,255,.10); border-radius:8px;
      background:rgba(15,23,42,.42);
    }
    .cs-attack-row input { padding:6px 5px !important; font-size:14px !important; }
    .cs-attack-head {
      display:grid;
      grid-template-columns:minmax(100px,1.35fr) 58px 54px minmax(88px,1fr) 62px minmax(86px,.9fr);
      gap:5px; padding:0 6px; color:#94a3b8; font-size:9px;
      font-weight:800; text-transform:uppercase;
    }

    @media (max-width: 600px) {
      .cs-grid,
      .cs-grid.cs-three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .cs-abilities {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }

      .cs-roll-table {
        grid-template-columns: 1fr;
      }
      .cs-attack-head { display:none; }
      .cs-attack-row { grid-template-columns:minmax(0,1fr) 58px 54px; }
      .cs-attack-row .cs-attack-damage { grid-column:1 / 2; }
      .cs-attack-row .cs-attack-type { grid-column:1 / 4; }
    }



    /* ROLL TOTAL POPUP */
    #rollTotalPopup {
      position: fixed;
      top: 112px;
      left: 50%;
      transform: translateX(-50%) scale(0.96);
      z-index: 100002;
      min-width: 160px;
      max-width: min(86vw, 360px);
      padding: 8px 14px 10px;
      border: 1px solid rgba(255,255,255,0.22);
      border-radius: 14px;
      background: rgba(9,13,22,0.94);
      box-shadow: 0 12px 34px rgba(0,0,0,0.45);
      backdrop-filter: blur(10px);
      text-align: center;
      pointer-events: none;
      opacity: 0;
      visibility: hidden;
      transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }

    #rollTotalPopup.show {
      opacity: 1;
      visibility: visible;
      transform: translateX(-50%) scale(1);
    }

    #rollTotalPopupName {
      color: #cbd5e1;
      font-size: 12px;
      font-weight: 700;
      line-height: 1.2;
    }

    #rollTotalPopupLabel {
      margin-top: 2px;
      color: #f8fafc;
      font-size: 14px;
      font-weight: 800;
      line-height: 1.2;
    }

    #rollTotalPopupNumber {
      margin-top: 2px;
      color: #4ade80;
      font-size: 38px;
      font-weight: 900;
      line-height: 1;
      text-shadow: 0 2px 12px rgba(74,222,128,0.22);
    }

    /* CHARACTER SHEET AUTO MODIFIERS */
    .cs-auto-row {
      display:flex;
      gap:6px;
      align-items:center;
      justify-content:space-between;
      flex-wrap:wrap;
      margin-bottom:7px;
    }

    .cs-auto-note {
      color:#94a3b8;
      font-size:10px;
      line-height:1.25;
    }

    .cs-prof-select {
      width:76px !important;
      min-width:76px;
      padding:5px 3px !important;
      font-size:12px !important;
    }

    .cs-save-prof {
      display:flex;
      align-items:center;
      justify-content:center;
      gap:3px;
      color:#cbd5e1;
      font-size:10px;
      white-space:nowrap;
    }

    .cs-save-prof input {
      width:18px !important;
      height:18px !important;
      margin:0;
    }

    .cs-passive {
      display:inline-flex;
      align-items:center;
      gap:5px;
      padding:5px 9px;
      border:1px solid rgba(255,255,255,.12);
      border-radius:8px;
      background:rgba(15,23,42,.55);
      font-size:11px;
      font-weight:800;
    }

    .cs-roll-row.cs-save-row {
      grid-template-columns:minmax(100px,1fr) auto 58px auto;
    }

    .cs-roll-row.cs-skill-row {
      grid-template-columns:minmax(105px,1fr) 76px 58px auto;
    }

    @media (max-width:600px) {
      .cs-roll-row.cs-save-row,
      .cs-roll-row.cs-skill-row {
        grid-template-columns:minmax(0,1fr) auto 58px auto;
      }
      .cs-prof-select { width:68px !important; min-width:68px; font-size:11px !important; }
    }




    .cs-level-auto-box {
      display:flex;
      flex-wrap:wrap;
      align-items:center;
      gap:7px;
      margin-top:8px;
      padding:7px;
      border:1px solid rgba(34,197,94,.22);
      border-radius:8px;
      background:rgba(15,23,42,.45);
    }
    .cs-level-auto-box button {
      flex:0 0 auto;
    }
    #csLevelAutoStatus {
      color:#94a3b8;
      font-size:9px;
      line-height:1.3;
    }





    #combatRoundTracker {
      position:fixed !important;
      top:calc(100vh - 180px) !important;
      bottom:auto !important;
      left:8px !important;
      right:auto !important;
      width:270px !important;
      max-width:calc(100vw - 16px) !important;
      height:auto !important;
      transform:none !important;
      z-index:99999 !important;
      display:flex !important;
      visibility:visible !important;
      opacity:1 !important;
      flex-direction:column;
      gap:5px;
      padding:6px;
      border:1px solid rgba(148,163,184,.35);
      border-radius:10px;
      background:rgba(9,13,22,.96);
      backdrop-filter:blur(10px);
      box-shadow:0 6px 18px rgba(0,0,0,.4);
      pointer-events:auto !important;
    }
    .round-tracker-top {
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:6px;
      min-width:0;
    }
    .round-tracker-main {
      display:flex;
      align-items:center;
      gap:5px;
      white-space:nowrap;
      flex:0 0 auto;
    }
    .round-tracker-label {
      font-size:8px;
      color:#94a3b8;
      letter-spacing:.08em;
    }
    #combatRoundDisplay {
      min-width:22px;
      text-align:center;
      font-size:14px;
      font-weight:800;
      color:#f8fafc;
    }
    .round-turn-display {
      min-width:0;
      flex:1 1 auto;
      text-align:right;
      font-size:9px;
      color:#c4b5fd;
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    #combatRoundControls.round-tracker-controls {
      display:grid;
      grid-template-columns:repeat(4, minmax(0, 1fr));
      gap:4px;
      width:100%;
    }
    #combatMovementActions {
      display:grid;
      grid-template-columns:repeat(2, minmax(0, 1fr));
      gap:4px;
      width:100%;
    }
    #playerCombatTurnControl {
      display:none;
      width:100%;
    }
    #playerCombatTurnControl.player-turn-visible {
      display:grid !important;
      grid-template-columns:1fr;
      gap:4px;
    }
    #playerCombatTurnBtn {
      min-width:0 !important;
      width:100% !important;
      height:32px;
      padding:0 6px;
      border-radius:7px;
      font-size:10px;
      font-weight:850;
      background:#1d4ed8;
      border-color:#3b82f6;
      color:#fff;
    }
    #combatMovementActions.player-hidden { display:none !important; }
    #combatMovementActions:not(.player-hidden) { display:grid !important; }
    #combatMovementActions button {
      min-width:0 !important;
      width:100% !important;
      height:27px;
      padding:0 4px;
      border-radius:7px;
      font-size:9px;
      white-space:nowrap;
    }
    #combatRoundControls.round-tracker-controls.player-hidden {
      display:none !important;
    }
    #combatRoundControls.round-tracker-controls:not(.player-hidden) {
      display:grid !important;
    }
    #combatRoundTracker button {
      pointer-events:auto !important;
      touch-action:manipulation !important;
      position:relative;
      z-index:2;
    }
    .round-tracker-controls button {
      min-width:0 !important;
      width:100% !important;
      height:32px;
      padding:0 3px;
      border-radius:7px;
      font-size:9px;
      white-space:nowrap;
    }
    @media (max-width:760px) {
      #combatRoundTracker {
        bottom:auto !important;
        left:8px !important;
        width:270px !important;
        max-width:calc(100vw - 16px) !important;
        transform:none !important;
      }
    }

    .cs-concentration-box {
      margin-top:10px;
      padding:8px;
      border:1px solid rgba(168,85,247,.35);
      border-radius:9px;
      background:rgba(88,28,135,.12);
    }
    .cs-concentration-row {
      display:grid;
      grid-template-columns:auto minmax(0,1fr) auto;
      gap:6px;
      align-items:center;
    }
    .cs-concentration-toggle {
      display:flex;
      align-items:center;
      gap:4px;
      font-size:10px;
      color:#cbd5e1;
    }
    .cs-concentration-toggle input { width:auto; }

    .cs-concentration-duration-row {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:6px;
      margin-top:6px;
    }
    .cs-concentration-duration-row label {
      font-size:9px;
      color:#94a3b8;
    }
    .cs-concentration-duration-row input {
      width:100%;
      margin-top:3px;
    }

    .cs-concentration-status {
      margin-top:6px;
      font-size:10px;
      color:#c4b5fd;
    }

    .cs-concentration-check {
      display:none;
      margin-top:8px;
      padding:7px;
      border:1px solid rgba(251,191,36,.4);
      border-radius:8px;
      background:rgba(120,53,15,.16);
    }
    .cs-concentration-check.show { display:block; }
    .cs-concentration-check-title {
      font-size:10px;
      font-weight:800;
      color:#fde68a;
      margin-bottom:5px;
    }
    .cs-concentration-check-row {
      display:grid;
      grid-template-columns:minmax(0,1fr) auto;
      gap:6px;
      align-items:center;
    }
    .cs-concentration-check-text {
      font-size:10px;
      color:#e2e8f0;
      line-height:1.3;
    }

    .cs-currency-grid {
      display:grid;
      grid-template-columns:repeat(5, 1fr);
      gap:6px;
    }
    .cs-currency-grid label {
      font-size:9px;
      color:#94a3b8;
      text-align:center;
    }
    .cs-currency-grid input {
      width:100%;
      margin-top:3px;
      text-align:center;
      padding:7px 3px;
    }
    .cs-inventory-header,
    .cs-inventory-row {
      display:grid;
      grid-template-columns:minmax(90px,1.35fr) 44px 48px 36px 70px 50px 48px;
      gap:5px;
      align-items:center;
    }
    .cs-inventory-header {
      margin-top:7px;
      padding:0 2px;
      font-size:9px;
      color:#94a3b8;
      text-align:center;
    }
    .cs-inventory-header span:first-child { text-align:left; }
    .cs-inventory-row { margin-top:6px; }
    .cs-inventory-row input { width:100%; min-width:0; }
    .cs-inventory-equip {
      display:flex;
      align-items:center;
      justify-content:center;
      gap:3px;
      font-size:9px;
      color:#94a3b8;
    }
    .cs-inventory-equip input { width:auto; }

    .cs-inventory-armor-type {
      width:100%;
      min-width:0;
      font-size:9px;
      padding:6px 2px;
    }
    .cs-ac-helper-box {
      grid-column:1 / -1;
      margin-top:4px;
      padding:8px;
      border:1px solid rgba(59,130,246,.28);
      border-radius:8px;
      background:rgba(15,23,42,.55);
    }
    .cs-ac-helper-summary {
      font-size:10px;
      color:#cbd5e1;
      line-height:1.4;
      margin-bottom:6px;
    }
    .cs-ac-helper-actions {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:6px;
      margin-bottom:5px;
    }

    .cs-inventory-summary {
      margin-top:8px;
      padding:7px 8px;
      border:1px solid rgba(148,163,184,.22);
      border-radius:8px;
      color:#cbd5e1;
      font-size:10px;
      background:rgba(15,23,42,.55);
    }

    .cs-resource-help {
      font-size:10px;
      line-height:1.4;
      color:#94a3b8;
      margin-bottom:8px;
    }
    .cs-resource-row {
      padding:9px;
      margin-top:8px;
      border:1px solid rgba(56,189,248,.24);
      border-radius:9px;
      background:rgba(15,23,42,.62);
    }
    .cs-resource-name {
      width:100%;
      font-weight:700;
      margin-bottom:7px;
    }
    .cs-resource-numbers {
      display:grid;
      grid-template-columns:1fr 1fr 1.35fr;
      gap:6px;
    }
    .cs-resource-numbers label {
      min-width:0;
      font-size:9px;
      color:#94a3b8;
    }
    .cs-resource-numbers input,
    .cs-resource-numbers select {
      width:100%;
      margin-top:3px;
    }
    .cs-resource-display {
      margin-top:6px;
      font-size:10px;
      color:#cbd5e1;
    }
    .cs-resource-actions {
      display:grid;
      grid-template-columns:1fr 1fr 1fr;
      gap:6px;
      margin-top:6px;
    }
    .cs-resource-actions button {
      min-width:0;
      padding:7px 3px;
      font-size:10px;
    }

    .cs-level-up-hp-helper {
      margin-top:8px;
      padding:9px;
      border:1px solid rgba(34,197,94,.35);
      border-radius:9px;
      background:rgba(15,23,42,.72);
    }
    .cs-level-up-hp-title {
      font-size:12px;
      font-weight:800;
      color:#86efac;
      margin-bottom:4px;
    }
    .cs-level-up-hp-text {
      font-size:10px;
      color:#e2e8f0;
      line-height:1.4;
    }
    .cs-level-up-hp-actions {
      display:grid;
      grid-template-columns:1fr 1fr 1fr;
      gap:6px;
      margin-top:7px;
    }
    .cs-level-up-hp-actions button {
      min-width:0;
      padding:7px 4px;
      font-size:10px;
    }
    .cs-level-up-hp-note {
      margin-top:6px;
      color:#94a3b8;
      font-size:9px;
      line-height:1.35;
    }

    /* CHARACTER LIBRARY / MANUAL CHARACTER ID */
    .character-library-box {
      margin:7px 0;
      padding:8px;
      border:1px solid rgba(56,189,248,.28);
      border-radius:9px;
      background:rgba(15,23,42,.72);
    }
    .character-library-title {
      color:#38bdf8;
      font-size:12px;
      font-weight:800;
      margin-bottom:4px;
    }
    .character-library-status {
      color:#cbd5e1;
      font-size:10px;
      margin-bottom:6px;
      overflow-wrap:anywhere;
    }
    .character-library-row {
      display:grid;
      grid-template-columns:minmax(0,1fr) auto;
      gap:6px;
      margin-top:6px;
      align-items:center;
    }
    .character-library-row select,
    .character-library-row input {
      width:100%;
      min-width:0;
      padding:7px;
      border-radius:7px;
    }
    .character-library-help {
      margin-top:6px;
      color:#94a3b8;
      font-size:9px;
      line-height:1.35;
    }
    .cs-character-id-box {
      display:grid;
      grid-template-columns:minmax(0,1fr) auto;
      gap:7px;
      align-items:end;
      padding:7px;
      margin-bottom:8px;
      border:1px solid rgba(139,92,246,.28);
      border-radius:8px;
      background:rgba(15,23,42,.50);
    }
    .cs-character-id-label {
      color:#94a3b8;
      font-size:9px;
      font-weight:800;
      margin-bottom:3px;
    }
    #csCharacterIdDisplay {
      width:100%;
      min-width:0;
      font-size:10px;
      padding:6px;
    }

    /* CHARACTER SHEET SECTION PAGES */
    .cs-page-switcher { display:grid; grid-template-columns:46px minmax(0,1fr) 46px; gap:6px; align-items:center; margin:8px 0; }
    .cs-page-nav-btn, .cs-page-center-btn, .cs-section-menu-btn {
      min-height:42px; border:1px solid rgba(255,255,255,.14); border-radius:9px;
      background:#1e293b; color:#f8fafc; font-weight:800; touch-action:manipulation;
    }
    .cs-page-nav-btn { font-size:20px; padding:0; }
    .cs-page-center-btn { display:flex; flex-direction:column; align-items:center; justify-content:center; line-height:1.1; padding:5px 8px; min-width:0; }
    .cs-page-title-text { width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
    .cs-page-subtext { color:#94a3b8; font-size:9px; margin-top:2px; }
    #csSectionMenu { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:8px 0 10px; }
    #csSectionMenu.hidden { display:none !important; }
    .cs-section-menu-btn { display:flex; align-items:center; justify-content:flex-start; gap:8px; padding:10px 11px; text-align:left; font-size:12px; }
    .cs-section-menu-btn.active { border-color:#8b5cf6; background:rgba(124,58,237,.18); }
    .cs-section-menu-icon { width:22px; text-align:center; font-size:16px; flex:0 0 22px; }
    /* Stage 27: timed combat effects */
    .cs-timed-effects-box {
      margin-top: 12px;
      padding: 10px;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 10px;
      background: rgba(255,255,255,0.04);
    }
    .cs-timed-effect-add {
      display: flex;
      justify-content: flex-start;
      margin-top: 8px;
    }
    .cs-timed-effect-add-btn {
      min-height: 34px;
      padding: 6px 12px;
      font-weight: 800;
    }
    .cs-timed-effects-list {
      display: grid;
      gap: 6px;
      margin-top: 9px;
    }
    .cs-timed-effect-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 68px auto auto auto;
      gap: 5px;
      align-items: end;
      padding: 7px;
      border: 1px solid rgba(255,255,255,0.10);
      border-radius: 8px;
      background: rgba(0,0,0,0.16);
    }
    .cs-timed-effect-field {
      min-width: 0;
    }
    .cs-timed-effect-field label {
      display: block;
      margin: 0 0 3px;
      font-size: 9px;
      opacity: .72;
      text-transform: uppercase;
      letter-spacing: .04em;
    }
    .cs-timed-effect-field input {
      width: 100%;
      min-width: 0;
      height: 31px;
      padding: 4px 6px;
    }
    .cs-timed-effect-btn {
      min-width: 31px;
      height: 31px;
      padding: 3px 7px;
      border-radius: 7px;
    }
    .cs-timed-effects-empty {
      font-size: 12px;
      opacity: 0.7;
      padding: 4px 1px;
    }

    #characterSheetForm .cs-page-section { display:none; }
    #characterSheetForm .cs-page-section.cs-page-active { display:block; }
    #characterSheetForm.cs-menu-open .cs-page-section { display:none !important; }
    #characterSheetPageHint { color:#94a3b8; font-size:10px; text-align:center; margin:-2px 0 6px; }
    @media (max-width:420px) {
      #csSectionMenu { grid-template-columns:1fr; }
      .cs-section-menu-btn { min-height:44px; font-size:13px; }
    }


    /* CHARACTER SHEET SPELLS */
    .cs-spell-grid {
      display:grid;
      grid-template-columns:repeat(2, minmax(0,1fr));
      gap:7px;
    }

    .cs-spell-stat {
      border:1px solid rgba(255,255,255,.10);
      border-radius:8px;
      background:rgba(15,23,42,.42);
      padding:7px;
    }

    .cs-spell-stat label {
      display:block;
      color:#94a3b8;
      font-size:10px;
      font-weight:800;
      margin-bottom:4px;
    }

    .cs-spell-slot-grid {
      display:grid;
      grid-template-columns:repeat(3, minmax(0,1fr));
      gap:7px;
    }

    .cs-spell-slot-card {
      border:1px solid rgba(255,255,255,.10);
      border-radius:8px;
      background:rgba(15,23,42,.42);
      padding:7px;
    }

    .cs-spell-slot-title {
      font-size:11px;
      font-weight:800;
      margin-bottom:5px;
      color:#e2e8f0;
    }

    .cs-spell-slot-inputs {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:5px;
    }

    .cs-spell-slot-inputs label {
      color:#94a3b8;
      font-size:9px;
      font-weight:700;
    }

    .cs-spell-row {
      display:grid;
      grid-template-columns:minmax(105px,1.2fr) 54px 72px 58px minmax(82px,1fr) 68px 58px auto;
      gap:5px;
      align-items:center;
      padding:6px;
      border:1px solid rgba(255,255,255,.10);
      border-radius:8px;
      background:rgba(15,23,42,.42);
    }

    .cs-spell-row input,
    .cs-spell-row select {
      padding:6px 5px !important;
      font-size:13px !important;
      min-width:0;
    }

    .cs-spell-head {
      display:grid;
      grid-template-columns:minmax(105px,1.2fr) 54px 72px 58px minmax(82px,1fr) 68px 58px auto;
      gap:5px;
      padding:0 6px;
      color:#94a3b8;
      font-size:9px;
      font-weight:800;
      text-transform:uppercase;
    }

    @media (max-width:600px) {
      .cs-spell-grid { grid-template-columns:1fr 1fr; }
      .cs-spell-slot-grid { grid-template-columns:1fr 1fr; }
      .cs-spell-head { display:none; }
      .cs-spell-row {
        grid-template-columns:minmax(0,1fr) 70px 72px;
      }
      .cs-spell-row .cs-spell-name { grid-column:1 / 4; }
      .cs-spell-row .cs-spell-damage { grid-column:1 / 2; }
      .cs-spell-row .cs-spell-type { grid-column:2 / 3; }
      .cs-spell-row .cs-spell-range { grid-column:3 / 4; }
      .cs-spell-row .cs-spell-damage-btn { grid-column:auto; }
    }


    /* Stage 72: character saving-throw spell automation. */
    .cs-save-spell-list { display:grid; gap:7px; }
    .cs-save-spell-row {
      display:grid;
      grid-template-columns:minmax(110px,1.25fr) 62px 54px 58px 78px 54px 54px minmax(80px,1fr) 70px 78px minmax(86px,1fr) auto;
      gap:5px;
      align-items:center;
      padding:7px;
      border:1px solid rgba(125,211,252,.16);
      border-radius:8px;
      background:rgba(15,23,42,.46);
    }
    .cs-save-spell-row input,
    .cs-save-spell-row select {
      padding:6px 5px !important;
      font-size:12px !important;
      min-width:0;
    }
    .cs-save-spell-conc {
      display:flex;
      align-items:center;
      justify-content:center;
      gap:4px;
      min-height:31px;
      padding:4px;
      border:1px solid rgba(255,255,255,.08);
      border-radius:6px;
      color:#cbd5e1;
      font-size:9px;
      font-weight:800;
      white-space:nowrap;
    }
    .cs-save-spell-conc input { width:auto !important; }
    .cs-save-spell-head {
      display:grid;
      grid-template-columns:minmax(110px,1.25fr) 62px 54px 58px 78px 54px 54px minmax(80px,1fr) 70px 78px minmax(86px,1fr) auto;
      gap:5px;
      padding:0 7px;
      color:#94a3b8;
      font-size:8px;
      font-weight:800;
      text-transform:uppercase;
    }
    @media (max-width:600px) {
      .cs-save-spell-head { display:none; }
      .cs-save-spell-row { grid-template-columns:1fr 1fr 1fr; }
      .cs-save-spell-row .cs-save-spell-name { grid-column:1 / 4; }
      .cs-save-spell-row .cs-save-spell-condition { grid-column:1 / 3; }
      .cs-save-spell-row .cs-save-spell-cast { grid-column:3 / 4; min-height:34px; }
    }


    /* CHARACTER SHEET TOKEN SYNC */
    .cs-sync-box {
      display:grid;
      gap:8px;
      padding:9px;
      border:1px solid rgba(255,255,255,.10);
      border-radius:9px;
      background:rgba(15,23,42,.42);
      margin-top:8px;
    }

    .cs-sync-row {
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      flex-wrap:wrap;
    }

    .cs-sync-label {
      font-size:11px;
      font-weight:800;
      color:#e2e8f0;
    }

    .cs-sync-note {
      font-size:10px;
      color:#94a3b8;
      line-height:1.25;
    }

    .cs-condition-sync-grid {
      display:grid;
      grid-template-columns:repeat(2, minmax(0,1fr));
      gap:6px;
    }

    .cs-condition-sync-item {
      display:flex;
      align-items:center;
      gap:6px;
      min-height:38px;
      padding:7px 8px;
      border:1px solid rgba(255,255,255,.10);
      border-radius:8px;
      background:rgba(15,23,42,.35);
      font-size:11px;
      color:#e2e8f0;
    }

    .cs-condition-sync-item input {
      width:18px !important;
      height:18px !important;
      margin:0;
      flex:0 0 auto;
    }

    @media (max-width:420px) {
      .cs-condition-sync-grid { grid-template-columns:1fr; }
    }


    /* CHARACTER SHEET SURVIVAL / REST */
    .cs-survival-grid {
      display:grid;
      grid-template-columns:repeat(2, minmax(0,1fr));
      gap:8px;
    }

    .cs-survival-card {
      border:1px solid rgba(255,255,255,.10);
      border-radius:9px;
      background:rgba(15,23,42,.42);
      padding:8px;
    }

    .cs-survival-title {
      font-size:11px;
      font-weight:800;
      color:#e2e8f0;
      margin-bottom:6px;
    }

    .cs-death-row {
      display:flex;
      align-items:center;
      gap:7px;
      flex-wrap:wrap;
      margin:5px 0;
    }

    .cs-death-checks {
      display:flex;
      gap:5px;
    }

    .cs-death-checks input {
      width:20px !important;
      height:20px !important;
      margin:0;
    }

    .cs-rest-actions {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:7px;
      margin-top:8px;
    }

    .cs-hit-dice-row {
      display:grid;
      grid-template-columns:minmax(0,1fr) 70px auto;
      gap:6px;
      align-items:center;
    }

    .cs-inspiration-row {
      display:flex;
      align-items:center;
      gap:8px;
      min-height:38px;
    }

    .cs-inspiration-row input {
      width:20px !important;
      height:20px !important;
      margin:0;
    }

    @media (max-width:500px) {
      .cs-survival-grid { grid-template-columns:1fr; }
      .cs-rest-actions { grid-template-columns:1fr; }
    }


    /* CHARACTER SHEET HP CONTROLS */
    .cs-hp-control-box {
      display:grid;
      gap:8px;
      padding:9px;
      margin-top:8px;
      border:1px solid rgba(255,255,255,.10);
      border-radius:9px;
      background:rgba(15,23,42,.42);
    }

    .cs-hp-control-input {
      width:100%;
      min-height:42px;
      text-align:center;
      font-weight:800;
    }

    .cs-hp-control-actions {
      display:grid;
      grid-template-columns:repeat(3, minmax(0,1fr));
      gap:7px;
    }

    .cs-hp-summary {
      font-size:11px;
      color:#cbd5e1;
      text-align:center;
    }

    @media (max-width:420px) {
      .cs-hp-control-actions { grid-template-columns:1fr; }
    }


    /* SPELL SLOT CONTROLS */
    .cs-spell-slot-card .cs-slot-display {
      margin-top:6px;
      text-align:center;
      font-size:11px;
      font-weight:800;
      color:#cbd5e1;
    }
    .cs-spell-slot-card .cs-slot-actions {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:5px;
      margin-top:6px;
    }

    .cs-row-manager{display:flex;gap:6px;margin:7px 0 8px;flex-wrap:wrap;}
    .cs-row-manager button{flex:1;min-width:110px;}
    .cs-row-hidden{display:none!important;}

    /* Stage 43: persistent visual status for monster Recharge abilities. */
    .monster-recharge-ready {
      background:#2563eb !important;
      border-color:#60a5fa !important;
      color:#ffffff !important;
      box-shadow:0 0 10px rgba(37,99,235,.75) !important;
    }
    .monster-recharge-waiting {
      background:rgba(127,29,29,.78) !important;
      border-color:#ef4444 !important;
      color:#fee2e2 !important;
      box-shadow:0 0 7px rgba(239,68,68,.35) !important;
    }

/* Simple Stage 4 cosmetic restore */
#toolsMenu{position:fixed!important;top:0!important;left:0!important;bottom:0!important;width:min(285px,82vw)!important;height:100dvh!important;max-height:none!important;overflow-y:auto!important;display:block!important;padding:10px!important;border:0!important;border-right:1px solid rgba(148,163,184,.3)!important;border-radius:0 14px 14px 0!important;background:rgba(7,11,20,.985)!important;z-index:180000!important;transform:translateX(-105%);transition:transform .16s ease-out}#toolsMenu.open{transform:translateX(0)}#toolsMenuHeader{position:sticky;top:-10px;z-index:3;min-height:46px;margin:-10px -10px 8px!important;padding:10px!important;background:rgba(7,11,20,.985);font-size:18px;font-weight:900}.side-menu-section{margin-bottom:7px;padding:5px;border:1px solid rgba(148,163,184,.2);border-radius:8px;background:rgba(15,23,42,.56)}.side-menu-section-title{margin:0 2px 4px;color:#94a3b8;font-size:8px;font-weight:900;letter-spacing:.1em}.side-menu-items{display:grid;gap:3px}.side-menu-item{width:100%;height:26px;justify-content:flex-start;padding:2px 8px;border-radius:5px;font-size:10px}.cs-roll-mode.cs-attack-roll-mode{grid-template-columns:repeat(4,minmax(0,1fr))}.cs-roll-mode.cs-attack-roll-mode .cs-roll-btn{min-width:0;padding:6px 3px;font-size:10px}#combatInitiativeListBtn{min-width:34px;height:27px;padding:0 5px;font-size:9px}.combat-tracker-collapse-btn{width:27px!important;min-width:27px!important;height:27px!important;padding:0!important}.tracker-collapsed #combatRoundControls,.tracker-collapsed #playerCombatTurnControl,.tracker-collapsed #combatMovementActions{display:none!important}.tracker-collapsed .combat-tracker-collapse-btn{transform:rotate(180deg)}#initiativeOrderPopup{position:fixed;top:64px;right:8px;z-index:100110;width:min(132px,calc(100vw - 16px));max-height:62vh;overflow:auto;padding:5px;border:1px solid rgba(148,163,184,.45);border-radius:11px;background:rgba(9,13,22,.97)}#initiativeOrderPopup.hidden{display:none!important}.initiative-popup-head{display:flex;align-items:center;gap:3px;margin-bottom:4px}.initiative-popup-title{flex:1;font-size:8px;font-weight:900}.initiative-order-row{display:grid;grid-template-columns:13px minmax(0,1fr) auto;gap:3px;align-items:center;min-height:23px;padding:2px 4px;border:1px solid rgba(148,163,184,.2);border-radius:7px;background:rgba(30,41,59,.58);font-size:9px}.initiative-order-row.current{border-color:#fbbf24;background:rgba(146,64,14,.34)}.initiative-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:800}.initiative-value{font-weight:900;color:#bfdbfe}.initiative-rank{color:#94a3b8;text-align:center}.initiative-order-row.current .initiative-value{color:#fde68a}

/* Simple Stage 5: combined panels + universal collapsible tool panels */
.combined-panel-divider{height:1px;background:rgba(148,163,184,.22);margin:7px 0 4px;width:100%;}
.combined-panel-section-title{font-size:12px;font-weight:900;color:#e2e8f0;margin:2px 0 3px;}
.panel-collapse-btn{position:absolute;top:8px;right:50px;z-index:22;width:34px;height:34px;min-width:34px;padding:0;border-radius:9px;font-size:16px;font-weight:900;display:flex;align-items:center;justify-content:center;}
.panel-collapse-btn.panel-collapse-inline{position:static;flex:0 0 42px;width:42px;min-width:42px;height:42px;margin-left:auto;}
.tool-panel-header .panel-collapse-inline + .panel-close-inline{margin-left:0;}
.panel-collapse-label{display:none;font-size:12px;font-weight:900;color:#e2e8f0;padding-right:82px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tool-panel.panel-collapsed{min-width:150px!important;width:auto!important;max-width:min(260px,calc(100vw - 16px))!important;max-height:52px!important;min-height:48px!important;overflow:hidden!important;padding:8px 88px 8px 10px!important;gap:0!important;}
.tool-panel.panel-collapsed > *:not(.panel-close-btn):not(.panel-collapse-btn):not(.panel-collapse-label):not(.tool-panel-header){display:none!important;}
.tool-panel.panel-collapsed > .panel-collapse-label{display:block!important;align-self:center;line-height:32px;}
.tool-panel.panel-collapsed > .tool-panel-header{min-height:32px!important;}
.tool-panel.panel-collapsed > .tool-panel-header ~ *{display:none!important;}
.tool-panel.panel-collapsed .panel-collapse-btn{transform:rotate(180deg);}
.tool-panel.panel-collapsed .tool-panel-header .panel-collapse-btn{transform:rotate(180deg);}

/* Stage 7: compact phone-first Walls + Terrain panel layout. */
#panelWalls {
  width: min(660px, calc(100vw - 30px));
  max-height: 78vh;
  gap: 10px;
}
#panelWalls .wall-panel-body { display:flex; flex-direction:column; gap:11px; }
#panelWalls .wall-mode-box {
  padding: 10px 12px;
  border: 1px solid rgba(148,163,184,.14);
  border-radius: 12px;
  background: rgba(15,23,42,.34);
}
#panelWalls .wall-mode-row {
  display:grid;
  grid-template-columns:64px repeat(4, minmax(0,1fr));
  gap:8px;
  align-items:center;
}
#panelWalls .wall-mode-row-secondary {
  grid-template-columns:64px repeat(3, minmax(0,1fr)) 1fr;
  margin-top:8px;
}
#panelWalls .wall-mode-row button,
#panelWalls .terrain-button-row button,
#panelWalls .wall-brush-row button {
  min-height:44px;
  padding:7px 10px;
  font-size:14px;
  font-weight:800;
}
#panelWalls .wall-row-label {
  color:#94a3b8;
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
}
#panelWalls .wall-row-spacer { display:block; }
#panelWalls .wall-brush-row {
  display:grid;
  grid-template-columns:64px auto auto minmax(130px,auto);
  gap:10px;
  align-items:center;
  padding:0 8px;
}
#panelWalls .wall-brush-chip {
  min-height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:6px 12px;
  color:#64748b;
  border:1px solid rgba(148,163,184,.22);
  border-radius:9px;
  background:rgba(15,23,42,.34);
  white-space:nowrap;
  font-size:13px;
}
#panelWalls .wall-help-text,
#panelWalls .terrain-help-text {
  color:#94a3b8;
  font-size:13px;
  line-height:1.45;
  padding:0 8px;
}
#panelWalls .wall-terrain-title {
  color:#f8fafc;
  font-size:17px;
  font-weight:900;
  padding:0 2px;
}
#panelWalls .terrain-button-row {
  display:grid;
  grid-template-columns:repeat(4, minmax(0,auto));
  gap:9px;
  justify-content:start;
  padding:0 8px;
}
@media (max-width:520px) {
  #panelWalls { width:calc(100vw - 30px); }
  #panelWalls .wall-mode-row {
    grid-template-columns:58px repeat(4, minmax(0,1fr));
    gap:6px;
  }
  #panelWalls .wall-mode-row-secondary {
    grid-template-columns:58px repeat(3, minmax(0,1fr)) 1fr;
  }
  #panelWalls .wall-mode-row button,
  #panelWalls .terrain-button-row button,
  #panelWalls .wall-brush-row button {
    min-height:42px;
    padding:6px 7px;
    font-size:13px;
  }
  #panelWalls .wall-brush-row {
    grid-template-columns:58px minmax(0,1fr) auto minmax(120px,1.25fr);
    gap:7px;
    padding:0 4px;
  }
  #panelWalls .wall-brush-chip { min-width:0; padding:6px 7px; font-size:12px; }
  #panelWalls .terrain-button-row { grid-template-columns:repeat(4, minmax(0,1fr)); padding:0 4px; gap:7px; }
  #panelWalls .wall-help-text,
  #panelWalls .terrain-help-text { font-size:12px; padding:0 4px; }
}


/* Stage 8: imported parser/library UI from Stage 95 donor. */

    .ddb-import-box {
      margin-top:8px;
      padding-top:8px;
      border-top:1px solid rgba(255,255,255,.10);
    }
    .ddb-import-button {
      display:flex;
      align-items:center;
      justify-content:center;
      width:100%;
      min-height:38px;
      cursor:pointer;
    }
    .ddb-import-status {
      margin-top:6px;
      color:#94a3b8;
      font-size:9px;
      line-height:1.35;
      overflow-wrap:anywhere;
    }
    .ddb-import-overlay {
      position:fixed;
      inset:0;
      z-index:1000000;
      display:flex;
      align-items:center;
      justify-content:center;
      padding:12px;
      background:rgba(2,6,23,.82);
      backdrop-filter:blur(5px);
      touch-action:manipulation;
    }
    .ddb-import-overlay.hidden { display:none !important; }
    .ddb-import-modal {
      position:relative;
      width:min(94vw,620px);
      max-height:88vh;
      overflow:auto;
      padding:14px;
      border:1px solid rgba(96,165,250,.45);
      border-radius:14px;
      background:#0f172a;
      box-shadow:0 20px 60px rgba(0,0,0,.55);
      color:#f8fafc;
    }
    .ddb-import-subtitle { color:#94a3b8; font-size:10px; line-height:1.4; }
    .ddb-import-summary {
      margin-top:10px;
      padding:10px;
      border:1px solid rgba(255,255,255,.12);
      border-radius:10px;
      background:rgba(15,23,42,.75);
    }
    .ddb-import-summary-grid {
      display:grid;
      grid-template-columns:repeat(2,minmax(0,1fr));
      gap:7px;
      font-size:11px;
    }
    .ddb-import-summary-grid b { color:#7dd3fc; }
    .ddb-import-counts {
      margin-top:8px;
      color:#cbd5e1;
      font-size:10px;
      line-height:1.45;
    }
    .ddb-import-field {
      margin-top:10px;
      display:flex;
      flex-direction:column;
      gap:4px;
    }
    .ddb-import-field label { color:#cbd5e1; font-size:10px; font-weight:700; }
    .ddb-import-field select { width:100%; min-height:38px; }
    .ddb-import-option {
      display:flex;
      gap:8px;
      align-items:flex-start;
      margin-top:9px;
      color:#cbd5e1;
      font-size:10px;
      line-height:1.4;
    }
    .ddb-import-option input { width:auto; margin-top:2px; }
    .ddb-import-changes {
      margin-top:9px;
      padding:8px;
      border-radius:9px;
      background:rgba(30,41,59,.72);
      color:#cbd5e1;
      font-size:10px;
      line-height:1.45;
    }
    .ddb-import-actions {
      display:grid;
      grid-template-columns:1fr 1fr;
      gap:8px;
      margin-top:12px;
    }
    .ddb-import-actions button { min-height:44px; font-weight:800; }
    @media (max-width:480px) {
      .ddb-import-summary-grid { grid-template-columns:1fr; }
      .ddb-import-actions { grid-template-columns:1fr; }
    }


    


    /* Simple Stage 9: narrower floating-right chat window, matching the later mobile layout. */
    #chatDrawer {
      position: fixed !important;
      top: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      left: auto !important;
      width: min(560px, 80vw) !important;
      height: 100dvh !important;
      max-height: 100dvh !important;
      background: rgba(3, 8, 28, 0.985) !important;
      border-left: 1px solid rgba(96, 165, 250, 0.20) !important;
      box-shadow: -10px 0 34px rgba(0,0,0,.62) !important;
      transform: translate3d(105%,0,0);
      transition: transform .22s cubic-bezier(.16,1,.3,1) !important;
      overflow: hidden;
    }
    #chatDrawer.open {
      right: 0 !important;
      transform: translate3d(0,0,0);
    }
    #chatDrawer .chat-header {
      min-height: 66px;
      padding: 12px 16px !important;
      background: rgba(3,8,28,.98) !important;
      border-bottom: 1px solid rgba(96,165,250,.14) !important;
      font-size: 17px !important;
      font-weight: 900 !important;
    }
    #chatMessages {
      padding: 12px !important;
      gap: 9px !important;
      background: rgba(2,6,23,.96);
      overscroll-behavior: contain;
    }
    #chatDrawer .chat-msg {
      padding: 10px 11px !important;
      border-radius: 10px !important;
      border: 1px solid rgba(37,99,235,.30) !important;
      background: rgba(6,18,69,.58) !important;
      font-size: 13px !important;
      line-height: 1.28;
      box-shadow: none !important;
    }
    #chatDrawer .chat-msg.dm {
      background: rgba(6,18,69,.70) !important;
      border-color: rgba(37,99,235,.36) !important;
    }
    #chatDrawer .chat-msg-header {
      font-size: 10px !important;
      margin-bottom: 5px !important;
    }
    #chatDrawer .chat-msg-author.dm { color:#f59e0b !important; }
    #chatDrawer .chat-input-area {
      padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
      background: rgba(3,8,28,.99) !important;
      border-top: 1px solid rgba(96,165,250,.18) !important;
    }
    #chatDrawer .chat-input-row { gap: 7px !important; }
    #chatTextInput {
      min-width: 0;
      min-height: 44px;
      padding: 10px 12px !important;
      border-radius: 10px !important;
      font-size: 13px !important;
      background: rgba(15,23,42,.94) !important;
    }
    #chatDrawer .chat-input-row > label.btn,
    #chatDrawer .chat-input-row > button {
      min-height: 44px;
      border-radius: 10px;
      font-size: 12px;
    }
    @media (max-width: 430px) {
      #chatDrawer { width: 80vw !important; }
      #chatDrawer .chat-header { min-height: 58px; padding: 9px 10px !important; font-size: 15px !important; }
      #chatMessages { padding: 9px !important; gap: 7px !important; }
      #chatDrawer .chat-msg { font-size: 12px !important; padding: 9px !important; }
    }

    /* Simple Stage 10: readable chat result text + rendered **bold** markers. */
    #chatDrawer .chat-msg-text {
      font-size: 15px;
      line-height: 1.34;
      color: #f8fafc;
    }
    #chatDrawer .chat-msg-text strong { font-weight: 900; color: #ffffff; }
    /* Stage 68: cosmetic chat emphasis only. Character names get stable per-name colors; monsters share one color. */
    #chatDrawer .chat-name-tag { font-weight: 900; }
    #chatDrawer .chat-name-monster { color: #fb7185; text-shadow: 0 0 8px rgba(251,113,133,.22); }
    #chatDrawer .chat-roll-total { color: #fbbf24; font-weight: 950; text-shadow: 0 0 8px rgba(251,191,36,.26); }
    @media (max-width: 430px) {
      #chatDrawer .chat-msg { font-size: 14px !important; }
      #chatDrawer .chat-msg-text { font-size: 15px !important; line-height: 1.34; }
    }

/* Stage 21: dedicated Spells / AoE header so collapse/close never cover controls */
#panelAoe .stage21-aoe-header{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:42px;margin-bottom:4px;}
#panelAoe .stage21-aoe-title{font-size:14px;font-weight:900;color:#f8fafc;}
#panelAoe .stage21-aoe-header-actions{display:flex;align-items:center;gap:8px;margin-left:auto;}
#panelAoe .stage21-aoe-header-actions .panel-collapse-btn,
#panelAoe .stage21-aoe-header-actions .panel-close-btn{position:static !important;top:auto !important;right:auto !important;flex:0 0 42px;width:42px;min-width:42px;height:42px;padding:0;margin:0;z-index:auto;}
#panelAoe > .panel-collapse-label{display:none !important;}
#panelAoe.panel-collapsed{padding:8px 10px !important;min-width:245px !important;max-width:min(300px,calc(100vw - 16px)) !important;max-height:60px !important;}
#panelAoe.panel-collapsed > .stage21-aoe-header{display:flex !important;margin:0 !important;min-height:42px !important;}
#panelAoe.panel-collapsed .stage21-aoe-title{display:block !important;}
#panelAoe.panel-collapsed .stage21-aoe-header-actions{display:flex !important;pointer-events:auto !important;}
#panelAoe.panel-collapsed .stage21-aoe-header-actions button{display:flex !important;pointer-events:auto !important;}

/* Stage 24: fixed three-library chooser. Explicit hidden rule prevents it from showing on page load. */
#libraryChooserOverlay.hidden { display:none !important; }
#libraryChooserOverlay {
  position:fixed; inset:0; z-index:300000;
  display:flex; align-items:center; justify-content:center;
  padding:18px; background:rgba(2,6,23,.78); backdrop-filter:blur(5px);
  touch-action:manipulation;
}
.library-chooser-card {
  width:min(360px,94vw); padding:14px;
  border:1px solid rgba(96,165,250,.38); border-radius:14px;
  background:#0f172a; box-shadow:0 18px 55px rgba(0,0,0,.6);
}
.library-chooser-btn { width:100%; min-height:50px; font-size:14px; touch-action:manipulation; }


/* Stage 25: consistent Back navigation for all floating tool panels. */
.panel-back-btn {
  position: static !important;
  flex: 0 0 auto;
  min-width: 66px;
  height: 42px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 850;
  background: rgba(30,41,59,.94);
  border: 1px solid rgba(96,165,250,.38);
  color: #dbeafe;
  touch-action: manipulation;
}
.panel-back-row {
  display:flex;
  align-items:center;
  justify-content:flex-start;
  min-height:34px;
  width:100%;
  padding-right:86px;
  margin-bottom:2px;
}
.tool-panel-header > .panel-back-btn {
  margin-right: 8px;
}
/* Keep Back available even when a panel is collapsed. */
.tool-panel.panel-collapsed > .panel-back-row { display:flex !important; }
.tool-panel.panel-collapsed > .panel-back-btn { display:inline-flex !important; }


/* Stage 29: Move / Fog Only mode. UI-only; does not alter VTT data. */
body.move-fog-only #combatRoundTracker,
body.move-fog-only #chatToggleBtn,
body.move-fog-only #dieLogToggleBtn,
body.move-fog-only #initiativeOrderPopup,
body.move-fog-only #panelCharacterSheet,
body.move-fog-only #panelDice,
body.move-fog-only #panelCharacterImporter,
body.move-fog-only #panelCharacterLibrary,
body.move-fog-only #panelSpellImporter,
body.move-fog-only #panelSpellLibrary,
body.move-fog-only #panelMonsterImporter,
body.move-fog-only #panelMonsterLibrary,
body.move-fog-only #panelWeather,
body.move-fog-only #libraryChooserOverlay {
  display:none !important;
}
body.move-fog-only #toolsMenu .side-menu-section:not(.move-fog-section):not(#accessMenuSection) {
  display:none !important;
}
/* Monster 72: Move/Fog must never hide the ACCESS section. Without this,
   Character Mode cannot reach DM Login/DM Mode to turn Move/Fog back off. */
body.move-fog-only #toolsMenu #accessMenuSection {
  display:block !important;
}
body.move-fog-only #toolsMenu .move-fog-section .side-menu-item:not(.move-fog-allowed) {
  display:none !important;
}
body.move-fog-only #panelTokens .character-library-box,
body.move-fog-only #panelTokens .conditions-container {
  display:none !important;
}
#moveFogModeBtn.active {
  outline:2px solid #38bdf8;
  box-shadow:0 0 0 2px rgba(56,189,248,.18);
}


    /* Stage 41: DM double-tap token quick menu */
    #tokenQuickMenuOverlay { position: fixed; inset: 0; z-index: 12000; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(0,0,0,.58); }
    #tokenQuickMenuOverlay.hidden { display:none !important; }
    /* Stage 49: compact phone-first token quick menu. Mechanics unchanged. */
    #tokenQuickMenuCard { width:min(215px,86vw); background:#071025; border:1px solid #334155; border-radius:12px; padding:9px; box-shadow:0 18px 50px rgba(0,0,0,.55); }
    #tokenQuickMenuName { color:#f59e0b; font-size:17px; font-weight:800; margin:0 0 7px; overflow-wrap:anywhere; }
    .token-quick-grid { display:grid; grid-template-columns:1fr 1fr; gap:5px; }
    .token-quick-grid button { min-height:36px; padding:5px 6px; border-radius:8px; font-size:11px; font-weight:750; }
    #tokenQuickDuplicateBtn[hidden] { display:none; }
    .token-quick-size-row { grid-column:1 / -1; display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:5px; padding:0; }
    .token-quick-size-row label { font-size:11px; font-weight:750; color:#cbd5e1; }
    #tokenQuickSizeSelect { min-height:36px; width:100%; border-radius:8px; font-size:12px; padding:3px 5px; }
    #tokenQuickDeleteBtn { background:#b91c1c; color:white; border:1px solid #ef4444; }
    #tokenQuickCloseBtn { background:#1e293b; }

/* Stage 88 character-console experiment: compact mobile play header + attack cards */
#panelCharacterSheet{
  width:min(430px,calc(100vw - 12px))!important;
}
#panelCharacterSheet #characterSheetTitle,
#panelCharacterSheet #characterSheetStatus{
  display:none!important;
}
.cs-play-header{
  position:sticky;
  top:0;
  z-index:40;
  margin:-2px 0 7px;
  padding:7px;
  border:1px solid rgba(148,163,184,.30);
  border-radius:10px;
  background:rgba(9,13,22,.97);
  box-shadow:0 5px 14px rgba(0,0,0,.28);
}
.cs-play-identity{
  min-width:0;
  padding:0 2px 5px;
  color:#f8fafc;
  letter-spacing:.02em;
}
.cs-play-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:950;line-height:1.2}
.cs-play-detail{margin-top:2px;overflow-wrap:anywhere;color:#94a3b8;font-size:9px;font-weight:800;line-height:1.25}
.cs-play-stats{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:4px;
}
.cs-play-stat{
  min-width:0!important;
  min-height:31px!important;
  padding:4px 3px!important;
  border-radius:7px!important;
  font-size:10px!important;
  font-weight:950!important;
  white-space:nowrap;
}
.cs-play-hp{font-size:11px!important;}
.cs-play-hp-popup{
  margin-top:6px;
  padding:7px;
  border:1px solid rgba(96,165,250,.40);
  border-radius:8px;
  background:rgba(15,23,42,.98);
}
#csPlayHpAmount{
  width:100%;
  min-height:38px;
  text-align:center;
  font-size:16px;
  font-weight:900;
}
.cs-play-hp-actions{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:5px;
  margin-top:5px;
}
.cs-play-hp-actions button{
  min-width:0!important;
  min-height:34px!important;
  padding:4px!important;
  font-size:10px!important;
  font-weight:900!important;
}
.cs-play-attack-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin:2px 0 6px;
  color:#e2e8f0;
  font-size:11px;
  font-weight:950;
}
.cs-compact-attack-list{
  display:grid;
  gap:5px;
  margin-bottom:7px;
}
.cs-compact-attack{
  display:grid;
  grid-template-columns:minmax(0,1.45fr) 52px minmax(72px,.9fr);
  gap:5px;
  align-items:stretch;
  min-height:38px;
}
.cs-compact-attack-name,
.cs-compact-attack-hit,
.cs-compact-attack-dmg{
  min-width:0;
  border:1px solid rgba(148,163,184,.25);
  border-radius:7px;
  background:rgba(30,41,59,.72);
}
.cs-compact-attack-name{
  display:flex;
  flex-direction:column;
  justify-content:center;
  padding:4px 7px;
  overflow:hidden;
}
.cs-compact-attack-name strong{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:11px;
}
.cs-compact-attack-name small{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#94a3b8;
  font-size:8px;
}
.cs-compact-attack-hit,
.cs-compact-attack-dmg{
  padding:3px!important;
  font-size:10px!important;
  font-weight:950!important;
}
.cs-compact-attack-hit{color:#bfdbfe!important;}
.cs-compact-attack-dmg{color:#fde68a!important;}
#panelCharacterSheet:not(.cs-attack-editor-open) [data-cs-page="attacks"] .cs-row-manager,
#panelCharacterSheet:not(.cs-attack-editor-open) [data-cs-page="attacks"] .cs-attack-head,
#panelCharacterSheet:not(.cs-attack-editor-open) [data-cs-page="attacks"] .cs-attack-list,
#panelCharacterSheet:not(.cs-attack-editor-open) [data-cs-page="attacks"] .cs-field:has(#csAttacks){
  display:none!important;
}
#panelCharacterSheet .cs-page-switcher{
  margin-top:2px;
}
#panelCharacterSheet #characterSheetPageHint{
  display:none!important;
}
@media(max-width:420px){
  #panelCharacterSheet{left:6px!important;right:6px!important;width:auto!important;}
}


/* Character console fix 1: true HP popup + reliable phone scrolling/taps */
.cs-play-hp-popup.hidden { display:none !important; }

#csPlayHpPopup {
  position:fixed !important;
  inset:0 !important;
  z-index:500000 !important;
  margin:0 !important;
  padding:14px !important;
  border:0 !important;
  border-radius:0 !important;
  background:rgba(2,6,23,.72) !important;
  display:flex;
  align-items:center;
  justify-content:center;
  touch-action:manipulation !important;
}

#csPlayHpPopup::before {
  content:"";
  position:absolute;
  inset:0;
}

#csPlayHpPopup > * { position:relative; }

.cs-play-hp-modal-card {
  position:relative;
  width:min(330px,92vw);
  padding:12px;
  border:1px solid rgba(96,165,250,.45);
  border-radius:12px;
  background:#0f172a;
  box-shadow:0 18px 55px rgba(0,0,0,.62);
}


body.character-sheet-open {
  touch-action:pan-y !important;
}

body.character-sheet-open #panelCharacterSheet {
  touch-action:pan-y !important;
  overflow-y:auto !important;
  -webkit-overflow-scrolling:touch !important;
}

body.character-sheet-open #panelCharacterSheet button,
body.character-sheet-open #panelCharacterSheet input,
body.character-sheet-open #panelCharacterSheet select {
  touch-action:manipulation !important;
}


/* Character console fix 2: tighten Overview and remove redundant controls */
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csInitiative),
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csAC),
#characterSheetForm [data-cs-page="overview"] .cs-hp-control-box {
  display:none !important;
}

#characterSheetForm [data-cs-page="overview"] {
  padding:7px !important;
  border-radius:9px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-section-title {
  margin-bottom:5px !important;
  font-size:11px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-grid {
  gap:5px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-field {
  gap:2px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-field label {
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="overview"] input,
#characterSheetForm [data-cs-page="overview"] select {
  min-height:34px !important;
  padding:5px 7px !important;
  font-size:14px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-character-id-box {
  padding:5px !important;
  margin-bottom:6px !important;
  gap:5px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-auto-box {
  margin-top:6px !important;
  padding:5px !important;
  gap:5px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-auto-box button {
  min-height:32px !important;
  padding:4px 7px !important;
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-helper {
  margin-top:6px !important;
  padding:6px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-title {
  font-size:11px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-text,
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-note {
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-actions {
  gap:5px !important;
  margin-top:5px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-actions button {
  min-height:32px !important;
  padding:4px 5px !important;
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-ac-helper-box {
  padding:6px !important;
  margin-top:0 !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-ac-helper-summary,
#characterSheetForm [data-cs-page="overview"] .cs-sync-note {
  font-size:9px !important;
  line-height:1.25 !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-ac-helper-actions {
  gap:5px !important;
  margin-bottom:4px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-ac-helper-actions button {
  min-height:32px !important;
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-sync-box {
  padding:6px !important;
  gap:5px !important;
  margin-top:6px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-sync-row {
  gap:5px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-sync-label {
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="overview"] .cs-sync-box button {
  min-height:32px !important;
  padding:4px 7px !important;
  font-size:10px !important;
}


/* Character console fix 3: remove setup helpers from normal play Overview and tighten layout.
   Underlying calculations/functions remain intact. */
#characterSheetForm [data-cs-page="overview"] .cs-level-auto-box,
#characterSheetForm [data-cs-page="overview"] .cs-level-up-hp-helper,
#characterSheetForm [data-cs-page="overview"] .cs-ac-helper-box {
  display:none !important;
}

/* Tighter Overview cards and spacing. */
#characterSheetForm [data-cs-page="overview"] {
  padding:5px !important;
  margin-bottom:5px !important;
  border-radius:8px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-section-title {
  margin:0 0 4px !important;
  font-size:10px !important;
  line-height:1.15 !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-grid,
#characterSheetForm [data-cs-page="overview"] .cs-grid.cs-three {
  gap:4px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-field {
  gap:1px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-field label {
  font-size:8px !important;
  line-height:1.1 !important;
}

#characterSheetForm [data-cs-page="overview"] input,
#characterSheetForm [data-cs-page="overview"] select {
  min-height:29px !important;
  height:29px !important;
  padding:3px 6px !important;
  border-radius:6px !important;
  font-size:12px !important;
}

#characterSheetForm [data-cs-page="overview"] button {
  min-height:29px !important;
  padding:3px 6px !important;
  border-radius:6px !important;
  font-size:9px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-character-id-box {
  padding:4px !important;
  margin:0 0 4px !important;
  gap:4px !important;
  border-radius:7px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-character-id-label {
  font-size:7px !important;
}

#characterSheetForm [data-cs-page="overview"] #csCharacterIdDisplay {
  font-size:9px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-sync-box {
  margin-top:4px !important;
  padding:5px !important;
  gap:4px !important;
  border-radius:7px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-sync-label {
  font-size:9px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-sync-note,
#characterSheetForm [data-cs-page="overview"] #csTokenSyncStatus {
  font-size:8px !important;
  line-height:1.15 !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-sync-row {
  gap:4px !important;
}

#characterSheetForm [data-cs-page="overview"] .cs-dice-color-row {
  gap:4px !important;
}

#characterSheetForm [data-cs-page="overview"] #csDiceColorPreview {
  width:29px !important;
  height:29px !important;
  border-radius:6px !important;
}

/* Combat values now use compact cards; AC/HP actions live in the top header. */
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csSpeed),
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csHPCurrent),
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csHPMax),
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csHPTemp),
#characterSheetForm [data-cs-page="overview"] .cs-field:has(#csHitDice) {
  padding:3px 4px !important;
  border:1px solid rgba(148,163,184,.12);
  border-radius:7px;
  background:rgba(15,23,42,.30);
}

/* Keep the important values editable, but visually subordinate to the play header. */
#characterSheetForm [data-cs-page="overview"] #csSpeed,
#characterSheetForm [data-cs-page="overview"] #csHPCurrent,
#characterSheetForm [data-cs-page="overview"] #csHPMax,
#characterSheetForm [data-cs-page="overview"] #csHPTemp,
#characterSheetForm [data-cs-page="overview"] #csHitDice {
  min-height:27px !important;
  height:27px !important;
  border:0 !important;
  background:transparent !important;
  box-shadow:none !important;
  padding:1px 3px !important;
  font-size:12px !important;
}

/* Slightly tighten the permanent header too without changing its design. */
.cs-play-header {
  padding:6px !important;
  margin-bottom:6px !important;
}
.cs-play-identity {
  padding-bottom:4px !important;
  font-size:12px !important;
}
.cs-play-stat {
  min-height:29px !important;
  font-size:9px !important;
}


/* Character console fix 4: automatic sync stays; manual Token Sync controls are hidden. */
#characterSheetForm [data-cs-page="overview"] .cs-sync-box {
  display:none !important;
}


/* Fix 5: carry the approved Overview visual language through the rest of the sheet. */

/* ---------- universal compact play-page treatment ---------- */
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) {
  padding:6px !important;
  margin-bottom:5px !important;
  border-radius:8px !important;
}
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) .cs-section-title {
  margin:0 0 5px !important;
  font-size:10px !important;
  line-height:1.15 !important;
}
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) input,
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) select,
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) textarea {
  border-radius:6px !important;
  font-size:12px !important;
}
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) button {
  border-radius:6px !important;
  font-size:9px !important;
}
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) .cs-auto-note,
#characterSheetForm .cs-page-section:not([data-cs-page="overview"]) .cs-sync-note {
  font-size:8px !important;
  line-height:1.2 !important;
}

/* Keep Roll Mode but make it a thin single-row control. */
#characterSheetForm [data-cs-page="abilities"] .cs-roll-mode,
#characterSheetForm [data-cs-page="skills"] .cs-roll-mode,
#characterSheetForm [data-cs-page="attacks"] .cs-roll-mode,
#characterSheetForm [data-cs-page="spells"] .cs-roll-mode {
  gap:4px !important;
  margin:0 !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-mode button,
#characterSheetForm [data-cs-page="skills"] .cs-roll-mode button,
#characterSheetForm [data-cs-page="attacks"] .cs-roll-mode button,
#characterSheetForm [data-cs-page="spells"] .cs-roll-mode button {
  min-height:30px !important;
  padding:3px 4px !important;
  font-size:9px !important;
}
/* Explanations immediately below Roll Mode are redundant in play. */
#characterSheetForm [data-cs-page="abilities"] .cs-roll-mode + div,
#characterSheetForm [data-cs-page="skills"] .cs-roll-mode + div,
#characterSheetForm [data-cs-page="attacks"] .cs-roll-mode + div,
#characterSheetForm [data-cs-page="spells"] .cs-roll-mode + div {
  display:none !important;
}

/* ---------- ABILITIES ---------- */
/* Automatic setup/calculation helper is not a normal-play control. */
#characterSheetForm [data-cs-page="abilities"] .cs-auto-row {
  display:none !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-abilities {
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:4px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-ability {
  padding:4px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-ability label {
  margin-bottom:2px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-ability input {
  height:28px !important;
  min-height:28px !important;
  padding:2px !important;
  font-size:12px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-ability-mod {
  min-height:28px !important;
  margin-top:3px !important;
  padding:2px !important;
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-table {
  grid-template-columns:1fr !important;
  gap:3px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-row.cs-save-row {
  grid-template-columns:minmax(0,1fr) auto 50px auto !important;
  min-height:32px !important;
  padding:3px 5px !important;
  gap:4px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-row.cs-save-row span {
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-save-prof {
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-save-prof input {
  width:15px !important;
  height:15px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-row.cs-save-row > input {
  height:27px !important;
  min-height:27px !important;
  font-size:11px !important;
}
#characterSheetForm [data-cs-page="abilities"] .cs-roll-row.cs-save-row > button {
  min-height:27px !important;
  padding:2px 6px !important;
}

/* ---------- SKILLS ---------- */
#characterSheetForm [data-cs-page="skills"] .cs-auto-row {
  margin:0 0 5px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-auto-row > .cs-auto-note {
  display:none !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-passive {
  padding:4px 7px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-roll-table {
  grid-template-columns:1fr !important;
  gap:3px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-roll-row.cs-skill-row {
  grid-template-columns:minmax(0,1fr) 62px 46px auto !important;
  min-height:31px !important;
  padding:3px 5px !important;
  gap:4px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-roll-row.cs-skill-row span {
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-prof-select {
  width:62px !important;
  min-width:62px !important;
  height:27px !important;
  min-height:27px !important;
  padding:2px 14px 2px 4px !important;
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-roll-row.cs-skill-row > input {
  height:27px !important;
  min-height:27px !important;
  padding:2px !important;
  font-size:10px !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-roll-row.cs-skill-row > button {
  min-height:27px !important;
  padding:2px 5px !important;
}

/* ---------- ATTACKS ---------- */
#characterSheetForm [data-cs-page="attacks"] .cs-section-title {
  display:none !important;
}
#characterSheetForm [data-cs-page="attacks"] #csMonsterMultiattackBox,
#characterSheetForm [data-cs-page="attacks"] #csMonsterSaveAbilityBox {
  padding:5px !important;
  margin:4px 0 !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="attacks"] #csMonsterMultiattackDescription,
#characterSheetForm [data-cs-page="attacks"] #csMonsterSaveAbilityBox > div:nth-child(2) {
  font-size:8px !important;
  line-height:1.2 !important;
}
#characterSheetForm [data-cs-page="attacks"] .cs-play-attack-toolbar {
  margin:0 0 5px !important;
}
#characterSheetForm [data-cs-page="attacks"] .cs-compact-attack-list {
  gap:4px !important;
}
#characterSheetForm [data-cs-page="attacks"] .cs-compact-attack {
  min-height:34px !important;
}
#characterSheetForm [data-cs-page="attacks"] .cs-compact-attack-name strong {
  font-size:10px !important;
}

/* ---------- LIMITED RESOURCES / FEATURES ---------- */
/* Keep function, remove the long instructions. */
#characterSheetForm [data-cs-page="features"] .cs-resource-help {
  display:none !important;
}
#characterSheetForm [data-cs-page="features"] .cs-row-controls {
  display:flex !important;
  gap:4px !important;
  margin-bottom:5px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-row-controls button {
  min-height:28px !important;
  padding:3px 6px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-row {
  margin-top:4px !important;
  padding:5px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-name {
  height:28px !important;
  min-height:28px !important;
  margin-bottom:4px !important;
  padding:3px 6px !important;
  font-size:11px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-numbers {
  gap:4px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-numbers label {
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-numbers input,
#characterSheetForm [data-cs-page="features"] .cs-resource-numbers select {
  height:27px !important;
  min-height:27px !important;
  padding:2px 4px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-display {
  margin-top:3px !important;
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-actions {
  gap:4px !important;
  margin-top:4px !important;
}
#characterSheetForm [data-cs-page="features"] .cs-resource-actions button {
  min-height:27px !important;
  padding:2px 3px !important;
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="features"] textarea {
  min-height:60px !important;
  padding:5px !important;
  font-size:10px !important;
}

/* ---------- SPELLS ---------- */
#characterSheetForm [data-cs-page="spells"] .cs-spell-grid {
  gap:4px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-stat {
  padding:5px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-stat label {
  font-size:8px !important;
  margin-bottom:2px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-stat input,
#characterSheetForm [data-cs-page="spells"] .cs-spell-stat select,

/* Monster 66: class-aware Sorcerer resource design card. */
.cs-sorcerer-magic-card {
  margin: 0 0 10px; padding: 9px; border: 1px solid #334155; border-radius: 8px; background: #0f172a;
}
.cs-sorcerer-magic-card.hidden { display: none !important; }
.cs-sorcerer-magic-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.cs-sorcerer-magic-resource { border:1px solid #334155; border-radius:7px; padding:7px; background:#111827; }
.cs-sorcerer-magic-resource-title { font-size:11px; font-weight:700; color:#e2e8f0; margin-bottom:5px; }
.cs-sorcerer-magic-numbers { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.cs-sorcerer-magic-numbers label { font-size:9px; color:#94a3b8; }
.cs-sorcerer-magic-numbers input { width:100%; margin-top:3px; }
.cs-sorcerer-magic-actions { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-top:6px; }
.cs-sorcerer-magic-actions button { min-height:28px; padding:4px 6px; border:1px solid #475569; border-radius:6px; background:#172033; color:#e2e8f0; font-size:10px; font-weight:700; }
.cs-sorcerer-magic-actions button:disabled { opacity:.4; }
/* SHEETS 233: the shared small-button style has no turned-off look, so the Wild Shape card (Wild Shape, Wild Resurgence, Wild Companion, Nature Magician) fades its own buttons the same way. */
#csWildShapeCard .cs-mini-roll:disabled { opacity:.4; cursor:default; }
#csNaturesWrath1640 { white-space:normal; }
#csNaturesWrath1640:disabled { opacity:.4; cursor:default; }
#csElderChampionCard1644 .cs-mini-roll,
#csAvengingAngelCard1638 .cs-mini-roll { white-space:normal; }
#csElderChampionCard1644 .cs-mini-roll:disabled,
#csAvengingAngelCard1638 .cs-mini-roll:disabled { opacity:.4; cursor:default; }
/* SHEETS 283: turned-off Intimidating Presence buttons look turned off, and long labels wrap at phone width. */
#csIntimidatingPresenceUseBtn, #csIntimidatingPresenceRestoreBtn { white-space:normal; }
#csIntimidatingPresenceUseBtn:disabled, #csIntimidatingPresenceRestoreBtn:disabled { opacity:.4; cursor:default; }
/* SHEETS 237 — turned-off Moonlight Step buttons look turned off */
#csMoonlightStepBtn:disabled, #csMoonlightStepRegainBtn:disabled { opacity:.4; cursor:default; }
/* SHEETS 242 — turned-off Draconic Flight buttons look turned off */
#csDraconicFlightExtendBtn:disabled, #csDraconicFlightRetractBtn:disabled { opacity:.4; cursor:default; }
/* SHEETS 243 — turned-off Breath Weapon buttons look turned off */
#csBreathWeaponConeBtn:disabled, #csBreathWeaponLineBtn:disabled { opacity:.4; cursor:default; }
/* SHEETS 248 — turned-off Rage buttons look turned off */
#csRageEnterBtn:disabled, #csRageEndBtn:disabled, #csRageExtendBtn:disabled { opacity:.4; cursor:default; }
.cs-sorcerer-magic-note { margin-top:6px; font-size:9px; line-height:1.35; color:#94a3b8; }
.cs-metamagic-wrap { margin-top:8px; border-top:1px solid #334155; padding-top:8px; }
.cs-metamagic-title { font-size:11px; font-weight:800; color:#e2e8f0; margin-bottom:6px; }
.cs-metamagic-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:6px; align-items:center; margin-top:6px; }
.cs-metamagic-row.hidden { display:none !important; }
.cs-metamagic-choice { min-width:0; width:100%; border:1px solid #334155; border-radius:6px; background:#0f172a; color:#e2e8f0; padding:7px 8px; font-size:10px; font-weight:700; }
.cs-metamagic-cost { min-width:42px; text-align:center; font-size:9px; color:#94a3b8; }
.cs-metamagic-use { min-height:30px; padding:4px 8px; border:1px solid #475569; border-radius:6px; background:#172033; color:#e2e8f0; font-size:10px; font-weight:800; }
.cs-metamagic-use:disabled { opacity:.4; }
#characterSheetForm [data-cs-page="spells"] .cs-spell-stat button {
  height:29px !important;
  min-height:29px !important;
  padding:2px 5px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-concentration-box {
  margin-top:5px !important;
  padding:5px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-concentration-row {
  gap:4px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-concentration-row input {
  height:28px !important;
  min-height:28px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-concentration-duration-row {
  gap:4px !important;
  margin-top:4px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-concentration-status {
  margin-top:3px !important;
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-grid {
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:4px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-card {
  padding:4px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-title {
  margin-bottom:3px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-inputs {
  gap:3px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-inputs label {
  font-size:7px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-slot-inputs input {
  height:25px !important;
  min-height:25px !important;
  padding:1px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-slot-display {
  margin-top:2px !important;
  font-size:7px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-slot-actions {
  gap:3px !important;
  margin-top:3px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-slot-actions button {
  min-height:25px !important;
  padding:1px 2px !important;
  font-size:7px !important;
}
/* Spell editor rows stay functional but take less vertical space. */
#characterSheetForm [data-cs-page="spells"] .cs-row-manager {
  gap:4px !important;
  margin:4px 0 !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-row-manager button {
  min-height:27px !important;
  padding:2px 4px !important;
}
#characterSheetForm [data-cs-page="spells"] .cs-spell-row,
#characterSheetForm [data-cs-page="spells"] .cs-save-spell-row {
  padding:4px !important;
  gap:3px !important;
  border-radius:7px !important;
}


/* CHARACTER DESIGN 45: PDF-authoritative inventory snapshot/reference. */
.cs-inventory-pdf-summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
  margin:8px 0 10px;
}
.cs-inventory-pdf-summary label{
  display:flex;
  flex-direction:column;
  gap:3px;
  font-size:10px;
  opacity:.92;
}
.cs-inventory-pdf-summary input{
  width:100%;
  min-width:0;
}
.cs-inventory-authority-note{
  font-size:10px;
  line-height:1.35;
  opacity:.78;
  margin:6px 0 8px;
}
@media (max-width:600px){
  .cs-inventory-pdf-summary{grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;}
  .cs-inventory-pdf-summary label{font-size:9px;}
  .cs-inventory-pdf-summary input{padding:8px 5px;font-size:11px;}
}

/* ---------- INVENTORY / DETAILS ---------- */
#characterSheetForm [data-cs-page="inventory"] {
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="inventory"] .cs-currency-grid {
  gap:3px !important;
}
#characterSheetForm [data-cs-page="inventory"] .cs-currency-grid input {
  height:27px !important;
  min-height:27px !important;
  padding:2px !important;
}
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-row {
  margin-top:3px !important;
  gap:3px !important;
}
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-row input,
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-row select {
  min-height:27px !important;
  height:27px !important;
  padding:2px 3px !important;
  font-size:8px !important;
}
#characterSheetForm [data-cs-page="inventory"] textarea {
  min-height:55px !important;
}

/* ---------- CONDITIONS ---------- */
#characterSheetForm [data-cs-page="conditions"] .cs-sync-box {
  padding:5px !important;
  gap:4px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="conditions"] .cs-condition-sync-grid {
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  gap:3px !important;
}
#characterSheetForm [data-cs-page="conditions"] .cs-condition-sync-item {
  min-height:30px !important;
  padding:4px 6px !important;
  border-radius:6px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="conditions"] .cs-condition-sync-item input {
  width:15px !important;
  height:15px !important;
}

/* ---------- SURVIVAL / REST ---------- */
#characterSheetForm [data-cs-page="survival"] .cs-survival-grid {
  gap:5px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-survival-card {
  padding:5px !important;
  border-radius:7px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-survival-title {
  margin-bottom:4px !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-death-row {
  gap:4px !important;
  margin:3px 0 !important;
  font-size:9px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-death-checks {
  gap:3px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-death-checks input,
#characterSheetForm [data-cs-page="survival"] .cs-inspiration-row input {
  width:16px !important;
  height:16px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-hit-dice-row {
  gap:4px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-hit-dice-row input {
  height:28px !important;
  min-height:28px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-rest-actions {
  gap:4px !important;
  margin-top:5px !important;
}
#characterSheetForm [data-cs-page="survival"] .cs-rest-actions button {
  min-height:30px !important;
  padding:3px 5px !important;
}

/* ---------- NOTES ---------- */
#characterSheetForm [data-cs-page="notes"] textarea {
  min-height:100px !important;
  padding:6px !important;
  font-size:10px !important;
}

/* Slightly smaller section navigator to match the approved Overview density. */
#panelCharacterSheet .cs-page-switcher {
  grid-template-columns:42px minmax(0,1fr) 42px !important;
  gap:5px !important;
  margin:6px 0 !important;
}
#panelCharacterSheet .cs-page-nav-btn,
#panelCharacterSheet .cs-page-center-btn {
  min-height:38px !important;
}
#panelCharacterSheet .cs-page-title-text {
  font-size:11px !important;
}
#panelCharacterSheet .cs-page-subtext {
  font-size:8px !important;
}


/* Fix 6: notes/text fields open into a page-size editor when tapped. */
.cs-large-text-overlay.hidden { display:none !important; }
.cs-large-text-overlay {
  position:fixed;
  inset:0;
  z-index:700000;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px;
  background:rgba(2,6,23,.80);
  backdrop-filter:blur(5px);
  touch-action:manipulation;
}
.cs-large-text-card {
  width:min(560px,96vw);
  height:min(82dvh,760px);
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border:1px solid rgba(96,165,250,.45);
  border-radius:12px;
  background:#0f172a;
  box-shadow:0 20px 60px rgba(0,0,0,.60);
}
.cs-large-text-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:38px;
  font-size:14px;
  font-weight:900;
}
#csLargeTextEditor {
  flex:1 1 auto;
  width:100%;
  min-height:0;
  resize:none;
  padding:10px !important;
  border-radius:9px !important;
  font-size:15px !important;
  line-height:1.35 !important;
  user-select:text !important;
  touch-action:auto !important;
}
.cs-large-text-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
.cs-large-text-actions button {
  min-height:38px !important;
  font-size:11px !important;
}

/* Normal sheet textareas stay compact and act as launchers. */
#panelCharacterSheet textarea.cs-large-text-launcher {
  cursor:pointer;
  caret-color:transparent;
}


/* Fix 9: Full Inventory launcher. */
.cs-full-inventory-launch {
  margin-top:7px;
  padding:6px;
  border:1px solid rgba(96,165,250,.22);
  border-radius:8px;
  background:rgba(15,23,42,.34);
}
.cs-full-inventory-launch button {
  width:100%;
  min-height:34px !important;
  font-size:10px !important;
  font-weight:900 !important;
}
.cs-full-inventory-launch > div {
  margin-top:4px;
  color:#94a3b8;
  font-size:8px;
  line-height:1.2;
}


/* Fix 10: full Spellbook launcher. */
.cs-spellbook-launch {
  margin-top:7px;
  padding:6px;
  border:1px solid rgba(96,165,250,.22);
  border-radius:8px;
  background:rgba(15,23,42,.34);
}
.cs-spellbook-launch button {
  width:100%;
  min-height:34px !important;
  font-size:10px !important;
  font-weight:900 !important;
}
.cs-spellbook-launch > div {
  margin-top:4px;
  color:#94a3b8;
  font-size:8px;
  line-height:1.2;
}


/* Clean text-window fix: render editor at BODY level, independent of Character Sheet panel. */
.cs-large-text-overlay.hidden { display:none !important; }
.cs-large-text-overlay {
  position:fixed !important;
  inset:0 !important;
  z-index:1000000 !important;
  display:flex !important;
  align-items:stretch !important;
  justify-content:center !important;
  padding:8px !important;
  background:rgba(2,6,23,.92) !important;
  backdrop-filter:blur(5px);
  -webkit-backdrop-filter:blur(5px);
  overflow:hidden !important;
  touch-action:manipulation !important;
}
.cs-large-text-overlay.hidden { display:none !important; }

.cs-large-text-card {
  width:min(620px,100%) !important;
  height:calc(100dvh - 16px) !important;
  max-height:calc(100dvh - 16px) !important;
  margin:0 auto !important;
  display:flex !important;
  flex-direction:column !important;
  gap:7px !important;
  padding:8px !important;
  border:1px solid rgba(96,165,250,.45) !important;
  border-radius:12px !important;
  background:#0f172a !important;
  box-shadow:0 20px 60px rgba(0,0,0,.65) !important;
  overflow:hidden !important;
}

.cs-large-text-header {
  flex:0 0 auto !important;
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:8px !important;
  min-height:38px !important;
  font-size:14px !important;
  font-weight:900 !important;
}

#csLargeTextEditor {
  flex:1 1 auto !important;
  width:100% !important;
  min-height:0 !important;
  max-height:none !important;
  resize:none !important;
  overflow:auto !important;
  padding:10px !important;
  border-radius:9px !important;
  font-size:15px !important;
  line-height:1.35 !important;
  user-select:text !important;
  -webkit-user-select:text !important;
  touch-action:auto !important;
  overscroll-behavior:contain !important;
  -webkit-overflow-scrolling:touch !important;
}

.cs-large-text-actions {
  flex:0 0 auto !important;
  display:grid !important;
  grid-template-columns:1fr 1fr !important;
  gap:7px !important;
}
.cs-large-text-actions button {
  min-height:40px !important;
  font-size:10px !important;
}

body.cs-large-text-open {
  overflow:hidden !important;
  touch-action:none !important;
}

/* Keep the modal usable when Samsung's keyboard reduces the visual viewport. */
@media (max-height:560px) {
  .cs-large-text-overlay { padding:4px !important; }
  .cs-large-text-card {
    height:calc(100dvh - 8px) !important;
    max-height:calc(100dvh - 8px) !important;
    padding:6px !important;
  }
  .cs-large-text-header { min-height:32px !important; }
  .cs-large-text-actions button { min-height:34px !important; }
}



/* V4: read-only monster/SRD reference. This layer never changes combat mechanics. */
#monsterReferencePanel{margin-top:10px;padding:8px;border:1px solid rgba(148,163,184,.28);border-radius:9px;background:rgba(15,23,42,.55)}
#monsterReferencePanel.hidden{display:none!important}
.monster-ref-title{font-size:11px;font-weight:800;color:#f8fafc;margin:0 0 6px}
.monster-ref-subtitle{font-size:10px;color:#94a3b8;margin:7px 0 4px}
.monster-ref-chips{display:flex;flex-wrap:wrap;gap:5px}
.monster-ref-chip{font-size:10px!important;line-height:1.1!important;padding:5px 7px!important;min-height:0!important;border-radius:7px!important;border:1px solid rgba(96,165,250,.45)!important;background:rgba(30,64,175,.22)!important;color:#dbeafe!important}
.monster-ref-chip.rule{border-color:rgba(251,191,36,.45)!important;background:rgba(120,53,15,.22)!important;color:#fef3c7!important}
#rulesReferenceOverlay{position:fixed;inset:0;z-index:1200000;background:rgba(2,6,23,.96);display:flex;flex-direction:column;padding:10px;touch-action:auto}
#rulesReferenceOverlay.hidden{display:none!important}
#rulesReferenceHeader{display:flex;align-items:center;gap:8px;padding:4px 0 9px;border-bottom:1px solid rgba(148,163,184,.28)}
#rulesReferenceTitle{flex:1;font-size:16px;font-weight:900;color:#f8fafc}
#rulesReferenceClose{font-size:12px;padding:7px 10px}
#rulesReferenceSource{font-size:10px;color:#94a3b8;margin:8px 0 4px}
#rulesReferenceBody{flex:1;overflow:auto;white-space:pre-wrap;font-size:14px;line-height:1.5;color:#e2e8f0;padding:6px 2px 24px;user-select:text;touch-action:pan-y}



#panelMonsterSheet{
  position:fixed!important;top:48px!important;left:8px!important;
  z-index:150000!important;width:min(440px,calc(100vw - 16px))!important;
  max-height:calc(100dvh - 58px)!important;overflow-y:auto!important;overflow-x:hidden!important;
  padding:9px!important;border:1px solid rgba(148,163,184,.34)!important;border-radius:12px!important;
  background:rgba(8,13,24,.985)!important;box-shadow:0 18px 55px rgba(0,0,0,.58)!important;
  touch-action:pan-y!important;-webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;
}
#panelMonsterSheet.hidden{display:none!important}
.ms-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:7px}
.ms-name{font-size:18px;font-weight:950;color:#f8fafc;line-height:1.1;overflow-wrap:anywhere}
.ms-sub{font-size:9px;color:#94a3b8;margin-top:3px;line-height:1.3}
.ms-head-actions{display:flex;gap:5px;flex:0 0 auto}.ms-head-actions button{min-width:34px;height:34px;padding:0 7px}
.ms-preview-banner{display:none;padding:5px 7px;margin-bottom:7px;border:1px solid rgba(250,204,21,.42);border-radius:7px;background:rgba(113,63,18,.2);font-size:9px;color:#fde68a;font-weight:800}
.ms-preview .ms-preview-banner{display:block}
.ms-statbar{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;margin:6px 0 4px}
.ms-stat{padding:5px 3px;text-align:center;border:1px solid rgba(148,163,184,.22);border-radius:7px;background:rgba(15,23,42,.82)}
.ms-stat b{display:block;color:#f8fafc;font-size:12px}.ms-stat span{font-size:7px;color:#94a3b8;text-transform:uppercase;letter-spacing:.05em}
.ms-speed-row{display:flex;align-items:flex-start;gap:8px;padding:6px 8px;margin:0 0 6px;border:1px solid rgba(148,163,184,.22);border-radius:7px;background:rgba(15,23,42,.82)}
.ms-speed-row span{flex:0 0 auto;padding-top:2px;font-size:7px;color:#94a3b8;text-transform:uppercase;letter-spacing:.05em;font-weight:800}.ms-speed-row b{min-width:0;color:#f8fafc;font-size:11px;line-height:1.35;overflow-wrap:anywhere}
.ms-roll-mode{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;margin:6px 0}
.ms-roll-mode-four{grid-template-columns:repeat(4,minmax(0,1fr))}
.ms-roll-mode button{min-height:25px!important;padding:2px 3px!important;font-size:8px!important}
.ms-condition-open-btn.active{outline:none!important}
#msConditionOverlay{
  position:fixed;inset:0;z-index:2147483450;background:rgba(2,6,23,.76);
  display:flex;align-items:center;justify-content:center;padding:14px;
}
#msConditionOverlay.hidden{display:none!important}
.ms-condition-modal-card{
  width:min(94vw,440px);max-height:84vh;overflow:auto;touch-action:pan-y;
  background:#050b18;border:1px solid rgba(125,211,252,.45);border-radius:14px;
  padding:11px;box-shadow:0 24px 70px rgba(0,0,0,.72);
}
.ms-condition-modal-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.ms-condition-modal-title{font-size:15px;font-weight:900;color:#e0f2fe}
.ms-condition-modal-sub{font-size:9px;color:#94a3b8;margin-top:2px}

.ms-condition-exhaustion-row{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:7px 8px;margin-bottom:8px;border:1px solid rgba(148,163,184,.22);
  border-radius:8px;background:rgba(15,23,42,.72);font-size:10px;font-weight:800;
}
.ms-condition-exhaustion-row select{min-width:100px;min-height:30px;font-size:10px}

.ms-section{margin-top:7px;padding:7px;border:1px solid rgba(148,163,184,.20);border-radius:8px;background:rgba(15,23,42,.52)}
.ms-section-title{font-size:10px;font-weight:900;color:#bae6fd;margin-bottom:5px;text-transform:uppercase;letter-spacing:.04em}
.ms-abilities{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:4px}
.ms-ability{padding:4px 2px;text-align:center;border:1px solid rgba(148,163,184,.20);border-radius:7px;background:rgba(2,6,23,.50)}
.ms-ability-name{font-size:7px;color:#94a3b8;font-weight:900}.ms-ability-score{font-size:13px;color:#f8fafc;font-weight:900}.ms-ability button{width:100%;min-height:24px!important;margin-top:2px;padding:1px!important;font-size:8px!important}
.ms-chip-row{display:flex;gap:4px;flex-wrap:wrap}.ms-chip{min-height:28px!important;padding:4px 7px!important;border:1px solid rgba(148,163,184,.25)!important;border-radius:7px!important;background:rgba(2,6,23,.5)!important;font-size:9px!important;color:#e2e8f0!important}
.ms-empty{font-size:9px;color:#64748b;font-style:italic}
.ms-multiattack{margin-bottom:6px;padding:6px;border:1px solid rgba(250,204,21,.42);border-radius:7px;background:rgba(113,63,18,.18)}
.ms-multiattack-top{display:flex;align-items:center;gap:6px}.ms-multiattack-top strong{flex:1;color:#fde68a;font-size:10px}.ms-multiattack-text{margin-top:4px;font-size:9px;color:#cbd5e1;line-height:1.3;white-space:pre-wrap}
.ms-attack-list{display:grid;gap:4px}.ms-attack-card{display:grid;grid-template-columns:minmax(0,1.4fr) 52px minmax(70px,.9fr);gap:4px;align-items:stretch;min-height:34px}
.ms-attack-name{display:flex;flex-direction:column;justify-content:center;min-width:0;padding:4px 6px;border:1px solid rgba(148,163,184,.24);border-radius:7px;background:rgba(30,41,59,.72);cursor:pointer}
.ms-attack-name strong{font-size:10px;text-decoration:underline dotted;text-underline-offset:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ms-attack-name small{font-size:7px;color:#94a3b8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ms-attack-card button{min-width:0!important;padding:3px!important;font-size:9px!important;font-weight:900!important}.ms-hit{color:#bfdbfe!important}.ms-dmg{color:#fde68a!important}
.ms-attack-card .ms-dmg{white-space:normal;overflow-wrap:anywhere}
.ms-save-ability{margin-top:5px;padding:6px;border:1px solid rgba(56,189,248,.30);border-radius:7px;background:rgba(8,47,73,.18)}
.ms-save-ability-top{display:flex;align-items:center;gap:5px}.ms-save-ability-name{flex:1;min-width:0;font-size:10px;font-weight:900;color:#bae6fd}.ms-save-ability-meta{font-size:8px;color:#94a3b8;margin-top:3px;line-height:1.3}.ms-save-ability-text{font-size:9px;color:#cbd5e1;margin-top:4px;line-height:1.35;white-space:pre-wrap}
.ms-text-entry{margin-top:4px;padding:5px;border:1px solid rgba(148,163,184,.17);border-radius:7px;background:rgba(2,6,23,.42)}.ms-text-entry-name{font-size:10px;font-weight:900;color:#e2e8f0;text-decoration:underline dotted;text-underline-offset:2px;cursor:pointer}.ms-text-entry-body{font-size:9px;color:#cbd5e1;line-height:1.35;margin-top:3px;white-space:pre-wrap}
.ms-defense{font-size:9px;color:#cbd5e1;line-height:1.4;margin-top:3px}.ms-raw{width:100%;min-height:180px;resize:vertical;background:#020617;color:#cbd5e1;border:1px solid rgba(148,163,184,.25);border-radius:7px;padding:7px;font-size:9px;line-height:1.35;user-select:text;touch-action:auto}
.ms-preview button[data-ms-combat="1"]{pointer-events:none;opacity:.58}
@media(max-width:540px){#panelMonsterSheet{left:6px!important;right:6px!important;width:auto!important}.ms-abilities{grid-template-columns:repeat(3,minmax(0,1fr))}}


/* MONSTER REBUILD 2: interactive monster HP/initiative + roll overlays above every window. */
#diceCanvas { position:fixed !important; z-index:2147483600 !important; }
#dice3dOverlay { z-index:2147483601 !important; }
#rollTotalPopup { z-index:2147483602 !important; }
#attackResultBanner { z-index:2147483603 !important; }
#cancelPendingActionBtn { z-index:2147483604 !important; }
/* SHEETS 136: Keep the live cancellation control available without obscuring
   3D affected-target previews or the Lock Aim & Cast button. This applies
   only while the full 3D panel is expanded; minimized/closed layout stays as-is. */
body:has(#dt3dAim106[style*="display: block"]) #cancelPendingActionBtn {
  top: 56px !important;
  bottom: auto !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  max-width: min(210px, 40vw);
}


.ms-stat.ms-stat-button {
  appearance:none; -webkit-appearance:none; width:100%; min-width:0;
  color:inherit; font:inherit; cursor:pointer; touch-action:manipulation;
}
.ms-stat.ms-stat-button:active { transform:scale(.97); }
.ms-stat.ms-stat-button:disabled { cursor:default; opacity:.58; transform:none; }

#msHpOverlay.hidden { display:none !important; }
#msHpOverlay {
  position:fixed; inset:0; z-index:2147483500; display:flex; align-items:center; justify-content:center;
  padding:14px; background:rgba(2,6,23,.72); touch-action:manipulation;
}
.ms-hp-modal-card {
  width:min(330px,92vw); padding:12px; border:1px solid rgba(96,165,250,.45);
  border-radius:12px; background:#0f172a; box-shadow:0 18px 55px rgba(0,0,0,.62);
}
.ms-hp-modal-title { text-align:center; font-size:13px; font-weight:900; margin-bottom:7px; color:#f8fafc; }
#msHpAmount { width:100%; min-height:42px; text-align:center; font-size:17px; font-weight:900; }
.ms-hp-modal-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; margin-top:7px; }
.ms-hp-modal-actions button { min-height:40px; font-size:11px; font-weight:900; }


    /* Libraries 10: all opened VTT windows stay above the persistent turn panel. */
    .tool-panel,
    .modal,
    [role="dialog"],
    #characterSheetPanel,
    #monsterSheetPanel,
    #monsterLibraryPanel,
    #monsterImporterPanel {
      z-index: 12000 !important;
    }

/* Libraries 13: empty Monster Sheet categories stay hidden. */
.ms-section.hidden { display:none !important; }
#monsterSheetTokenMenuBtn:not(.player-hidden) {
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  width:auto !important;
  min-width:86px !important;
  padding:5px 8px !important;
  font-size:10px !important;
  white-space:nowrap;
}


/* Libraries 16: explanation / rules dictionary always opens above Character/Monster sheets. */
#rulesReferenceOverlay {
  z-index: 2147483400 !important;
}
.ms-text-entry-top {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}
.ms-text-entry-use {
  flex:0 0 auto;
  min-width:52px !important;
  min-height:34px !important;
  padding:5px 9px !important;
  font-size:10px !important;
  font-weight:900 !important;
}
.ms-text-entry-use.monster-recharge-waiting {
  opacity:.78;
}

/* Libraries 24: live Monster Sheet conditions / Exhaustion */
.ms-condition-grid{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;
}
.ms-condition-btn{
  min-height:36px!important;padding:5px 7px!important;border-radius:8px!important;
  font-size:10px!important;font-weight:800!important;text-align:left!important;
  background:rgba(15,23,42,.78)!important;border:1px solid rgba(148,163,184,.28)!important;
}
.ms-condition-btn.active{
  background:rgba(127,29,29,.78)!important;border-color:rgba(248,113,113,.72)!important;
  color:#fff!important;
}
.ms-condition-btn:disabled{opacity:.46!important}
#msExhaustionSelect{
  max-width:145px;min-height:32px;padding:4px 6px;font-size:10px;border-radius:7px;
}
.ms-condition-note{font-size:9px;color:#94a3b8;margin-top:6px;line-height:1.35}
@media(max-width:430px){.ms-condition-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}

/* SECOND CHAT 1 — Out-of-Character chat */
#oocChatDrawer{position:fixed;top:0;right:-100%;width:min(520px,100vw);height:100vh;z-index:2147483300;background:rgba(2,6,23,.98);border-left:1px solid rgba(56,189,248,.35);display:flex;flex-direction:column;transition:right .2s ease;box-shadow:-18px 0 50px rgba(0,0,0,.55)}
#oocChatDrawer.open{right:0}
#oocChatDrawer .chat-header{flex:0 0 auto;min-height:58px;padding:9px 10px;font-size:15px}
#oocChatMessages{flex:1 1 auto;overflow-y:auto;padding:9px;display:flex;flex-direction:column;gap:7px;touch-action:pan-y}
#oocChatDrawer .chat-input-area{flex:0 0 auto;padding:9px}
#oocChatDrawer .chat-input-row{display:flex;gap:7px;align-items:center}
#oocChatDrawer .chat-input-row input[type="text"]{flex:1 1 auto;min-width:0}
#oocChatDrawer .chat-msg{font-size:14px;padding:9px;background:rgba(2,6,23,.92);border:1px solid rgba(59,130,246,.26);border-radius:12px}
#oocChatDrawer .chat-msg.dm{border-color:rgba(245,158,11,.34)}
#oocChatDrawer .chat-msg-header{display:flex;align-items:center;gap:7px}
#oocChatDrawer .chat-msg-author.dm{color:#f59e0b!important}
#oocChatDrawer .chat-msg-text{font-size:15px;line-height:1.34;margin-top:5px}
#oocChatDrawer .chat-msg-img{max-width:100%;border-radius:10px;margin-top:7px}
#oocChatBadge{display:none;margin-left:3px;min-width:17px;height:17px;padding:0 4px;border-radius:999px;background:#ef4444;color:#fff;font-size:9px;font-weight:900;line-height:17px;text-align:center}
@media(max-width:600px){#oocChatDrawer{width:80vw!important}}

/* SECOND CHAT 2 — chat-room switching + DM access moved into Menu */
.chat-header-actions{
  display:flex;
  align-items:center;
  gap:6px;
  margin-left:auto;
}
.chat-room-switch{
  min-width:58px !important;
  min-height:34px !important;
  height:34px !important;
  padding:4px 8px !important;
  font-size:10px !important;
  white-space:nowrap;
}
#chatDrawer .chat-header > span,
#oocChatDrawer .chat-header > span{
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#accessMenuSection #dmAuthBtn{
  width:100%;
  justify-content:flex-start;
}

/* SHADOWS 1 — fixed cover colors + wall-projected cover shadows */
#wallModeWall{
  border-color:#22d3ee !important;
  color:#67e8f9 !important;
  box-shadow:inset 0 0 0 1px rgba(34,211,238,.18);
}
#wallModeLowWall{
  border-color:#a78bfa !important;
  color:#c4b5fd !important;
  box-shadow:inset 0 0 0 1px rgba(167,139,250,.18);
}
#wallModeThreeQuarter{
  border-color:#f43f5e !important;
  color:#fda4af !important;
  box-shadow:inset 0 0 0 1px rgba(244,63,94,.18);
}
#wallModeWall.active{background:rgba(34,211,238,.24) !important;}
#wallModeLowWall.active{background:rgba(167,139,250,.24) !important;}
#wallModeThreeQuarter.active{background:rgba(244,63,94,.24) !important;}
.wall-cover-key{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
  padding:0 4px;
}
.wall-cover-key-item{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  min-width:0;
  padding:5px 4px;
  border:1px solid rgba(148,163,184,.18);
  border-radius:7px;
  background:rgba(15,23,42,.46);
  font-size:9px;
  font-weight:800;
  white-space:nowrap;
}
.wall-cover-key-swatch{
  width:10px;
  height:10px;
  flex:0 0 10px;
  border-radius:3px;
  box-shadow:0 0 5px currentColor;
}
.wall-shadow-note{
  padding:0 4px;
  color:#94a3b8;
  font-size:9px;
  line-height:1.35;
}

/* PROPS 1 — scenery layer between maps and tokens */
#panelProps{width:min(340px,calc(100vw - 16px));}
#panelProps .toolbar-row{gap:6px;flex-wrap:wrap;}
#panelProps button,#panelProps .btn{font-size:10px;min-height:30px;}

/* PING 1 — synchronized one-tap map ping */
#mapPingMenuBtn.ping-armed{
  border-color:#22d3ee !important;
  background:rgba(34,211,238,.18) !important;
  color:#a5f3fc !important;
  box-shadow:inset 0 0 0 1px rgba(34,211,238,.22);
}

/* CHAT FIX 1 — keep OOC composer visible on mobile browser viewports */
#oocChatDrawer{
  top:0 !important;
  right:0 !important;
  bottom:0 !important;
  left:auto !important;
  width:min(560px,80vw) !important;
  height:100dvh !important;
  max-height:100dvh !important;
  min-height:0 !important;
  overflow:hidden !important;
  transform:translate3d(105%,0,0);
  transition:transform .22s cubic-bezier(.16,1,.3,1) !important;
}
#oocChatDrawer.open{
  right:0 !important;
  transform:translate3d(0,0,0);
}
#oocChatDrawer .chat-header{
  flex:0 0 auto !important;
}
#oocChatMessages{
  flex:1 1 0 !important;
  min-height:0 !important;
  overflow-y:auto !important;
  overscroll-behavior:contain;
}
#oocChatDrawer .chat-input-area{
  display:flex !important;
  flex:0 0 auto !important;
  width:100% !important;
  padding:10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
  background:rgba(3,8,28,.99) !important;
  border-top:1px solid rgba(96,165,250,.18) !important;
  visibility:visible !important;
}
#oocChatDrawer .chat-input-row{
  display:flex !important;
  width:100% !important;
  gap:7px !important;
  align-items:center !important;
}
#oocChatTextInput{
  display:block !important;
  flex:1 1 auto !important;
  min-width:0 !important;
  min-height:44px !important;
  padding:10px 12px !important;
  border-radius:10px !important;
  font-size:13px !important;
  background:rgba(15,23,42,.94) !important;
  color:#f8fafc !important;
  user-select:text !important;
}
#oocChatDrawer .chat-input-row > label.btn,
#oocChatDrawer .chat-input-row > button{
  display:inline-flex !important;
  flex:0 0 auto !important;
  min-height:44px !important;
  align-items:center !important;
  justify-content:center !important;
  border-radius:10px !important;
  font-size:12px !important;
}
@media(max-width:430px){
  #oocChatDrawer{width:80vw !important;}
}

/* Monster 13: csSpellbook is backing storage opened through the Spellbook button; do not render it inline. */
#panelCharacterSheet #csSpellbook { display:none !important; }

/* MONSTER 106: Token control belongs with general character controls, not page navigation. */
#panelCharacterSheet .cs-page-switcher {
  grid-template-columns:42px minmax(0,1fr) 42px !important;
}
#panelCharacterSheet #csAutomationControl {
  align-items:center !important;
}
#panelCharacterSheet #characterSheetTokenMenuBtn.cs-page-token-btn {
  flex:0 0 42px !important;
  width:42px !important;
  min-width:42px !important;
  max-width:42px !important;
  height:34px !important;
  min-height:34px !important;
  padding:0 !important;
  margin-left:auto !important;
  border-radius:8px !important;
  font-size:15px !important;
  line-height:1 !important;
}


/* Monster 116: conditions are an entry point to the existing shared token-condition authority.
   HP controls belong to the persistent character play header, not a second floating modal. */
#characterSheetForm [data-cs-page="abilities"] .cs-roll-mode,
#characterSheetForm [data-cs-page="skills"] .cs-roll-mode,
#characterSheetForm [data-cs-page="spells"] .cs-roll-mode {
  grid-template-columns:repeat(4,minmax(0,1fr)) !important;
}
#characterSheetForm [data-cs-page="attacks"] .cs-roll-mode.cs-attack-roll-mode {
  grid-template-columns:repeat(5,minmax(0,1fr)) !important;
}
#characterSheetForm .cs-conditions-access-btn {
  min-width:0 !important;
  padding-left:3px !important;
  padding-right:3px !important;
  font-size:9px !important;
}
#csPlayHeader #csPlayHpPopup {
  position:static !important;
  inset:auto !important;
  z-index:auto !important;
  width:100% !important;
  margin:6px 0 0 !important;
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  background:transparent !important;
  display:block;
  align-items:initial !important;
  justify-content:initial !important;
  touch-action:manipulation !important;
}
#csPlayHeader #csPlayHpPopup.hidden { display:none !important; }
#csPlayHeader #csPlayHpPopup::before { display:none !important; }
#csPlayHeader #csPlayHpPopup .cs-play-hp-modal-card {
  width:100% !important;
  padding:8px !important;
  border-radius:8px !important;
  box-shadow:none !important;
}

/* CHARACTER DESIGN 43 — compact skill training marker */
#characterSheetForm [data-cs-page="skills"] .cs-roll-row.cs-skill-row {
  grid-template-columns:minmax(0,1fr) 30px 46px auto !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-prof-select {
  display:none !important;
}
#characterSheetForm [data-cs-page="skills"] .cs-skill-training-marker {
  width:30px !important; min-width:30px !important; height:27px !important; min-height:27px !important;
  padding:0 !important; border:1px solid #334155; border-radius:7px;
  background:#172033; color:#94a3b8; font-size:11px; font-weight:800; line-height:25px; text-align:center;
}
#characterSheetForm [data-cs-page="skills"] .cs-skill-training-marker[data-state="prof"] { color:#dbeafe; border-color:#2563eb; }
#characterSheetForm [data-cs-page="skills"] .cs-skill-training-marker[data-state="expert"] { color:#fef3c7; border-color:#d97706; }

/* CHARACTER DESIGN 46: full inventory editor follows DragonTop dark theme. */
#csFullInventoryModal textarea,
#csFullInventoryModal .cs-text-editor,
#csFullInventoryModal input,
#csFullInventoryModal select{
  background:#0f172a !important;
  color:#f8fafc !important;
  border-color:#334155 !important;
  color-scheme:dark;
  caret-color:#f8fafc;
}
#csFullInventoryModal textarea::placeholder,
#csFullInventoryModal input::placeholder{color:#94a3b8;}


#csFullInventoryEditor,
.cs-full-inventory-editor,
.cs-full-inventory-modal textarea{
  background:#0f172a !important;
  color:#f8fafc !important;
  border-color:#334155 !important;
  color-scheme:dark;
  caret-color:#f8fafc;
}


/* CHARACTER DESIGN 47: dark full-screen text editor, including Full Inventory. */
.cs-text-modal{
  background:#0b1220 !important;
  color:#f8fafc !important;
  border-color:#334155 !important;
}
.cs-text-modal textarea,
#csTextEditorArea{
  background:#0f172a !important;
  color:#f8fafc !important;
  border:1px solid #334155 !important;
  caret-color:#f8fafc !important;
  color-scheme:dark !important;
}
.cs-text-modal textarea::placeholder,
#csTextEditorArea::placeholder{
  color:#94a3b8 !important;
}
.cs-text-modal h2,
.cs-text-modal .cs-text-editor-title{
  color:#f8fafc !important;
}


  /* Character Design 73 — Lucky mobile button layout.
     Keep long Lucky action labels inside their card on narrow screens. */
  #csLuckyCard button,
  .cs-lucky-card button,
  [data-feature="lucky"] button {
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.2;
    min-height: 52px;
    height: auto !important;
    padding: 8px 10px;
    text-align: center;
  }

  #csLuckyAdvantageBtn,
  #csLuckyIncomingDisadvantageBtn {
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.2;
    min-height: 52px;
    height: auto !important;
    padding: 8px 10px;
    text-align: center;
  }


/* CHARACTER DESIGN 94 — GLOBAL LONG-PAGE NAVIGATION */
.panel-back-row{
  position:sticky !important;
  top:0 !important;
  z-index:2147482000 !important;
  background:linear-gradient(180deg,rgba(9,13,22,.99) 0%,rgba(9,13,22,.94) 82%,rgba(9,13,22,0) 100%);
  padding-top:2px;
  padding-bottom:5px;
}
.panel-top-btn{
  position:sticky;
  float:right;
  bottom:8px;
  z-index:2147481900;
  display:none;
  min-width:42px;
  height:38px;
  margin:8px 2px 2px 8px;
  padding:0 9px;
  border-radius:10px;
  font-size:11px;
  font-weight:900;
  background:rgba(30,41,59,.97);
  border:1px solid rgba(96,165,250,.5);
  color:#dbeafe;
  touch-action:manipulation;
}
.tool-panel.vtt-panel-scrolled > .panel-top-btn{display:inline-flex;align-items:center;justify-content:center;}
#monsterLibraryAlphabetBar{
  position:sticky;
  top:41px;
  z-index:2147481800;
  float:right;
  width:26px;
  max-height:calc(75vh - 58px);
  overflow-y:auto;
  margin:0 0 6px 6px;
  padding:2px;
  border:1px solid rgba(96,165,250,.35);
  border-radius:9px;
  background:rgba(9,13,22,.96);
  -webkit-overflow-scrolling:touch;
}
#monsterLibraryAlphabetBar button{
  width:20px;
  min-width:20px;
  height:19px;
  min-height:19px;
  margin:0 0 1px 0;
  padding:0;
  border-radius:5px;
  font-size:9px;
  font-weight:900;
  line-height:19px;
  color:#dbeafe;
  background:rgba(30,41,59,.92);
  border:1px solid rgba(96,165,250,.22);
}
#monsterLibraryAlphabetBar button:disabled{opacity:.22;}
#monsterEncounterBuilder { margin:5px 32px 7px 0; padding:8px; border:1px solid #36455b; border-radius:8px; background:#101a2b; color:#e2e8f0; }
#monsterEncounterBuilder summary { cursor:pointer; font-size:12px; font-weight:800; padding:4px 0; }
#monsterEncounterBuilder label { display:grid; gap:4px; min-width:0; font-size:12px; }
#monsterEncounterBuilder input, #monsterEncounterBuilder select { width:100%; min-width:0; box-sizing:border-box; }
.encounter-settings { display:grid; grid-template-columns:1fr 1fr 1.4fr; gap:6px; margin:8px 0; }
#encounterBalance { margin:8px 0; line-height:1.5; font-weight:700; }
#encounterBalance[data-over="true"], #encounterNumbers { color:#fcd34d; }
.encounter-add, .encounter-group { display:flex; flex-wrap:wrap; align-items:end; gap:6px; margin:8px 0; }
.encounter-group { align-items:center; }
.encounter-group strong { flex:1; }
#monsterEncounterBuilder small { display:block; color:#b9c6d6; }
#monsterHabitatDetails { margin:5px 32px 7px 0; padding:6px; border:1px solid rgba(148,163,184,.28); border-radius:8px; background:rgba(15,23,42,.55); }
#monsterHabitatDetails summary { cursor:pointer; font-size:12px; font-weight:800; color:#e2e8f0; padding:4px 0; }
#monsterHabitatDetails label { display:flex; align-items:center; gap:8px; margin:6px 0; }
#monsterHabitatSelect { flex:1; min-width:0; }
#monsterHabitatResults { max-height:38vh; overflow:auto; }
#monsterHabitatResults section { margin:6px 0 12px; }
#monsterHabitatResults h4 { margin:0 0 4px; }
#monsterHabitatResults .habitat-creatures { display:flex; flex-wrap:wrap; gap:4px; }
#monsterHabitatResults button, #monsterHabitatResults .missing-sheet { max-width:100%; white-space:normal; text-align:left; font-size:12px; padding:6px 8px; }
#monsterHabitatResults button small { display:block; color:#bfdbfe; font-size:10px; }
#monsterHabitatResults .missing-sheet { color:#cbd5e1; }
#panelMonsterLibrary #monsterLibraryList{padding-right:31px;}
@media(max-width:600px){
  .panel-back-btn{min-width:62px;height:42px;}
  #monsterLibraryAlphabetBar{width:25px;}
}

/* CHARACTER DESIGN 95 — MONSTER LIBRARY MOBILE NAVIGATION FIX
   A-Z is a narrow fixed rail on the right. Back-to-top is a small arrow only,
   fixed at the lower-right instead of spanning the page. */
#panelMonsterLibrary #monsterLibraryAlphabetBar{
  position:fixed !important;
  right:20px !important;
  top:150px !important;
  bottom:96px !important;
  width:24px !important;
  max-height:none !important;
  float:none !important;
  margin:0 !important;
  padding:2px !important;
  z-index:2147483000 !important;
  overflow-y:auto !important;
  border-radius:10px !important;
  background:rgba(9,13,22,.96) !important;
}
#panelMonsterLibrary #monsterLibraryAlphabetBar button{
  width:18px !important;
  min-width:18px !important;
  height:18px !important;
  min-height:18px !important;
  line-height:18px !important;
  font-size:9px !important;
  margin:0 0 1px 0 !important;
  padding:0 !important;
}
.tool-panel > .panel-top-btn{
  position:fixed !important;
  right:22px !important;
  bottom:82px !important;
  float:none !important;
  width:42px !important;
  min-width:42px !important;
  height:42px !important;
  min-height:42px !important;
  margin:0 !important;
  padding:0 !important;
  border-radius:50% !important;
  font-size:0 !important;
  z-index:2147483100 !important;
}
.tool-panel > .panel-top-btn::before{
  content:'↑';
  font-size:26px;
  line-height:1;
  font-weight:900;
}
#panelMonsterLibrary #monsterLibraryList{padding-right:34px !important;}

/* CHARACTER DESIGN 96 — FIXED A-Z RAIL + SEPARATE TOP ARROW */
#panelMonsterLibrary #monsterLibraryAlphabetBar{
  position:fixed !important;
  right:20px !important;
  top:205px !important;
  bottom:auto !important;
  width:24px !important;
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
  overscroll-behavior:none !important;
  float:none !important;
  margin:0 !important;
  padding:2px !important;
  z-index:2147483000 !important;
}
#panelMonsterLibrary #monsterLibraryAlphabetBar button{
  display:block !important;
  width:18px !important;
  min-width:18px !important;
  height:16px !important;
  min-height:16px !important;
  line-height:16px !important;
  font-size:8px !important;
  margin:0 0 1px 0 !important;
  padding:0 !important;
}
/* Separate the top control from the alphabet rail completely. */
#panelMonsterLibrary > .panel-top-btn{
  position:fixed !important;
  left:50% !important;
  right:auto !important;
  bottom:88px !important;
  transform:translateX(-50%) !important;
  width:42px !important;
  min-width:42px !important;
  height:42px !important;
  min-height:42px !important;
  border-radius:50% !important;
  margin:0 !important;
  padding:0 !important;
  z-index:2147483100 !important;
}

/* CHARACTER DESIGN 97 — TRUE VIEWPORT-FIXED MONSTER NAV
   Controls are moved to document.body so transformed/contained panels cannot make
   position:fixed behave like scrolling panel content. */
body > #monsterLibraryAlphabetBar{
  position:fixed !important;
  right:20px !important;
  top:205px !important;
  bottom:auto !important;
  width:24px !important;
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
  margin:0 !important;
  padding:2px !important;
  z-index:2147483000 !important;
  border:1px solid rgba(96,165,250,.35) !important;
  border-radius:10px !important;
  background:rgba(9,13,22,.96) !important;
}
body > #monsterLibraryAlphabetBar button{
  display:block !important;
  width:18px !important;
  min-width:18px !important;
  height:16px !important;
  min-height:16px !important;
  line-height:16px !important;
  font-size:8px !important;
  margin:0 0 1px 0 !important;
  padding:0 !important;
}
body > #monsterLibraryViewportTop97{
  position:fixed !important;
  left:50% !important;
  right:auto !important;
  bottom:88px !important;
  transform:translateX(-50%) !important;
  display:none;
  align-items:center;
  justify-content:center;
  width:42px !important;
  min-width:42px !important;
  height:42px !important;
  min-height:42px !important;
  margin:0 !important;
  padding:0 !important;
  border-radius:50% !important;
  font-size:0 !important;
  z-index:2147483100 !important;
}
body > #monsterLibraryViewportTop97::before{
  content:'↑';
  font-size:26px;
  line-height:1;
  font-weight:900;
}

/* CHARACTER DESIGN 145 — dedicated runtime equipment slots; no AC authority yet. */
.cs-equipped-loadout{display:grid;grid-template-columns:1fr;gap:6px;margin:6px 0 8px;}
.cs-equipped-loadout label{display:grid;grid-template-columns:82px 1fr;gap:8px;align-items:center;font-size:12px;font-weight:700;}
.cs-equipped-loadout select{width:100%;min-width:0;}
/* Retire per-row equipment controls visually; inventory rows remain item/qty/weight only. */
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-header span:nth-child(n+4),
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-row > :nth-child(n+4){display:none!important;}
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-header,
#characterSheetForm [data-cs-page="inventory"] .cs-inventory-row{grid-template-columns:minmax(0,1fr) 52px 58px!important;}

body.move-fog-only #panelTokens .move-fog-link-row{
  display:grid !important;
  grid-template-columns:1fr 1fr !important;
  gap:10px !important;
  align-items:stretch !important;
}
body.move-fog-only #panelTokens .move-fog-link-row #linkBtn,
body.move-fog-only #panelTokens .move-fog-link-row #unlinkBtn{
  display:block !important;
  width:100% !important;
  min-width:0 !important;
  position:static !important;
  margin:0 !important;
}

/* CHARACTER DESIGN 184 — DOMAIN SPELLS TOUCH WINDOW */
.cs-domain-spells-link184 { width:100%; min-height:42px; margin-top:8px; padding:8px 12px; display:flex; align-items:center; justify-content:space-between; border:1px solid rgba(96,165,250,.38); border-radius:8px; background:#111a2d; color:#dbeafe; font-size:12px; font-weight:900; text-align:left; }
.cs-domain-spells-link184 span:last-child { font-size:22px; line-height:1; color:#93c5fd; }
.cs-domain-spells-modal184[hidden] { display:none !important; }
.cs-domain-spells-modal184 { position:fixed; inset:0; z-index:2147482000; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(2,6,23,.78); }
.cs-domain-spells-dialog184 { width:min(92vw,430px); max-height:78vh; overflow:auto; padding:14px; border:1px solid rgba(96,165,250,.42); border-radius:12px; background:#0f172a; box-shadow:0 18px 50px rgba(0,0,0,.55); }
.cs-domain-spells-head184 { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.cs-domain-spells-title184 { font-size:16px; font-weight:900; color:#f8fafc; }
.cs-domain-spells-sub184 { margin-top:2px; font-size:11px; font-weight:800; color:#93c5fd; }
.cs-domain-spells-list184 { margin-top:12px; display:grid; gap:8px; }
.cs-domain-spells-list184 > div { display:grid; grid-template-columns:38px 1fr; gap:8px; padding:7px 0; border-bottom:1px solid rgba(148,163,184,.12); font-size:12px; line-height:1.35; }
.cs-domain-spells-list184 b { color:#93c5fd; }
.cs-domain-spells-list184 span { color:#e2e8f0; }

/* CHARACTER DESIGN 183 — COMPLETE LEVEL 9 TRICKERY PAGE 10 LAYOUT */
.cs-subclass-action-row183 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin-top:7px; }
.cs-subclass-action183 { margin-top:7px; min-height:34px; border:1px solid rgba(96,165,250,.38); border-radius:7px; background:#172033; color:#dbeafe; font-size:11px; font-weight:800; }
.cs-subclass-action-row183 .cs-subclass-action183 { margin-top:0; }
.cs-subclass-action183:disabled { opacity:.72; }
.cs-domain-spells183 { margin-top:6px; display:grid; gap:4px; }
.cs-domain-spells183 > div { display:grid; grid-template-columns:32px 1fr; gap:6px; font-size:10px; line-height:1.3; }
.cs-domain-spells183 b { color:#93c5fd; }
.cs-domain-spells183 span { color:#cbd5e1; }

/* CHARACTER DESIGN 182 — TRICKERY DOMAIN: BLESSING OF THE TRICKSTER REFERENCE */
.cs-subclass-feature182 { margin-top:4px; padding:8px; border:1px solid rgba(148,163,184,.18); border-radius:7px; }
.cs-subclass-feature182-title { font-size:12px; font-weight:900; }
.cs-subclass-feature182-meta { margin-top:3px; font-size:10px; font-weight:700; color:#93c5fd; }
.cs-subclass-feature182-text { margin-top:5px; font-size:10px; line-height:1.35; color:#cbd5e1; }

/* CHARACTER DESIGN 181 — UNIVERSAL PAGE 10 SUBCLASS FRAMEWORK */
#characterSheetForm [data-cs-page="subclass"] .cs-subclass-page181 {
  padding:8px;
  border:1px solid rgba(96,165,250,.22);
  border-radius:8px;
  background:rgba(15,23,42,.34);
}
#characterSheetForm [data-cs-page="subclass"] .cs-subclass-page181-name {
  font-size:13px;
  font-weight:900;
  margin-bottom:6px;
}
#characterSheetForm [data-cs-page="subclass"] .cs-subclass-page181-note {
  font-size:10px;
  line-height:1.3;
  color:#94a3b8;
}

/* SHEETS 809: the DM's X on an initiative row. */
.initiative-order-row:has(.initiative-remove-x809){grid-template-columns:13px minmax(0,1fr) auto 22px}
.initiative-remove-x809{min-width:22px;height:20px;padding:0;border:1px solid rgba(248,113,113,.55);border-radius:6px;background:rgba(127,29,29,.45);color:#fecaca;font-size:14px;line-height:1;font-weight:900;cursor:pointer}
