.upper-bar {
  width: 194px;
  height: 15px;
  background: #848a83;
  border: 4px solid #000;
  border-bottom: 2px solid #000;
  box-sizing: border-box;
  overflow: hidden;
}

.upper-bar .bar-fill {
  height: 100%;
  width: 0%;
  background: yellow;
  transition: width 0.3s, background-color 0.3s;
}

.lower-bar {
  width: 194px;
  height: 15px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  background: #000;
  border: 4px solid #000;
  border-top: 2px solid #000;
  box-sizing: border-box;
}

.lower-bar .pip {
  background: #848a83;
  height: 100%;
}

.lower-bar .pip.filled {
  background: #5b63ff;
}

/* Grades */
#stats-panel [id$="-grade"] {
  color: #ffd60a;
  font-weight: bold;
}

/* ============================
   Chao Titles (Stats + Focus)
   ============================ */
#chao-title {
  display: block;
  font-size: 14px;
  color: #ffd60a;
  text-align: center;
  margin: 4px 0;
  text-shadow: 1px 1px 2px #000;
}

#select-title-btn {
  display: inline-block;
  background: #415a77;
  border: 2px solid #ffd60a;
  border-radius: 6px;
  color: #fff;
  font-weight: bold;
  font-size: 12px;
  padding: 4px 8px;
  margin-top: 4px;
  transition: background 0.2s, transform 0.1s;
}

#select-title-btn:hover {
  background: #5b63ff;
  transform: scale(1.05);
}

.focus-title-line {
  color: #ffd60a;
  font-size: 13px;
  font-style: italic;
  margin-top: 2px;
  text-shadow: 1px 1px 2px #000;
}

.title-highlight {
  color: #ffd60a;
  text-shadow: 1px 1px 2px #000;
}

/* ============================
   Snap-On Debug Panel
   ============================ */
#stats-debug-panel .stats-debug-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

#stats-debug-panel .stats-debug-heading {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  color: #dfefff;
  text-align: left;
  text-shadow: none;
}

#stats-debug-panel .debug-align {
  --debug-align-width: 200px;
  --debug-align-height: 16px;
  --debug-align-marker-left: 50%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

#stats-debug-panel .debug-align-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: rgba(223, 239, 255, 0.88);
}

#stats-debug-panel .debug-align-label-row strong {
  color: #ffffff;
}

#stats-debug-panel .debug-align-state {
  color: rgba(223, 239, 255, 0.72);
  font-weight: 700;
}

#stats-debug-panel .debug-align-bar {
  position: relative;
  width: var(--debug-align-width);
  max-width: 100%;
  height: var(--debug-align-height);
  border: 1px solid rgba(167, 189, 215, 0.62);
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(to right,
    #8f1d1d 0%, #8f1d1d 40%,
    #d9dce0 40%, #d9dce0 60%,
    #2459a8 60%, #2459a8 100%);
}

#stats-debug-panel .debug-align-marker {
  position: absolute;
  top: 0;
  left: var(--debug-align-marker-left);
  transform: translateX(-1px);
  width: 2px;
  height: 100%;
  background: #ffe066;
  box-shadow: 0 0 6px rgba(255, 224, 102, 0.65);
}

#stats-debug-panel .debug-align-scale {
  display: flex;
  justify-content: space-between;
  width: var(--debug-align-width);
  max-width: 100%;
  font-size: 11px;
  color: rgba(223, 239, 255, 0.62);
}

#stats-debug-panel .debug-dev-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

#stats-debug-panel .debug-dev-btn {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #415a77;
  background: linear-gradient(180deg, rgba(44, 64, 90, 0.96), rgba(18, 31, 49, 0.98));
  color: #f4f8ff;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

#stats-debug-panel .debug-dev-btn:hover {
  filter: brightness(1.08);
}

#stats-debug-panel .debug-dev-hint {
  color: rgba(223, 239, 255, 0.62);
  font-size: 12px;
  user-select: none;
}

#stats-debug-panel .stats-debug-pre {
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(91, 126, 165, 0.65);
  border-radius: 10px;
  background: rgba(9, 17, 29, 0.72);
  color: #e7f1ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

#stats-debug-panel .stats-debug-dev-card {
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(91, 126, 165, 0.65);
  border-radius: 10px;
  background: rgba(9, 17, 29, 0.72);
  color: #e7f1ff;
}

#stats-debug-panel .stats-debug-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

#stats-debug-panel .stats-debug-field-label,
#stats-debug-panel .stats-debug-field-section {
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(223, 239, 255, 0.86);
}

#stats-debug-panel .stats-debug-field-section {
  grid-column: 1 / -1;
  padding-top: 8px;
  color: rgba(223, 239, 255, 0.64);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

#stats-debug-panel .stats-debug-field-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#stats-debug-panel .stats-debug-tip {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(223, 239, 255, 0.68);
}

/* ============================
   Journal (Profile-style)
   ============================ */
/* ============================
   Journal (Stats & Achievements)
   - Larger, structured layout
   ============================ */
#journal-panel {
  padding: 10px;
  box-sizing: border-box;

  background: rgba(13, 27, 42, 0.95);
  border: 1px solid #415a77;
  border-radius: 10px;

  color: #eaeaea;
  font-size: 14px;

  overflow: hidden; /* pages handle scroll */
}

/* Kill default spacing bleed */
#journal-panel p {
  margin: 0;
}

/* ============================
   Journal Pages
   ============================ */
.journal-page {
  display: none;
  /* Keep content inside the larger panel and avoid "floating text" */
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.journal-page.active {
  display: block;
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

/* Content layout */
.journal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.journal-grid.one {
  grid-template-columns: 1fr;
}

.journal-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
}

.journal-card h3 {
  margin: 0 0 8px 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.journal-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.journal-kv:last-child {
  border-bottom: 0;
}

.journal-kv span {
  opacity: 0.9;
}

.journal-kv b {
  font-weight: 900;
}

/* ============================
   Tabs (match Profile buttons)
   ============================ */
#journal-panel .tabs {
  display: flex;
  gap: 4px;
  margin: 6px 0 8px 0;
}

#journal-panel .tabs button {
  flex: 1;
  padding: 4px 6px;
  font-size: 13px;
  background: #1b263b;
  border: 1px solid #415a77;
  border-radius: 6px;
  color: #ddd;
  cursor: pointer;
}

#journal-panel .tabs button.active {
  background: #415a77;
  color: #fff;
}

/* ============================
   Highlighted Journal Stats
   ============================ */
#journal-panel #journal-chaoregon-attempts,
#journal-panel #journal-chaoregon-wins {
  color: #ffd60a;
  font-weight: bold;
}

/* ============================
   Chao Preview (Profile-style)
   ============================ */
#journal-chao-preview {
  width: 96px;
  height: 96px;
  margin: 6px auto;

  border: 2px solid #415a77;
  border-radius: 8px;
  background: #000;

  display: flex;
  align-items: center;
  justify-content: center;
}

#journal-chao-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
