/* Túi đồ (gói P) + Giữ nhân vật (gói Q): sơn mài nâu trầm + vàng kim, chỉ dùng token màu của game.css.
   Mọi lớp bắt đầu bằng .tdo- (tủ đồ) hoặc .tk- (tài khoản) để không va lớp toàn cục như .primary. */
dialog.tdo-dialog[open] {
  text-align: left;
  width: min(760px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: 92dvh;
  padding: 22px 22px 18px;
}
dialog.tk-dialog[open] {
  width: min(500px, calc(100vw - 24px));
}
.tdo-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  padding-right: 44px;
}
.tdo-dialog .tdo-head h2 {
  margin: 0;
}
.tdo-count {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--milk);
}
.tdo-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-sunk);
  color: var(--cream);
}
.tdo-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.tdo-close:hover,
.tdo-close:focus-visible {
  border-color: var(--line-strong);
  color: var(--gold-hi);
}
.tdo-body {
  display: grid;
  grid-template-columns: minmax(200px, 250px) 1fr;
  gap: 18px;
  align-items: start;
}
.tdo-stage {
  position: relative;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: radial-gradient(ellipse 70% 55% at 50% 38%, rgba(243, 201, 115, 0.16), transparent 70%),
    linear-gradient(180deg, #2a1d12, #150e08);
  box-shadow: inset 0 0 0 1px rgba(243, 201, 115, 0.08);
  overflow: hidden;
}
.tdo-canvas {
  display: block;
  width: 100%;
  height: 300px;
  touch-action: none;
  cursor: grab;
}
.tdo-canvas:active {
  cursor: grabbing;
}
.tdo-stage-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--milk);
  pointer-events: none;
}
.tdo-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.tdo-tab {
  position: relative;
  min-height: 44px;
  display: grid;
  place-content: center;
  gap: 1px;
  border-radius: 10px;
  color: var(--milk);
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
}
.tdo-tab small {
  font-size: 10.5px;
  opacity: 0.8;
}
.tdo-tab.is-on {
  background: var(--selected-fill);
  color: var(--gold-hi);
  box-shadow: var(--glow);
}
.tdo-tab.is-new::after,
.tdo-cell.is-new::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion);
  box-shadow: 0 0 0 2px #1c140c;
}
.tdo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.tdo-cell {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  padding: 10px 6px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass-fill), rgba(30, 21, 13, 0.6);
  color: var(--cream);
}
.tdo-cell:hover,
.tdo-cell:focus-visible {
  border-color: var(--line-strong);
}
.tdo-cell .tdo-glyph {
  width: 46px;
  height: 46px;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
.tdo-name {
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}
.tdo-cell.is-worn {
  background: var(--selected-fill);
  border-color: var(--gold);
  box-shadow: var(--glow);
}
.tdo-cell.is-worn .tdo-name {
  color: var(--gold-hi);
}
.tdo-cell.is-selected:not(.is-worn) {
  border-color: var(--line-strong);
}
.tdo-cell.is-locked .tdo-glyph {
  opacity: 0.32;
  filter: grayscale(0.7);
}
.tdo-cell.is-locked .tdo-name {
  color: var(--milk);
}
.tdo-lock {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.7;
}
.tdo-cell > .tdo-lock {
  position: absolute;
  top: 8px;
  left: 8px;
  opacity: 0.85;
}
.tdo-meter {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 3px;
  border-radius: 2px;
  background: rgba(224, 178, 92, 0.16);
  overflow: hidden;
}
.tdo-meter i {
  display: block;
  width: calc(var(--k) * 100%);
  height: 100%;
  background: var(--gold);
}
.tdo-info {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 76px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-sunk);
}
.tdo-info-icon .tdo-glyph {
  width: 44px;
  height: 44px;
}
.tdo-info strong {
  font: 500 17px/1.3 var(--serif);
  color: var(--gold-hi);
}
.tdo-info p {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
}
.tdo-ok {
  color: var(--jade) !important;
}
.tdo-hint {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--gold) !important;
}
.tdo-muted {
  margin: 0;
  color: var(--milk) !important;
  font-size: 13px;
}
.tdo-foot {
  margin: 14px 0 0;
  font-size: 12px !important;
  color: var(--milk) !important;
  text-align: center;
}

/* ---- Giữ nhân vật ---- */
.tk-status {
  min-height: 1.4em;
  margin: -4px 0 8px;
  font-size: 13px !important;
  color: var(--milk) !important;
}
.tk-status.is-ok {
  color: var(--jade) !important;
}
.tk-status.is-err {
  color: #f0a08f !important;
}
.tk-section {
  padding: 14px 0 6px;
  border-top: 1px solid var(--line);
}
.tk-section:first-child {
  border-top: 0;
  padding-top: 0;
}
.tk-section h3 {
  margin: 0 0 6px;
  font: 500 18px/1.3 var(--serif);
  color: var(--gold-hi);
}
.tk-section p {
  margin: 0 0 10px;
}
.tk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunk);
  color: var(--cream);
  font-size: 14px;
  text-decoration: none;
}
.tk-btn:hover,
.tk-btn:focus-visible {
  border-color: var(--gold);
  color: var(--gold-hi);
}
.tk-btn.is-main {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-deep));
  border-color: transparent;
  color: #241708;
  font-weight: 600;
}
.tk-btn.is-danger {
  border-color: rgba(184, 55, 45, 0.6);
  color: #f0a08f;
}
.tk-input {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunk);
  color: var(--cream);
  font: 600 17px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tk-input::placeholder {
  color: var(--milk);
  opacity: 0.6;
  letter-spacing: 0.1em;
}
.tk-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--glow);
}
.tk-code-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  padding: 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--gold-deep);
  background: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(243, 201, 115, 0.14), transparent 70%),
    var(--surface-sunk);
}
.tk-code {
  margin: 0 !important;
  font: 600 26px/1.2 var(--sans);
  letter-spacing: 0.14em;
  color: var(--gold-hi) !important;
  user-select: all;
}
.tk-qr {
  width: min(220px, 60vw);
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 6px solid #f8efdd;
  image-rendering: pixelated;
}
.tk-warn {
  margin: 0 !important;
  font-size: 12.5px !important;
  text-align: center;
  color: var(--gold) !important;
}

@media (max-width: 640px) {
  dialog.tdo-dialog[open] {
    padding: 18px 14px 14px;
  }
  .tdo-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .tdo-canvas {
    height: 210px;
  }
  .tdo-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .tdo-cell .tdo-glyph {
    width: 38px;
    height: 38px;
  }
  .tdo-tab {
    font-size: 12px;
  }
  .tdo-tab small {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tdo-cell,
  .tdo-tab,
  .tk-btn {
    transition: none;
  }
}
