:root{
  --bg:#0f1115;
  --card:#151a22;
  --border:#2a3242;
  --text:#e9eef8;
  --muted:#93a4c7;
  --accent:#7ef0d6;
  --topbar-h: 55px;
  --scrollbar-thumb: #2a3242;
  --scrollbar-track: #0b0f18;

}

*{
  box-sizing:border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Scrollbar theming (Chromium/Safari) */
*::-webkit-scrollbar{ width: 10px; height: 10px; }
*::-webkit-scrollbar-track{ background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb{
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid var(--scrollbar-track);
}
*::-webkit-scrollbar-thumb:hover{ background: #3a4761; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:var(--bg);
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 14px;
  border-bottom:1px solid var(--border);
  background:#0c0f14;
}

.topbarLeft{
  display:flex;
  align-items:center;
  gap:10px;
}

.iconBtn{
  display:none;             /* shown on small screens */
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
}


.brand{font-weight:700; letter-spacing:.2px;}
.sessionline{display:flex; gap:8px; align-items:center;}

button{
  background:var(--card);
  border:1px solid var(--border);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
}
button:disabled{opacity:.45; cursor:not-allowed;}
button:hover{border-color:#3a4761;}

.badge{
  display:inline-flex;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--accent);
  background:#111722;
}

.layout{
  display:grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap:10px;
  padding:10px;
  height: calc(100dvh - var(--topbar-h));
  min-height: 0;
}

.col{
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height: 0;
}

/* Make side columns scrollable containers */
.col.left,
.col.right{
  overflow:auto;
  padding-right: 2px; /* prevents scrollbar overlap clipping */
}

/* Middle column: tabletop grows, notes stays fixed */

.col.middle{
  display:flex;
  flex-direction:column;
  height: 100%;
  min-height: 0;
  overflow:hidden; /* prevents middle from becoming a mega-scroll */
}

.panel{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}
.panel h2{
  margin:0;
  padding:10px 12px;
  font-size:14px;
  border-bottom:1px solid var(--border);
  color:#cfe0ff;
}
.panelBody{padding:12px;}
.panelRow{display:flex; gap:8px; padding:0 12px 12px 12px;}

.muted{color:var(--muted);}
.small{font-size:12px;}

#mediaPanel .panelBody{
  max-height: 220px;
  overflow:auto;
  padding-right: 6px;
}

.tabletopBox{
/*  height: 100%;
  min-height: 220px;*/
  flex: 1 1 auto;
  min-height: 0;                  /* critical */
  overflow: auto;                 /* key line */
  height: auto;                   /* undo height:100% behavior */
  display:flex;
  align-items:center;
  justify-content:center;
  padding:14px;
}

#tabletop img, #tabletop video, #tabletop iframe{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}


.diceRow{display:flex; flex-wrap:wrap; gap:8px;}
.dice{min-width:48px; border-radius:12px;}

.chatLog{
  height: auto;      /* override existing calc */
  flex: 1 1 auto;
  min-height: 0;
  padding:12px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.chatMsg{
  border:1px solid var(--border);
  background:#111722;
  padding:8px 10px;
  border-radius:12px;
}
.chatMeta{font-size:12px; color:var(--muted); margin-bottom:4px;}
.chatInput{
  border-top:1px solid var(--border);
  padding:10px;
  display:flex;
  gap:8px;
}
.chatInput input{
  flex:1;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#0c1018;
  color:var(--text);
}

@media (max-width: 980px){
  .iconBtn{ display:inline-flex; align-items:center; justify-content:center; }

  /* Single main column on mobile */
  .layout{
    grid-template-columns: 1fr;
    gap:10px;
  }

  /* Turn left/right into off-canvas drawers */
  .col.left,
  .col.right{
    position: fixed;
    top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h));
    width: min(360px, 92vw);
    z-index: 9998;
    background: var(--bg);
    padding: 10px;
    border-right: 1px solid var(--border);
    transform: translateX(-110%);
    transition: transform .18s ease;
    box-shadow: 0 0 0 1px rgba(0,0,0,.2);
  }

  .col.right{
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid var(--border);
    transform: translateX(110%);
  }

  body.drawerLeftOpen .col.left{ transform: translateX(0); }
  body.drawerRightOpen .col.right{ transform: translateX(0); }

  .drawerOverlay{
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,.55);
    z-index: 9997;
  }
  body.drawerLeftOpen .drawerOverlay,
  body.drawerRightOpen .drawerOverlay{
    display:block;
  }
}


.panel.tabletop{
  flex: 1 1 auto;
  min-height: 0;                  /* critical */
  display: flex;
  flex-direction: column;
}

.panel.notes{
  flex: 0 0 160px; /* fixed notes height */
}

/* Chat: Flex and Min-Height */
.panel.chat{
  display:flex;
  flex-direction:column;
  min-height: 75vh;
}



#notesText{
  width:100%;
  height: 72px; /* textarea + status line */
  resize:none;
  border-radius:12px;
  border:1px solid var(--border);
  background:#0c1018;
  color:var(--text);
  padding:10px 12px;
  outline:none;
}
#notesText:focus{border-color:#3a4761;}

/*GM TEXT SECTION*/

.gmText{white-space:pre-wrap; line-height:1.35;}
.gmChoices{
  margin-top:10px;
  padding:10px 12px;
  border:1px solid #2a3242;
  border-radius:12px;
  background:#0c1018;
}
.gmChoicesTitle{
  font-weight:700;
  color: var(--accent);
  margin-bottom:6px;
}
.gmChoices ul{
  margin:0;
  padding-left:18px;
  color:#b7ffe9; /* a lighter accent-ish */
}
.gmChoices li{margin:4px 0;}


/*MEDIA SECTION*/

#mediaGallery{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:8px;
}

.mediaThumb{
  border:1px solid #2a3242;
  border-radius:10px;
  overflow:hidden;
  cursor:pointer;
  background:#0c1018;
  height:64px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.mediaThumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.modal.hidden{display:none;}
.modal{
  position:fixed; inset:0;
  z-index:9999;
}
.modalBackdrop{
  position:absolute; inset:0;
  background:rgba(0,0,0,.65);
}
.modalCard{
  position:absolute;
  top:50%; left:50%;
  transform:translate(-50%,-50%);
  width:min(720px, 92vw);
  max-height:88vh;
  overflow:auto;
  border:1px solid #2a3242;
  border-radius:16px;
  background:#0b0f18;
  padding:12px;
}

.modalCard.sheetCard{
  width: min(980px, 92vw);
}

.hidden{ display:none; }

.modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 4px 10px 4px;
  border-bottom:1px solid #1b2231;
}
.modalBody{ padding-top:12px; }
.modalBody img{
  width:100%;
  height:auto;
  border-radius:12px;
  border:1px solid #2a3242;
}



#playerInventory{
  font-size: 12px;
}
#playerInventory ul{
  max-height: 160px;
  overflow:auto;
  padding-right: 6px;
}
#playerInventory li { line-height: 1.25; }


/* Player Sheet specific */
.sheetSummary{
  border: 1px solid var(--border);
  background: #111722;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.sheetSummary .row{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}

.sheetSummary .pill{
  display:inline-flex;
  gap: 6px;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0c1018;
  color: var(--text);
  font-size: 12px;
}

.sheetTabs{
  display:flex;
  gap: 8px;
  margin-bottom: 10px;
}

.sheetTabBtn{
  background: #0c1018;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.sheetTabBtn.active{
  border-color: #3a4761;
  color: var(--accent);
}

.btn{
  background:var(--card);
  border:1px solid var(--border);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
}
.btn:hover{border-color:#3a4761;}


.sheetTabPanel{
  border: 1px solid var(--border);
  background: #111722;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 220px;
}

.sheetGrid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 820px){
  .sheetGrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .sheetGrid{ grid-template-columns: 1fr; }
}

.statCard{
  border: 1px solid var(--border);
  background: #0c1018;
  border-radius: 12px;
  padding: 10px;
}
.statCard .k{ color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.statCard .v{ font-size: 18px; font-weight: 800; letter-spacing: .2px; }

.sheetPre{
  margin:0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text);
}
