/* ===== Reset ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Theme Variables ===== */
body {
  --bg: #0e0e0e;
  --surface: #1c1c1c;
  --surface-2: #252525;
  --text: #e8f0eb;
  --muted: #727573;
  --danger: #d40606;
  --accent: #7ee787;
  /* light green */
  --border: rgba(255, 255, 255, 0.06);
  --image: #00000055;
  --bar: #2a2a2a;
  --bar-border: #282828;
  --bar-text: #fff;
  --health: #ff3b3b;
  --stamina: #21b300;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

body.light {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f3f3f3;
  --text: #242424;
  --muted: #b1b1b1;
  --danger: #f42727;
  --accent: #34c759;
  /* soft modern green */
  --border: rgba(0, 0, 0, 0.06);
  --image: #00000000;
  --bar: #f6f6f6;
  --bar-border: #f6f6f6;
  --bar-text: #000000;
  --health: #ff5656;
  --stamina: #61cd49;
}

/* ===== Base Layout ===== */
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 40px 20px;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Center container */
body>* {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Top Controls Box ===== */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

#dashboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

table {
  background: var(--surface);
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.char-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 7px;
  border-radius: 10px;
  padding: 3px;
  color: var(--accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.stats-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 2px;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  /* centers everything horizontally */
  position: relative;
}

.stats-box h1 {
  margin-bottom: 5px;
  margin-top: 5px;
}

.stats-box p {
  text-align: center;
  width: 100%;
}

.stats-con {
  margin: 10px;
  margin-left: 0px;
}

.muted {
  color: var(--accent);
  font-size: 15px;
  position: absolute;
  justify-self: left;
  margin-top: -7px;
}

/* Wrap your buttons in a div with id="controls" */

h1 {
  font-size: 20px;
  font-weight: 600;
  padding-top: 3px;
}

/* ===== Buttons ===== */
button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #7ee78735;
}

/* ===== Dashboard Grid ===== */
#dashboard {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ===== Popup Modal ===== */
#popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  width: 340px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

/* Dim background */
body.modal-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  z-index: 999;
}

/* ===== Inputs ===== */
input[type=text],
select {
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: all 0.2s ease;
}

select {
  cursor: s-resize;
}

input[type=text]:hover,
select:hover {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.15);
}

.hidden {
  display: none;
}

.confirmText {
  margin: 12px;
  margin-left: 3px;
}

.confirmBtn,
.cancelBtn {
  margin-right: 4px;
  margin-bottom: 10px;
}

#closePopup:hover,
.deleteBtn:hover,
.confirmBtn:hover {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px #f4272735;
}

#image-main {
  width: 30px;
  height: 30px;
  margin-right: 10px;
  border-radius: 100%;
  box-shadow: 0 0 0 3px var(--image);
}

.highlight {
  background: var(--accent);
  color: var(--bg);
  cursor: pointer !important;
}

select {
  cursor: s-resize;
}

#table {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px !important;
  cursor: default;
}

.controls .right {
  display: flex;
  align-items: center;
  /* vertically centers items */
  gap: 10px;
  /* optional, adds space between checkbox and buttons */
}

.health-bar {
  width: 100%;
  height: 20px;
  background: var(--bar);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px 0;
  border: 1px solid var(--bar-border);
}

.health-fill {
  height: 100%;
  background: var(--health);
  width: 100%;
  transition: width 0.25s ease;
}

.health-text {
  margin-top: -21px;
  display: block;
  font-size: 11px;
  color: var(--bar-text);
  margin-bottom: 8px;
}

.stamina-bar {
  width: 100%;
  height: 20px;
  background: var(--bar);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px 0;
  border: 1px solid var(--bar-border);
}

.stamina-fill {
  height: 100%;
  background: var(--stamina);
  width: 100%;
  transition: width 0.25s ease;
}

.stamina-text {
  margin-top: -21px;
  display: block;
  font-size: 11px;
  color: var(--bar-text);
  margin-bottom: 15px;
}


.modal-content {
  transition: 0.2s ease;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  width: 400px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.modal-content h2 {
  margin-top: 20px;
}

#dash-save-output,
#dash-load-input {
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  margin-bottom: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: all 0.2s ease;
}

#close-dash-save {
  margin-left: 100%;
  cursor: pointer;
}

#switch-to-load {
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

#switch-to-load:hover {
  color: var(--accent);
}

#switch-to-save {
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

#switch-to-save:hover {
  color: var(--accent);
}


/* ===== Modal Base ===== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  z-index: 1000;
}


/* ===== Modal Card ===== */
#dash-save-modal .modal-content {
  position: relative;
  width: 420px;
  max-width: calc(100vw - 40px);
  overflow: auto;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;

  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: modalPop 0.18s ease;
}

/* fix centering conflict */
#dash-save-modal .modal-content {
  position: relative;
  /* overrides the old fixed rule */
  top: auto;
  left: auto;
  transform: none;
  margin: 0;
}

/* subtle entrance */
@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== Close Button ===== */
#close-dash-save {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

#close-dash-save:hover {
  transform: scale(1.2);
}

/* ===== Headings ===== */
#dash-save-modal h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ===== Textareas ===== */
#dash-save-output,
#dash-load-input {
  width: 100%;
  min-height: 120px;
  resize: vertical;

  margin-top: 8px;
  margin-bottom: 14px;
  padding: 12px 14px;

  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);

  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;

  transition: all 0.18s ease;
}

#dash-save-output:focus,
#dash-load-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.18);
}

/* readonly visual cue */
#dash-save-output[readonly] {
  opacity: 0.9;
}

/* ===== Buttons Row Feel ===== */
#dash-save-modal button {
  width: 100%;
  margin-bottom: 10px;
}

/* primary action emphasis */
#dash-save-btn,
#dash-load-btn {
  box-shadow: 0 0 0 0 rgba(126, 231, 135, 0);
}

#dash-save-btn:hover,
#dash-load-btn:hover {
  box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.25);
}

/* ===== Copy confirmation ===== */
#copy-confirmation {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
}

/* ===== Switch text ===== */
.want {
  font-size: 13px;
  color: var(--muted);
}

.want a {
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s ease;
}

.want a:hover {
  color: var(--accent);
}


.dash {
  display: grid;
  grid-template-columns: 1fr;
  /* stacked by default */
  gap: 20px;
}

/* 🔹 mobile order (stacked) */
.chadash {
  order: 2;
}

.acttab {
  order: 1;
}

/* 🔹 wide screen layout */
@media (min-width: 1000px) {
  .dash {
    grid-template-columns: 1fr 1fr;
    /* side by side */
  }

  /* restore normal order */
  .chadash {
    order: 1;
  }

  .acttab {
    order: 2;
  }
}

#selectBtn {
  position: absolute;
  top: 8px;
  right: 9px;
  border: none;
  box-shadow: none;
  padding: 0px;
  background: none;
}

.dash h2 {
  margin-bottom: 5px;
  margin-left: 10px;
}

.dash p {
  margin-bottom: 10px;
  margin-left: 10px;
  color: var(--muted);
  font-size: 12px;
}

h2.chda {
  margin-bottom: 5px;
  margin-left: 10px;
  font-size: 28px;
}

p.chda {
  margin-bottom: 10px;
  margin-left: 10px;
  color: var(--muted);
  font-size: 14px;
}

#overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

#overview p {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 2px;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  display: flex;
  width: 22%;
  flex-direction: column;
  align-items: center;
  /* centers everything horizontally */
  color: var(--text);
}

#overview span {
  font-size: 18px;
}

.dead-character {
  position: relative;
}

.dead-character h1 {
  text-decoration: line-through;
}

/* visual fade layer */
.dead-character::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.05);
  /* adjust for your theme */
  backdrop-filter: grayscale(80%);
  pointer-events: none;
  border-radius: inherit;
}

/* keep controls fully visible */
.dead-character .playBtn,
.dead-character .deleteBtn,
.dead-character #selectBtn {
  position: relative;
  z-index: 2;
}

.char-tag.hidden-tag {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.stats-box {
  position: relative;
}

.char-portrait {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 100px;
}

.char-portrait {
  border: 1px solid var(--border);
  background: #111;
}

#table td.drop-hover {
  outline: 2px dashed var(--surface);
  outline-offset: -2px;
  opacity: 0.9;
}

.char-tag {
  cursor: grab;
}

.char-tag.dragging {
  cursor: grabbing;
  opacity: 0.5;
}