/* ================================================================
   HANGUL DOJANG - Styles
================================================================ */

/* ── Entry Modal ─────────────────────────────────────────────── */
#dojang-entry-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 8, 26, 0.88);
  backdrop-filter: blur(8px);
  transition: opacity .3s;
}
#dojang-entry-modal.off {
  opacity: 0;
  pointer-events: none;
}
#dojang-entry-inner {
  background: hsla(42, 28%, 95%, 1);
  background-image: url('../img/noise.svg');
  background-size: 200px;
  border: 1px solid rgba(80, 30, 10, 0.18);
  border-radius: 16px;
  padding: 24px 26px 26px 24px;
  width: min(660px, 94vw);
  color: #1a0808;
  box-shadow: 0 28px 80px rgba(0,0,0,.65);
  position: relative;
}

/* Modal title */
#dej-modal-title {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(100, 30, 20, .45);
  margin-bottom: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(100, 30, 20, .14);
}

/* Path selector row */
#dej-paths {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.dej-path-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,.03);
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 18px 12px;
  cursor: pointer;
  color: rgba(30, 10, 5, .8);
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
}
.dej-path-btn:hover {
  background: rgba(0,0,0,.06);
  border-color: rgba(0,0,0,.18);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
/* Per-path active accent colours */
.dej-path-btn[data-path="0"].active {
  background: rgba(154, 24, 24, .07);
  border-color: rgba(154, 24, 24, .4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(154,24,24,.1);
}
.dej-path-btn[data-path="1"].active {
  background: rgba(26, 60, 140, .07);
  border-color: rgba(26, 60, 140, .38);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26,60,140,.1);
}
.dej-path-btn[data-path="2"].active {
  background: rgba(14, 80, 55, .07);
  border-color: rgba(14, 80, 55, .38);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(14,80,55,.1);
}

/* Path icons — calligraphic for 0 and 1, typeset for 2 */
.dej-path-icon {
  font-size: 2.6rem;
  line-height: 1;
  color: rgba(30, 10, 5, .75);
  transition: color .2s;
}
.dej-path-btn[data-path="2"] .dej-path-icon {
  font-family: "Song Myung", "Nanum Myeongjo", serif;
  font-size: 3rem;
}

.dej-path-btn[data-path="1"] .dej-path-icon {
  font-family: "Nanum Myeongjo", serif;
  font-size: 3rem;
}
.dej-path-btn[data-path="0"].active .dej-path-icon,
.dej-path-btn[data-path="0"]:hover  .dej-path-icon { color: #9a1818; }
.dej-path-btn[data-path="1"].active .dej-path-icon,
.dej-path-btn[data-path="1"]:hover  .dej-path-icon { color: #1a3c8c; }
.dej-path-btn[data-path="2"].active .dej-path-icon,
.dej-path-btn[data-path="2"]:hover  .dej-path-icon { color: #0e5037; }

.dej-path-label {
  font-size: .74rem;
  color: rgba(40, 15, 10, .55);
  text-align: center;
  line-height: 1.4;
}
.dej-connector {
  font-size: 1.1rem;
  color: rgba(100, 30, 20, .2);
  flex-shrink: 0;
  align-self: center;
  letter-spacing: .05em;
}

/* Detail section */
#dej-detail {
  margin-top: 16px;
  border-top: 1px solid rgba(100, 30, 20, .13);
  padding-top: 16px;
}
#dej-detail.off { display: none; }
#dej-detail-title {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(80, 20, 10, .4);
  text-align: center;
  margin-bottom: 16px;
}
#dej-detail[data-path="0"] #dej-detail-title { color: rgba(154, 24,  24,  .8);  }
#dej-detail[data-path="1"] #dej-detail-title { color: rgba(26,  60,  140, .75); }
#dej-detail[data-path="2"] #dej-detail-title { color: rgba(14,  80,  55,  .75);
}
#dej-cards {
  display: flex;
  gap: 10px;
}
.dej-card {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,.03);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 11px 12px 0 12px;
  cursor: pointer;
  color: rgba(30,10,5,.85);
  text-align: left;
  position: relative;
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
}
.dej-card:hover {
  background: rgba(0,0,0,.06);
  border-color: rgba(0,0,0,.18);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.07);
}
/* Per-action default background tints */
.dej-card[data-action="dojang"]      { background: rgba(154,24,24,.04);  border-color: rgba(154,24,24,.2);  }
.dej-card[data-action="solo-normal"] { background: rgba(26,60,140,.04);  border-color: rgba(26,60,140,.18); }
.dej-card[data-action="coop"]        { background: rgba(26,60,140,.04);  border-color: rgba(26,60,140,.18); }
.dej-card[data-action="solo-expert"] { background: rgba(14,80,55,.04);   border-color: rgba(14,80,55,.18);  }
.dej-card[data-action="coop-expert"] { background: rgba(14,80,55,.04);   border-color: rgba(14,80,55,.18);  }

/* Card hover accents */
#dej-detail[data-path="0"] .dej-card:hover { background: rgba(154,24,24,.09); border-color: rgba(154,24,24,.35); }
#dej-detail[data-path="1"] .dej-card:hover { background: rgba(26,60,140,.09); border-color: rgba(26,60,140,.32); }
#dej-detail[data-path="2"] .dej-card:hover { background: rgba(14,80,55,.09);  border-color: rgba(14,80,55,.32);  }

.dej-card-desc {
  font-size: .9rem;
  font-family: "EZRA Serif", serif;
  color: rgb(40, 15, 10);
  line-height: 1.5;
  padding-right: 5.5rem;
  flex: 1;
}
.dej-card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 14px;
}
.dej-card-portrait {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.28));
}
.dej-card-portrait svg { width: 80px; height: 80px; }
.dej-card-portrait-coop {
  font-size: 62px;
  line-height: 91px;
  text-align: center;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.28));
}
.dej-card-cta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.dej-cta-emoji {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.28));
}
.dej-cta-label {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  color: rgba(30,10,5,.75);
  padding-bottom: 10px;
}
.dej-card-coop { flex: 0.75; }
.dej-card-coop .dej-card-desc { padding-right: 2.8rem; }
.dej-beta {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #dc2626;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1.3;
}
@media (max-width: 480px) {
  #dej-paths { gap: 5px; }
  .dej-path-btn { padding: 14px 8px; gap: 8px; }
  .dej-path-icon { font-size: 2rem !important; }
  .dej-path-label { font-size: .9rem; }
  .dej-connector { display: none; }
  #dej-cards { flex-direction: column; }
}
@media (max-height: 500px) {
  #dojang-entry-inner { zoom: 0.8; }
}

/* ── Dojang Paper Background (noise texture over gradient canvas) ── */
#dojang-paper-bg {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: url('../img/noise.svg');
  background-size: 180px;
  opacity: 0.1;
  display: none;
}
body.phase-dojang #dojang-paper-bg { display: block; }

/* ── Dojang Stroke Canvas ────────────────────────────────────── */
#dojang-canvas {
  position: fixed;
  inset: 0;
  z-index: 10;
  touch-action: none;
  cursor: crosshair;
}
body:not(.phase-dojang) #dojang-canvas {
  display: none;
  pointer-events: none;
}

/* ── Dojang Screen Overlay (HUD + modals) ────────────────────── */
#scr-dojang {
  z-index: 160;
  pointer-events: none; /* let drawing canvas receive events */
  background: transparent;
  display: flex;
  flex-direction: column;
}
#scr-dojang > * {
  pointer-events: all; /* re-enable for interactive children */
}
/* Drawing area must NOT intercept (it's on a separate canvas layer) */
#scr-dojang.off {
  opacity: 0;
  pointer-events: none;
}
#scr-dojang.off * {
  pointer-events: none !important;
}

/* ── Dojang HUD ──────────────────────────────────────────────── */
#dojang-hud {
  position: fixed;
  top: 10px;
  left: 0;
  right: 0;
  z-index: 161;
  pointer-events: none; /* transparent - children opt back in */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}
/* All direct HUD children receive pointer events */
#dojang-hud > * { pointer-events: all; }
#dojang-hud-left, #dojang-hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Progress ring + label - fixed to true viewport center, not HUD center */
#dojang-ring-wrap {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 162;
  pointer-events: all;
  display: grid;
  grid-template-columns: minmax(50px, max-content);
  justify-items: center;
  row-gap: 4px;
  max-width: 160px;
  background: rgba(0,0,0, .30);
  border-radius: 10px;
  padding: 6px 16px;
  transition: transform .2s ease;
  transform-origin: 50% 0; /* scale from top edge → grows downward */
}
/* Mobile: adiciona espaço para mobile titlebar */
body.mobile-fs #dojang-ring-wrap {
  top: calc(10px + var(--tb-h));
}
/* Phone portrait (narrow) or landscape (short): move ring to bottom-right */
@media (max-width: 600px), (max-height: 600px) {
  #dojang-ring-wrap {
    top: auto;
    left: auto;
    right: 12px;
    bottom: 12px;
    transform: none;
    transform-origin: 100% 100%;
  }
  body.mobile-fs #dojang-ring-wrap {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
#dojang-ring-svg {
  grid-row: 1;
  grid-column: 1;
  transform: rotate(-90deg);
}
#dojang-ring-bg { fill: none; stroke: rgba(255,255,255,.28); }
#dojang-ring-fg {
  fill: none;
  stroke: #ecf4c5;
  stroke-linecap: round;
  stroke-dasharray: 138.2; /* 2π×22 */
  stroke-dashoffset: 138.2;
  transition: stroke-dashoffset .4s ease;
}
#dojang-threshold {
  grid-row: 1;
  grid-column: 1;
  align-self: center;
  justify-self: center;
  font-size: .85rem;
  font-weight: 700;
  color: rgba(255,255,255,.8);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 1;
}
#dojang-phase-label {
  grid-row: 2;
  grid-column: 1;
  font-size: .65rem;
  font-weight: 600;
  color: hsl(70deg 93% 89% / 90%);
  text-align: center;
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}

/* HUD icon buttons */
.dj-hud-btn {
  background: rgba(0,0,0,.30);
  border: none;
  border-radius: 8px;
  color: rgba(255,255,255,.75);
  font-size: 1.1rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.dj-hud-btn:hover { background: rgba(0,0,0,.18); }

/* Pause icon via SVG mask (matches style.css icon pattern) */
.icon-pause {
  display: inline-block;
  width: 22px;
  height: 22px;
  background-color: rgba(255,255,255,.75);
  -webkit-mask-image: url(../img/pause.svg);
          mask-image: url(../img/pause.svg);
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}
.dj-hud-btn:hover .icon-pause { background-color: rgba(0,0,0,.18); }

/* ── Dojang Player Sprite ────────────────────────────────────── */
#dojang-player {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 280;
  pointer-events: none;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}
/* Mobile: posiciona no inferior-esquerdo, sprite à esquerda */
body.mobile-fs #dojang-player {
  left: 14px;
  transform: none;
  flex-direction: row-reverse;
}
#dojang-player-sprite {
  width: 84px;
  height: 84px;
  font-size: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
#dojang-player-sprite svg {
  width: 84px;
  height: 84px;
}

/* Player action buttons: 🔊 and ❌ */
.dj-player-btn {
  background: rgba(0,0,0,.30);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .95rem;
  pointer-events: all;
  margin-bottom: 22px; /* align to mid-height of sprite */
  transition: background .15s, opacity .2s;
}
.dj-player-btn:hover { background: rgba(0,0,0,.18); }

/* ── Announce - at body level, above everything ──────────────── */
#dojang-announce {
  position: fixed;
  left: 14px;
  top: 88px;
  z-index: 400;
  pointer-events: none;
  background: none; border: none; box-shadow: none; padding: 0;
  color: rgba(70,28,12,.82);
  font-family: 'EZRA Serif', serif;
  font-size: clamp(.8rem, 1.6vw, 1.1rem);
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  text-shadow: 0 0 14px rgba(255,255,255,.9), 0 1px 3px rgba(0,0,0,.1);
  opacity: 0;
  transition: opacity .3s;
}
#dojang-announce.on { opacity: 1; }
body:not(.phase-dojang) #dojang-announce { opacity: 0 !important; }

/* ── Pause Overlay ───────────────────────────────────────────── */
#dojang-pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(47, 29, 13, .68);
  backdrop-filter: blur(8px);

  transition: opacity .25s;
}
#dojang-pause-overlay.off {
  opacity: 0;
  pointer-events: none;
  display: none;
}
#dojang-pause-panel {
  background: hsla(42, 28%, 95%, .98) url('../img/noise.svg') repeat;
  background-size: 200px;
  border: 1px solid rgba(80, 30, 10, .22);
  border-radius: 18px;
  padding: 24px 22px 20px;
  width: min(390px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(37, 18, 5, .5);
  color: #32170d;
}
#dojang-pause-panel h2 {
  font-family: 'EZRA Serif', serif;
  font-size: 1.3rem;
  margin-bottom: 14px;
  color: #7d2119;
}
.dojang-pause-audio {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; padding: 0 8px;
  font-size: .85rem; opacity: .75;
}
.dojang-pause-audio-label { white-space: nowrap; }
.dojang-pause-tts-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 8px 10px;
  background: rgba(96, 51, 22, .045);
  border: 1px solid rgba(96, 51, 22, .12);
  border-radius: 10px;
  color: #573221;
  font-size: .8rem;
}
.dojang-pause-tts-row.tts-unsupported { opacity: .3; pointer-events: none; }
#dojang-pause-panel .gopt-track { background: rgba(89, 43, 19, .18); }
#dojang-pause-panel .gopt-toggle input:checked ~ .gopt-track { background: #8d261c; }
#dojang-pause-panel .support-callout {
  width: 100%; margin-top: 14px;
}
.dj-pause-btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px;
  background: rgba(96, 51, 22, .045);
  border: 1.5px solid rgba(96, 51, 22, .2);
  border-radius: 11px;
  color: #512719;
  font-family: 'EZRA Serif', serif;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dj-pause-btn:hover {
  background: rgba(96, 51, 22, .09);
  border-color: rgba(96, 51, 22, .38);
}
.dj-pause-btn.dj-pause-primary {
  background: #3b3529;
  border-color: rgba(42, 33, 23, .76);
  color: #fffaf0;
}
.dj-pause-btn.dj-pause-primary:hover {
  background: #30281f;
  border-color: #30281f;
}

@media (max-height: 500px) {
  #dojang-pause-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 10px;
  }
  #dojang-pause-panel {
    width: min(360px, 94vw);
    max-height: none;
    margin: auto;
    padding: 12px 14px;
  }
  #dojang-pause-panel h2 { font-size: 1.05rem; margin-bottom: 9px; }
  .dojang-pause-audio { margin-bottom: 9px; padding: 0 4px; font-size: .75rem; }
  .dojang-pause-tts-row { margin-bottom: 7px; padding: 6px 8px; font-size: .72rem; }
  #dojang-pause-panel .dj-pause-btn { margin: 4px 0; padding: 8px; font-size: .82rem; }
  #dojang-pause-panel .support-callout { margin-top: 8px; padding: 7px 9px 6px; gap: 5px; }
  #dojang-pause-panel .support-callout-heading { font-size: .75rem; gap: 5px; }
  #dojang-pause-panel .support-callout-emoji { font-size: .96rem; }
  #dojang-pause-panel .support-callout-body { font-size: .66rem; line-height: 1.3; }
  #dojang-pause-panel .support-callout-btn { min-height: 29px; padding: 4px 7px; font-size: .68rem; }
  #dojang-pause-panel .support-callout-btn img { width: 20px; height: 20px; }
  #dojang-pause-panel .support-callout-pix { font-size: .54rem; }
}

/* ── Book Modal ──────────────────────────────────────────────── */
#dojang-book-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 8, 4, 0.6);
  backdrop-filter: blur(8px);

  transition: opacity .25s;
}
#dojang-book-modal.off {
  opacity: 0;
  pointer-events: none;
}
#dojang-book-inner {
  background: hsla(45,35%,97%,1);
  border: 8px solid #b82222;
  border-left: 24px solid #9a1818;
  border-radius: 4px 14px 14px 4px;
  width: min(520px, 94vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -6px 0 18px rgba(100,0,0,.18), 4px 0 18px rgba(0,0,0,.25);
  position: relative;
}
/* Spiral binding holes on the red spine */
#dojang-book-inner::after {
  content: '';
  position: absolute;
  left: -18px;
  top: 0;
  bottom: 0;
  width: 16px;
  pointer-events: none;
  background: radial-gradient(circle at 8px 14%, hsla(45,35%,97%,.85) 4px, transparent 4px),
              radial-gradient(circle at 8px 28%, hsla(45,35%,97%,.85) 4px, transparent 4px),
              radial-gradient(circle at 8px 42%, hsla(45,35%,97%,.85) 4px, transparent 4px),
              radial-gradient(circle at 8px 56%, hsla(45,35%,97%,.85) 4px, transparent 4px),
              radial-gradient(circle at 8px 70%, hsla(45,35%,97%,.85) 4px, transparent 4px),
              radial-gradient(circle at 8px 84%, hsla(45,35%,97%,.85) 4px, transparent 4px);
}
#dojang-book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(100,0,0,.15);
  color: #2a0808;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  background: hsla(0,30%,96%,1);
}
#dojang-book-close {
  background: none;
  border: none;
  color: rgba(100,40,40,.6);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
#dojang-book-body {
  overflow-y: auto;
  padding: 16px 18px;
  flex: 1;
  scrollbar-color: rgba(150,0,0,.2) transparent;
}
.dj-book-header {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.dj-book-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(100,0,0,.12);
  border-radius: 10px;
  padding: 10px 18px;
  min-width: 90px;
}
.dj-book-stat-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: #8a2020;
}
.dj-book-stat-lbl {
  font-size: .68rem;
  color: rgba(60,20,20,.55);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dj-book-stage-pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(100,0,0,.12);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 160px;
}
.dj-stage-name {
  font-size: .78rem;
  font-weight: 700;
  color: #8a2020;
  text-align: center;
  letter-spacing: .02em;
}
.dj-stage-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.dj-stage-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  justify-content: center;
  margin-top: 2px;
}
.dj-stage-check {
  font-size: .60rem;
  color: rgba(50,150,70,.8);
  white-space: nowrap;
}
.dj-stage-step {
  font-size: .85rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s;
}
.dj-stage-done {
  color: rgba(80,160,80,.9);
  background: rgba(80,160,80,.12);
}
.dj-stage-current {
  color: #8a2020;
  background: rgba(138,32,32,.15);
  box-shadow: 0 0 0 2px rgba(138,32,32,.3);
}
.dj-stage-future {
  color: rgba(60,20,20,.3);
}
.dj-stage-arrow {
  font-size: .65rem;
  color: rgba(60,20,20,.25);
  padding: 0 1px;
}
.dj-book-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dj-book-row {
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  background: rgba(0,0,0,.025);
  font-size: .8rem;
  overflow: hidden;
  border: 1px solid rgba(100,0,0,.08);
}
.dj-book-row-main {
  border: 1px solid transparent;
  display: grid;
  grid-template-columns: 2rem 4.5rem 3rem 1fr 2.5rem 2rem 1.4rem;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 6px;
}
.dj-book-row.has-desc .dj-book-row-main:hover {
  border-color: rgba(150,30,30,.5);
}
.dj-book-jamo {
  font-size: 1.3rem;
  text-align: center;
  color: #1a0808;
}
.dj-book-name {
  color: rgba(40,15,15,.8);
  font-size: .78rem;
}
.dj-book-name-rom {
  color: rgba(80,30,30,.45);
  font-size: .68rem;
  font-weight: 400;
}
.dj-book-rom {
  color: rgba(120,40,40,.7);
  font-size: .72rem;
  font-style: italic;
}
.dj-book-bar-wrap {
  height: 5px;
  background: rgba(0,0,0,.08);
  border-radius: 3px;
  overflow: hidden;
}
.dj-book-bar {
  height: 100%;
  background: linear-gradient(90deg, #c03030, #e07070);
  border-radius: 3px;
  transition: width .3s ease;
}
.dj-book-count {
  color: rgba(60,20,20,.6);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: .75rem;
  cursor: default;
}
.dj-book-strokes {
  color: rgba(80,30,30,.4);
  font-size: .68rem;
  text-align: right;
  cursor: default;
}
.dj-book-expand-btn {
  background: none;
  border: none;
  color: rgba(120,40,40,.5);
  font-size: .65rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, color .15s;
}
.dj-book-row.expanded .dj-book-expand-btn {
  transform: rotate(180deg);
  color: rgba(160,30,30,.9);
}
.dj-book-desc {
  padding: 5px 10px 8px;
  font-size: .76rem;
  color: rgba(40,10,10,.75);
  border-top: 1px solid rgba(100,0,0,.1);
  line-height: 1.45;
  background: rgba(255,240,240,.4);
}
.dj-book-desc.off { display: none; }

/* ── Jamo font preview (top of dj-book-desc) ──────────────────── */
.jamo-font-preview {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 6px 2px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(100,0,0,.12);
}
.jamo-fp-main .jamo-fp-char {
  font-family: 'Pretendard', sans-serif;
  font-size: 3.75rem;
  font-weight: 700;
  line-height: 1;
}
.jamo-fp-variants {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.jamo-fp-variant {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
}
.jamo-fp-variant .jamo-fp-char {
  font-size: 2.5rem;
  line-height: 1;
  border: 1px solid rgba(100,0,0,.18);
  border-radius: 6px;
  padding: 4px;
  background: rgba(255,255,255,.55);
}
.jamo-fp-song .jamo-fp-char    { font-family: 'Song Myung', serif; padding: 2px 4px 0 !important; }
.jamo-fp-myeongjo .jamo-fp-char { font-family: 'Nanum Myeongjo', serif; padding: 6px 4px 0 !important; }
.jamo-fp-label {
  font-size: .6rem;
  color: rgba(60,30,30,.45);
  font-family: 'Pretendard', sans-serif;
  letter-spacing: .02em;
}
.jamo-name-sound {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 2px 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(100,0,0,.1);
  font-size: .76rem;
}
.jamo-ns-row { display: flex; gap: 8px; font-size: .9rem; }
.jamo-ns-label { color: rgba(60,20,20,.5); flex-shrink: 0; }
.jamo-ns-val   { color: rgba(30,10,10,.85); font-weight: 600; }
.jamo-ns-rom   { color: rgba(80,30,30,.45); font-size: .8em; font-weight: 400; }
#dojang-book-inner .md-speak-word { color: #c02020; font-weight: 700; }
#dojang-book-inner .md-speak-word:hover { color: #e03030; }

/* ── Jamo Unlock Leaf Modal ──────────────────────────────────── */
#dojang-leaf-modal {
  position: fixed;
  inset: 0;
  z-index: 305;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3,8,26,0.72);
  backdrop-filter: blur(6px);
}
#dojang-leaf-modal.off { display: none; }
#dojang-leaf-inner {
  background: hsla(8,30%,96%,1);
  background-image: url('../img/noise.svg');
  background-size: 200px;
  border: 6px solid #b82222;
  border-left: 20px solid #9a1818;
  border-radius: 4px 14px 14px 4px;
  padding: 0 0 24px;
  width: min(400px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  color: #1a0808;
  box-shadow: -4px 0 14px rgba(100,0,0,.16), 0 24px 80px rgba(0,0,0,.65);
  scrollbar-width: thin;
  scrollbar-color: rgba(150,0,0,.2) transparent;
}
#dojang-leaf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(154,24,24,.2);
  position: sticky;
  top: 0;
  background: hsla(0,30%,96%,.97);
  z-index: 1;
}
#dojang-leaf-nospoil {
  font-size: .72rem;
  color: rgba(154,24,24,.5);
  background: none;
  border: 1px solid rgba(154,24,24,.25);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, border-color .15s;
}
#dojang-leaf-nospoil:hover { color: rgba(154,24,24,.85); border-color: rgba(154,24,24,.5); }
#dojang-leaf-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: rgba(154,24,24,.35);
  padding: 2px 4px;
  line-height: 1;
}
#dojang-leaf-close:hover { color: rgba(154,24,24,.7); }

/* ── Markdown spacing inside book descriptions ──────────────── */
.dj-book-desc .md-p  { margin: 5px 0; }
.dj-book-desc .md-li { margin-top: 4px; margin-bottom: 4px; }
.dj-book-desc .md-br { height: 8px; }

/* ── Batchim section in book desc ───────────────────────────── */
.dj-batchim-section {
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1.5px solid rgba(138,32,32,.22);
}
.dj-batchim-header {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(120,20,20,.65);
  margin-bottom: 12px;
}
.dj-double-batchim-section {
  border-top-color: rgba(60,40,120,.18);
}
.dj-double-batchim-section .dj-batchim-header {
  color: rgba(60,40,120,.65);
}
#dojang-leaf-body {
  padding: 0 20px;
}
#dojang-leaf-body .dj-book-desc {
  display: block;
  background: none;
  border: none;
  padding: 0;
}

/* ── Stroke Inspector Modal ──────────────────────────────────── */
#dojang-inspector-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 8, 4, 0.6);
  backdrop-filter: blur(8px);

  transition: opacity .25s;
}
#dojang-inspector-modal.off {
  opacity: 0;
  pointer-events: none;
}
#dojang-inspector-inner {
  background: hsla(45,35%,97%,1);
  border: 1.5px solid rgba(0,0,0,.15);
  border-radius: 14px;
  width: min(360px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 60px rgba(0,0,0,.3);
}
#dojang-inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 11px;
  border-bottom: none;
  background: #f0efeb;
  font-size: .95rem;
  font-weight: 700;
  flex-shrink: 0;
  order: 0; /* dark header at very top */
  color: #0d1428;
  border-radius: 13px 13px 0 0;
}
#dojang-inspector-header button {
  background: none;
  border: none;
  color: #0d142870;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
#dojang-inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 12px;
  display: flex;
  justify-content: center;
  order: 2;
}
.dj-insp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.dj-insp-char {
  font-size: 3rem;
  color: rgba(30,20,10,.9);
  line-height: 1.1;
  font-family: "Nanum Myeongjo", "Song Myung", serif;
  margin-top: 8px;
}
.dj-insp-name {
  font-size: .9rem;
  color: rgba(80,50,20,.65);
  font-style: italic;
}
.dj-insp-strokes {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  margin-top: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.18) transparent;
}
.dj-insp-strokes::-webkit-scrollbar {
  height: 4px;
}
.dj-insp-strokes::-webkit-scrollbar-track {
  background: transparent;
}
.dj-insp-strokes::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.18);
  border-radius: 2px;
}
.dj-insp-stroke-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 62px;
}
.dj-insp-num {
  font-size: .88rem;
  color: rgba(40,80,160,.8);
  font-weight: 700;
}
.dj-insp-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(30,20,10,.85);
  width: 30px;
  height: 30px;
}
/* Inspector nav as notebook tabs, below the dark header */
#dojang-inspector-nav {
  display: flex;
  gap: 4px;
  justify-content: flex-start;
  padding: 8px 12px 0;
  flex-shrink: 0;
  flex-wrap: wrap;
  border-bottom: 2px solid rgba(0,0,0,.12);
  background: rgba(0,0,0,.04);
  order: 1; /* between dark header (0) and body (2) */
}
#dojang-inspector-nav:empty { display: none; }
.dj-insp-dot {
  background: rgba(0,0,0,.05);
  border: 1.5px solid rgba(0,0,0,.15);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  color: rgba(60,40,20,.65);
  font-size: 1rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
  bottom: -2px;
}
.dj-insp-dot:hover {
  background: rgba(255,255,255,.7);
  color: rgba(30,20,10,.9);
}
.dj-insp-dot-active {
  background: hsla(45,35%,97%,1);
  border-color: rgba(0,0,0,.15);
  color: #1a1008;
  font-weight: 700;
}
.dj-insp-dot-current {
  color: rgba(20,120,50,.9);
}

/* ── Mobile titlebar offset ──────────────────────────────────── */
body.mobile-fs #dojang-hud { top: calc(10px + var(--tb-h)); }
body.mobile-fs #dojang-announce { top: calc(88px + var(--tb-h)); }

/* ── Larger player on desktop ────────────────────────────────── */
@media (min-width: 768px) and (min-height: 500px) {
  #dojang-player-sprite { width: 108px; height: 108px; }
  #dojang-player-sprite svg { width: 108px; height: 108px; }
  .dj-player-btn { width: 44px; height: 44px; font-size: 1.1rem; margin-bottom: 30px; }
  #dojang-ring-wrap:hover { transform: translateX(-50%) scale(1.3); }
}

/* ── Small screen adjustments ────────────────────────────────── */
@media (max-height: 600px) {
  #dojang-player-sprite { width: 91px; height: 91px; order: 1; }
  #dojang-player-sprite svg { width: 91px; height: 91px; }
  .dj-player-btn { width: 36px; height: 36px; font-size: .96rem; margin-bottom: 17px; }
  #dojang-announce { top: 76px; font-size: .75rem; }
}

/* ── Dev cheat menu ──────────────────────────────────────── */
#dojang-cheat-menu {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
}
#djc-box {
  background: #2a1a0a; border: 1.5px solid rgba(240,224,200,.25);
  border-radius: 10px; padding: 20px; min-width: 260px;
  display: flex; flex-direction: column; gap: 10px; position: relative;
}
.djc-title {
  font-size: 1rem; font-weight: bold; margin-bottom: 15px; color: #f0e0c8;
}
.djc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: white; }
.djc-row span { color: rgba(240,224,200,.6); font-size: .8rem; }
#dojang-cheat-menu button {
  background: rgba(255,255,255,.08); border: 1px solid rgba(240,224,200,.2);
  color: #f0e0c8; border-radius: 5px; padding: 4px 10px;
  font-size: .8rem; cursor: pointer; transition: background .15s;
}
#dojang-cheat-menu button:hover { background: rgba(255,255,255,.15); }
#dojang-cheat-menu .djc-active { background: rgba(240,180,60,.25); border-color: rgba(240,180,60,.6); }
#dojang-cheat-menu .djc-danger { color: #e07070; border-color: rgba(220,80,80,.3); }
#dojang-cheat-menu .djc-close {
  position: absolute; top: 18px; right: 20px;
  padding: 4px 6px; font-size: .75rem;
}
#djc-prog-input {
  width: 54px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(240,224,200,.2); border-radius: 4px;
  color: #f0e0c8; padding: 3px 6px; font-size: .8rem; text-align: center;
}
