.tta-qimen-widget {
  --tta-night: #2a1710;
  --tta-night-2: #4a1b17;
  --tta-brown: #5a341f;
  --tta-brown-soft: #7b5b3a;
  --tta-red: #b91f32;
  --tta-gold: #d7aa3a;
  --tta-gold-soft: #f4d489;
  --tta-silver: #c7ccd3;
  --tta-white: #fffaf0;
  --tta-ink: #1b1712;
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(215, 170, 58, 0.46);
  border-radius: 10px;
  background:
    radial-gradient(circle at 14% 10%, rgba(215, 170, 58, 0.18), transparent 25%),
    radial-gradient(circle at 86% 18%, rgba(199, 204, 211, 0.2), transparent 24%),
    linear-gradient(135deg, #fffaf0 0%, #f1dfc3 46%, #d6b98a 100%);
  background-color: var(--tta-white);
  color: var(--tta-ink);
  font-family: inherit;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
}

.tta-qimen-widget::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: radial-gradient(circle, rgba(123, 91, 58, 0.22) 0 1.2px, transparent 1.7px);
  background-size: 96px 76px;
}

.tta-qimen-widget > * {
  position: relative;
  z-index: 1;
}

.tta-qimen-global-language {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: grid;
  gap: 5px;
  width: min(260px, calc(100% - 36px));
  color: var(--tta-brown);
  font-size: 13px;
  font-weight: 850;
}

.tta-qimen-global-language span {
  color: var(--tta-brown);
}

.tta-qimen-global-language select {
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid rgba(90, 52, 31, 0.32);
  border-radius: 5px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--tta-ink);
  font: inherit;
  font-weight: 800;
}

.tta-qimen-global-language select:focus {
  outline: 2px solid rgba(215, 170, 58, 0.28);
  border-color: var(--tta-gold);
}

.tta-qimen-hero {
  display: grid;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
  padding-right: 290px;
}

.tta-qimen-brand-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  width: min(560px, 100%);
  min-height: 108px;
  padding: 16px 18px;
  border: 1px solid rgba(183, 139, 55, 0.58);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 14px 34px rgba(123, 91, 58, 0.16), inset 0 0 0 1px rgba(255,255,255,0.72);
}

.tta-qimen-brand-card img {
  width: 150px;
  max-height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.32));
}

.tta-qimen-brand-card p,
.tta-qimen-brand-card span {
  margin: 0;
  color: var(--tta-brown-soft);
  font-weight: 800;
  letter-spacing: 0;
}

.tta-qimen-brand-card h2 {
  margin: 6px 0 0;
  color: #9a6918;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  letter-spacing: 0;
}

.tta-qimen-brand-card h2 {
  font-size: 25px;
}

.tta-qimen-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(215, 170, 58, 0.55);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
  color: var(--tta-ink);
  box-shadow: 0 12px 28px rgba(123, 91, 58, 0.12);
}

.tta-qimen-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.tta-qimen-tabs button {
  min-height: 40px;
  border: 1px solid rgba(183, 139, 55, 0.55);
  border-radius: 6px;
  padding: 0 16px;
  background: rgba(255, 250, 240, 0.86);
  color: var(--tta-brown);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.tta-qimen-tabs button.is-active {
  background: linear-gradient(135deg, var(--tta-red), #7d1624);
  color: #fff;
  border-color: rgba(125, 22, 36, 0.72);
  box-shadow: 0 8px 20px rgba(185, 31, 50, 0.18);
}

.tta-qimen-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.tta-qimen-fields-main {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.tta-qimen-fields-time {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  align-items: end;
}

.tta-qimen-form.is-destiny .tta-qimen-fields-time {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.tta-qimen-form.is-destiny .tta-qimen-profile-name-field,
.tta-qimen-form.is-destiny .tta-qimen-birth-place-field {
  grid-column: span 3;
}

.tta-qimen-form.is-destiny .tta-qimen-gender-field,
.tta-qimen-form.is-destiny .tta-qimen-time-mode-field {
  grid-column: span 1;
}

.tta-qimen-form.is-destiny .tta-qimen-profile-name-field,
.tta-qimen-form.is-destiny .tta-qimen-gender-field {
  order: 1;
}

.tta-qimen-form.is-destiny .tta-qimen-birth-place-field,
.tta-qimen-form.is-destiny .tta-qimen-time-mode-field {
  order: 2;
}

.tta-qimen-birth-place-field {
  position: relative;
}

.tta-qimen-city-suggestions {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid rgba(173, 136, 68, 0.38);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 0 14px 28px rgba(98, 68, 36, 0.18);
}

.tta-qimen-city-suggestion,
.tta-qimen-city-search-state {
  width: 100%;
  padding: 10px 12px;
  color: #fff;
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(255, 250, 240, 0.18);
  background: linear-gradient(135deg, #a91427, #811421);
}

.tta-qimen-form .tta-qimen-city-suggestion {
  display: block;
  min-height: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.tta-qimen-form .tta-qimen-city-suggestion:hover,
.tta-qimen-form .tta-qimen-city-suggestion:focus {
  background: linear-gradient(135deg, #c31f36, #941b2a);
  color: #fff;
  outline: none;
}

.tta-qimen-city-suggestion strong,
.tta-qimen-city-suggestion span {
  display: block;
}

.tta-qimen-city-suggestion strong {
  color: #fff;
  font-size: 14px;
  font-weight: 850;
}

.tta-qimen-city-suggestion span,
.tta-qimen-city-search-state {
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 650;
}

.tta-qimen-form.is-destiny label:not(.tta-qimen-destiny-field):not(.tta-qimen-feng-shui-field) {
  order: 3;
}

.tta-qimen-door-location-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.tta-qimen-door-location-row input,
.tta-qimen-door-location-row select {
  min-height: 42px;
  text-align: center;
  font-weight: 800;
}

.tta-qimen-door-location-field {
  grid-column: span 2;
}

.tta-qimen-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

.tta-qimen-form label.tta-qimen-year-hidden {
  display: none !important;
}

.tta-qimen-form label span {
  color: var(--tta-brown);
}

.tta-qimen-form input,
.tta-qimen-form select,
.tta-qimen-form textarea {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  border: 1px solid rgba(90, 52, 31, 0.32);
  border-radius: 5px;
  padding: 8px 10px;
  background: #fff;
  color: var(--tta-ink);
  font: inherit;
}

.tta-qimen-form textarea {
  min-height: 70px;
  resize: vertical;
}

.tta-qimen-form input:focus,
.tta-qimen-form select:focus,
.tta-qimen-form textarea:focus {
  outline: 2px solid rgba(215, 170, 58, 0.28);
  border-color: var(--tta-gold);
}

.tta-qimen-form button {
  justify-self: start;
  min-height: 42px;
  border: 1px solid rgba(90, 52, 31, 0.24);
  border-radius: 5px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--tta-red), #7d1624);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(185, 31, 50, 0.22);
}

.tta-qimen-form button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tta-qimen-message {
  min-height: 20px;
  margin: 0;
  color: #6e665c;
  font-size: 14px;
}

.tta-qimen-message.is-error {
  color: var(--tta-red);
}

.tta-qimen-three-victories-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(215, 170, 58, 0.55);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 12px 28px rgba(123, 91, 58, 0.12);
}

.tta-qimen-three-victories-form {
  display: grid;
  gap: 14px;
}

.tta-qimen-three-head h3,
.tta-three-personal h4,
.tta-three-calendar h4 {
  margin: 0;
  color: var(--tta-brown);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}

.tta-qimen-three-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.tta-qimen-three-name-field,
.tta-qimen-three-place-field {
  grid-column: span 3;
}

.tta-qimen-three-gender-field,
.tta-qimen-three-time-mode-field {
  grid-column: span 1;
}

.tta-qimen-three-fields label {
  position: relative;
  display: grid;
  gap: 6px;
  color: var(--tta-brown);
  font-size: 13px;
  font-weight: 850;
}

.tta-qimen-three-fields input,
.tta-qimen-three-fields select {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  border: 1px solid rgba(90, 52, 31, 0.32);
  border-radius: 5px;
  padding: 8px 10px;
  background: #fff;
  color: var(--tta-ink);
  font: inherit;
  font-weight: 750;
}

.tta-qimen-three-fields input:focus,
.tta-qimen-three-fields select:focus {
  outline: 2px solid rgba(215, 170, 58, 0.28);
  border-color: var(--tta-gold);
}

.tta-qimen-three-victories-form button[type="submit"],
.tta-three-calendar-head button {
  position: relative;
  z-index: 30;
  min-height: 42px;
  border: 1px solid rgba(90, 52, 31, 0.24);
  border-radius: 5px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--tta-red), #7d1624);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 8px 20px rgba(185, 31, 50, 0.18);
}

.tta-three-calendar-head button:hover,
.tta-three-month-day:hover,
.tta-three-activation:hover,
.tta-three-more:hover {
  cursor: pointer;
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.tta-qimen-three-victories-form button[type="submit"] {
  justify-self: start;
  width: auto;
}

.tta-qimen-three-message,
.tta-qimen-three-initial {
  margin: 0;
  color: #6e665c;
  font-size: 14px;
  font-weight: 750;
}

.tta-qimen-three-message.is-error {
  color: var(--tta-red);
}

.tta-qimen-three-results {
  display: grid;
  gap: 16px;
}

.tta-three-personal {
  display: grid;
  gap: 12px;
}

.tta-three-nine-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-column: 2 / span 3;
  grid-row: 2 / span 3;
  z-index: 2;
  gap: 0;
  background: rgba(183, 139, 55, 0.62);
}

.tta-three-nine-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: url("thien_tam_logo.png") center / 48% auto no-repeat;
  opacity: 0.085;
  pointer-events: none;
}

.tta-three-board-frame {
  position: relative;
  justify-self: center;
  display: grid;
  grid-template-columns: 56px repeat(3, minmax(0, 1fr)) 56px;
  grid-template-rows: 56px repeat(3, minmax(0, 1fr)) 56px;
  width: min(760px, 100%);
  aspect-ratio: 1 / 1;
  border: 0;
  background: #b99228;
  box-shadow: 0 18px 38px rgba(123, 91, 58, 0.12);
  overflow: hidden;
}

.tta-three-frame-band {
  position: relative;
  z-index: 0;
}

.tta-three-frame-band-wood {
  grid-column: 1 / span 2;
  grid-row: 1 / span 3;
  background: #2f9365;
}

.tta-three-frame-band-metal {
  grid-column: 4 / span 2;
  grid-row: 3 / span 3;
  background: #969da5;
}

.tta-three-frame-cell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  text-shadow: 0 2px 3px rgba(0,0,0,0.22);
  white-space: normal;
}

.tta-three-frame-cell .is-strong {
  font-weight: 980;
}

.tta-three-frame-cell .is-soft {
  font-weight: 720;
  opacity: 0.82;
}

.tta-three-frame-palace-4 {
  grid-column: 1 / span 2;
  grid-row: 1;
}

.tta-three-frame-palace-9 {
  grid-column: 3;
  grid-row: 1;
}

.tta-three-frame-palace-2 {
  grid-column: 4 / span 2;
  grid-row: 1;
}

.tta-three-frame-palace-3 {
  grid-column: 1;
  grid-row: 3;
  flex-direction: column;
  gap: 3px;
  line-height: 1.03;
}

.tta-three-frame-palace-7 {
  grid-column: 5;
  grid-row: 3;
  flex-direction: column;
  gap: 3px;
  line-height: 1.03;
}

.tta-three-frame-palace-8 {
  grid-column: 1 / span 2;
  grid-row: 5;
}

.tta-three-frame-palace-1 {
  grid-column: 3;
  grid-row: 5;
}

.tta-three-frame-palace-6 {
  grid-column: 4 / span 2;
  grid-row: 5;
}

.tta-three-frame-cell.wood {
  background: transparent;
}

.tta-three-frame-cell.fire {
  background: #d9362f;
}

.tta-three-frame-cell.earth {
  background: #b99228;
}

.tta-three-frame-cell.metal {
  background: transparent;
}

.tta-three-frame-cell.water {
  background: #2f7dbb;
}

.tta-three-palace {
  position: relative;
  z-index: 1;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid rgba(183, 139, 55, 0.62);
  display: grid;
  align-content: flex-start;
  gap: 8px;
  background: rgba(250, 249, 246, 0.94);
}

.tta-three-palace-5 {
  display: grid;
  place-items: center;
  background: rgba(250, 249, 246, 0.94);
}

.tta-three-palace-direction {
  color: var(--tta-brown-soft);
  font-size: 12px;
  font-weight: 900;
}

.tta-three-chip-stack {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.tta-three-chip,
.tta-three-summary-item {
  border: 1px solid color-mix(in srgb, var(--three-color), transparent 30%);
  border-left: 4px solid var(--three-color);
  border-radius: 5px;
  padding: 5px 8px;
  background: color-mix(in srgb, var(--three-color), white 88%);
  color: color-mix(in srgb, var(--three-color), black 28%);
  font-weight: 900;
  line-height: 1.12;
}

.tta-three-chip {
  width: max-content;
  max-width: 100%;
}

.tta-three-center-profile {
  display: grid;
  gap: 6px;
  max-width: 90%;
  color: var(--tta-brown);
  text-align: center;
  line-height: 1.2;
}

.tta-three-center-profile strong {
  color: var(--tta-red);
  font-size: clamp(15px, 1.35vw, 20px);
  font-weight: 780;
}

.tta-three-center-profile span {
  color: var(--tta-ink);
  font-size: clamp(13px, 1.35vw, 17px);
  font-weight: 900;
}

.tta-three-center-profile small {
  color: var(--tta-brown-soft);
  font-size: 12px;
  font-weight: 850;
}

.tta-three-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tta-three-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.tta-three-calendar {
  position: relative;
  z-index: 20;
  display: grid;
  gap: 12px;
  pointer-events: auto;
}

.tta-three-calendar-head {
  position: relative;
  z-index: 25;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.tta-three-range {
  color: var(--tta-brown-soft);
  font-size: 15px;
  font-weight: 900;
}

.tta-three-calendar-head div {
  position: relative;
  z-index: 26;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.tta-three-month-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tta-three-month-control-wrap {
  display: grid !important;
  gap: 4px;
  justify-items: end;
}

.tta-three-processing {
  margin: 0;
  color: var(--tta-red);
  font-size: 12px;
  font-weight: 900;
}

.tta-qimen-three-victories-panel.is-three-loading,
.tta-qimen-three-victories-panel.is-three-loading * {
  cursor: wait !important;
}

.tta-three-month-controls select {
  min-width: 92px;
  min-height: 38px;
  border: 1px solid rgba(90, 52, 31, 0.28);
  border-radius: 5px;
  padding: 4px 10px;
  background: #fffaf0;
  color: var(--tta-brown);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.tta-three-week {
  position: relative;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 10px;
}

.tta-three-day {
  min-height: 190px;
  padding: 10px;
  border: 1px solid rgba(183, 139, 55, 0.38);
  border-radius: 8px;
  background: rgba(255,255,255,0.58);
}

.tta-three-day.is-today {
  border-color: var(--tta-red);
  box-shadow: inset 0 0 0 2px rgba(185, 31, 50, 0.62), 0 8px 18px rgba(185, 31, 50, 0.1);
}

.tta-three-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--tta-brown);
  font-weight: 900;
}

.tta-three-day-head strong {
  font-size: 24px;
}

.tta-three-activation,
.tta-three-more {
  width: 100%;
  margin: 0 0 7px;
  border: 1px solid color-mix(in srgb, var(--three-color, #b91f32), transparent 45%);
  border-radius: 7px;
  padding: 8px;
  background: color-mix(in srgb, var(--three-color, #b91f32), white 88%);
  color: color-mix(in srgb, var(--three-color, #b91f32), black 25%);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.tta-three-activation strong,
.tta-three-activation small {
  display: block;
}

.tta-three-activation strong span {
  color: #d49b16;
}

.tta-three-more {
  color: var(--tta-red);
  background: #fff8ea;
  font-weight: 850;
}

.tta-three-empty {
  color: #9a8c78;
}

.tta-three-month-calendar {
  display: grid;
  gap: 10px;
}

.tta-three-month-weekdays,
.tta-three-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.tta-three-month-weekdays span {
  color: var(--tta-brown-soft);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.tta-three-month-blank,
.tta-three-month-day {
  min-height: 72px;
}

.tta-three-month-day {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(183, 139, 55, 0.35);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--tta-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tta-three-month-day.is-past {
  cursor: not-allowed;
  opacity: 0.38;
  filter: grayscale(0.35);
}

.tta-three-month-day:hover {
  border-color: rgba(185, 31, 50, 0.45);
  background: #fff4dc;
}

.tta-three-month-day.is-today {
  border-color: var(--tta-red);
  box-shadow: inset 0 0 0 2px rgba(185, 31, 50, 0.55);
}

.tta-three-month-day strong {
  color: var(--tta-brown);
  font-size: 15px;
}

.tta-three-month-day small {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tta-three-month-day small span {
  border: 1px solid color-mix(in srgb, var(--three-color), transparent 40%);
  border-radius: 999px;
  padding: 2px 5px;
  background: color-mix(in srgb, var(--three-color), white 88%);
  color: color-mix(in srgb, var(--three-color), black 25%);
  font-size: 10px;
  font-weight: 900;
}

.tta-three-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.tta-three-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 20, 12, 0.38);
}

.tta-three-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(640px, calc(100vw - 30px));
  max-height: min(780px, calc(100vh - 30px));
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(183, 139, 55, 0.55);
  border-radius: 10px;
  padding: 18px;
  background: #fffaf0;
  color: var(--tta-ink);
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
}

.tta-three-modal-close {
  float: right;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.tta-three-modal h3,
.tta-three-modal h4 {
  margin: 8px 0;
  color: var(--tta-red);
}

.tta-three-modal-stars {
  color: #d49b16;
  font-weight: 900;
}

.tta-three-modal dl,
.tta-three-structure {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tta-three-modal dl div,
.tta-three-structure div {
  padding: 8px;
  border: 1px solid rgba(183, 139, 55, 0.28);
  border-radius: 6px;
  background: rgba(255,255,255,0.58);
}

.tta-three-modal dt,
.tta-three-structure span {
  display: block;
  color: var(--tta-brown-soft);
  font-size: 14px;
  font-weight: 850;
}

.tta-three-modal dd {
  margin: 0;
  color: #19130f;
  font-size: 20px;
  font-weight: 900;
}

.tta-three-modal p,
.tta-three-modal li {
  color: #2f231b;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 400;
}

.tta-three-modal h4 + p {
  font-weight: 400;
}

.tta-three-modal ul {
  margin: 6px 0 14px;
  padding-left: 22px;
}

.tta-three-modal-note {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(183, 139, 55, 0.28);
}

.tta-three-modal-note em {
  color: var(--tta-brown);
  font-style: italic;
  font-weight: 850;
}

.tta-qimen-question-field {
  display: none;
}

.tta-qimen-destiny-manager {
  display: none;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(183, 139, 55, 0.4);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.72);
}

.tta-qimen-form.is-destiny .tta-qimen-destiny-manager:not([hidden]) {
  display: grid;
}

.tta-qimen-destiny-manager[hidden] {
  display: none !important;
}

.tta-qimen-save-profile {
  justify-self: start;
}

.tta-qimen-save-note,
.tta-qimen-empty-profiles {
  margin: 0;
  color: #746759;
  font-size: 13px;
}

.tta-qimen-profile-list {
  display: grid;
  gap: 8px;
}

.tta-qimen-profile-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, auto) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #dfd2b8;
  border-radius: 6px;
  background: #fffaf0;
}

.tta-qimen-profile-row strong {
  color: #9a6918;
}

.tta-qimen-profile-row button {
  min-height: 32px;
  padding: 0 10px;
  box-shadow: none;
}

.tta-qimen-result {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(183, 139, 55, 0.42);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 18px 48px rgba(123, 91, 58, 0.14), inset 0 0 0 1px rgba(255,255,255,0.72);
}

.tta-qimen-frame {
  width: 100%;
  min-height: 1160px;
  border: 0;
  background: transparent;
  display: block;
}

.tta-qimen-debug {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(90, 52, 31, 0.22);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
  color: #2a1710;
  font-size: 12px;
}

.tta-qimen-debug summary {
  cursor: pointer;
  color: #7b5b3a;
  font-weight: 900;
}

.tta-qimen-debug-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 12px;
  margin: 10px 0;
}

.tta-qimen-debug-grid span {
  color: #7b5b3a;
  font-weight: 750;
}

.tta-qimen-debug-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.tta-qimen-debug table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tta-qimen-debug th,
.tta-qimen-debug td {
  padding: 5px 6px;
  border-top: 1px solid rgba(90, 52, 31, 0.16);
  overflow-wrap: anywhere;
  text-align: left;
}

.tta-qimen-debug th {
  color: #7b5b3a;
  font-weight: 900;
}

@media (max-width: 900px) {
  .tta-qimen-global-language {
    position: relative;
    top: auto;
    right: auto;
    width: min(280px, 100%);
    margin: 0 0 12px auto;
  }

  .tta-qimen-hero {
    padding-right: 0;
  }

  .tta-qimen-fields,
  .tta-qimen-fields-main,
  .tta-qimen-fields-time {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tta-qimen-form.is-destiny .tta-qimen-profile-name-field,
  .tta-qimen-form.is-destiny .tta-qimen-birth-place-field,
  .tta-qimen-form.is-destiny .tta-qimen-gender-field,
  .tta-qimen-form.is-destiny .tta-qimen-time-mode-field {
    grid-column: span 1;
  }

  .tta-qimen-frame {
    min-height: 1280px;
  }

  .tta-qimen-door-location-field {
    grid-column: span 2;
  }
}

@media (max-width: 560px) {
  .tta-qimen-widget {
    padding: 14px;
  }

  .tta-qimen-brand-card {
    grid-template-columns: 1fr;
  }

  .tta-qimen-brand-card img {
    width: 130px;
  }

  .tta-qimen-fields,
  .tta-qimen-fields-main,
  .tta-qimen-fields-time {
    grid-template-columns: 1fr;
  }

  .tta-qimen-door-location-field {
    grid-column: auto;
  }

  .tta-qimen-form.is-destiny .tta-qimen-profile-name-field,
  .tta-qimen-form.is-destiny .tta-qimen-birth-place-field,
  .tta-qimen-form.is-destiny .tta-qimen-gender-field,
  .tta-qimen-form.is-destiny .tta-qimen-time-mode-field {
    grid-column: auto;
  }

  .tta-qimen-form button {
    width: 100%;
  }
}

.tta-qimen-strategy-panel {
  display: grid;
  gap: 14px;
}

.tta-qimen-strategy-panel[hidden],
.tta-qimen-three-victories-panel[hidden],
.tta-qimen-three-results[hidden],
.tta-qimen-form[hidden],
.tta-qimen-strategy-results[hidden],
.tta-qimen-check-group[hidden] {
  display: none !important;
}

.tta-qimen-strategy-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(215, 170, 58, 0.55);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 12px 28px rgba(123, 91, 58, 0.12);
}

.tta-qimen-strategy-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.tta-qimen-strategy-head h3 {
  margin: 0 0 4px;
  color: #7a411d;
  font-size: 22px;
  font-weight: 900;
}

.tta-qimen-strategy-head p {
  margin: 0;
  color: #6d5b46;
  font-weight: 650;
}

.tta-qimen-strategy-grid,
.tta-qimen-filter-grid {
  display: grid;
  gap: 12px;
}

.tta-qimen-strategy-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.tta-qimen-filter-grid {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
}

.tta-qimen-strategy-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 850;
  color: var(--tta-brown);
}

.tta-qimen-strategy-form input,
.tta-qimen-strategy-form select {
  min-height: 42px;
  border: 1px solid rgba(82, 58, 34, 0.28);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--tta-ink);
  font: inherit;
  font-weight: 750;
}

.tta-qimen-strategy-form select[multiple] {
  min-height: 142px;
  padding: 6px;
}

.tta-qimen-strategy-form select[multiple] option {
  padding: 5px 6px;
  border-radius: 4px;
}

.tta-qimen-strategy-form select[multiple] option:checked {
  background: linear-gradient(135deg, var(--tta-red), #7d1624);
  color: #fff;
}

.tta-qimen-strategy-types {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 12px;
  border: 1px solid rgba(183, 139, 55, 0.32);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.42);
}

.tta-qimen-strategy-types label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--tta-ink);
}

.tta-qimen-strategy-form button[type="submit"],
.tta-qimen-strategy-row button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--tta-red), #8f1525);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.tta-qimen-strategy-message.is-error {
  color: #b91f32;
}

.tta-qimen-strategy-results {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(215, 170, 58, 0.46);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
}

.tta-qimen-strategy-summary,
.tta-qimen-strategy-empty {
  margin: 0;
  color: #6d4f30;
  font-weight: 850;
}

.tta-qimen-strategy-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(121, 91, 48, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
}

.tta-qimen-strategy-row strong,
.tta-qimen-strategy-row span {
  display: block;
}

.tta-qimen-strategy-row strong {
  color: #1b1712;
  font-size: 15px;
}

.tta-qimen-strategy-row span,
.tta-qimen-strategy-row p {
  margin: 0;
  color: #6c5d4c;
  font-weight: 700;
}

@media (max-width: 860px) {
  .tta-qimen-strategy-head,
  .tta-qimen-strategy-grid,
  .tta-qimen-filter-grid,
  .tta-qimen-strategy-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .tta-qimen-three-fields,
  .tta-three-summary,
  .tta-three-week,
  .tta-three-modal dl,
  .tta-three-structure {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tta-three-week {
    overflow-x: auto;
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 1fr);
    grid-template-columns: none;
    padding-bottom: 8px;
  }

  .tta-three-frame-cell {
    font-size: 15px;
  }
}

@media (max-width: 560px) {
  .tta-qimen-three-fields,
  .tta-three-summary,
  .tta-three-modal dl,
  .tta-three-structure {
    grid-template-columns: 1fr;
  }

  .tta-three-calendar-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tta-three-modal {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 86vh;
    transform: none;
    border-radius: 14px 14px 0 0;
  }

  .tta-three-board-frame {
    --three-rim: 42px;
  }

  .tta-three-frame-cell {
    padding: 5px;
    font-size: 12px;
  }

  .tta-three-palace {
    padding: 8px;
  }

  .tta-three-month-calendar {
    overflow-x: auto;
  }

  .tta-three-month-weekdays,
  .tta-three-month-grid {
    min-width: 680px;
  }
}

.tta-qimen-check-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: flex-start;
  gap: 7px;
  min-height: 142px;
  max-height: 190px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(82, 58, 34, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.74);
}

.tta-qimen-check-group.compact {
  min-height: 104px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tta-qimen-check-group.formations {
  max-height: 230px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tta-qimen-check-chip {
  display: inline-flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 0 !important;
  min-height: 30px;
  margin: 0;
  cursor: pointer;
}

.tta-qimen-check-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tta-qimen-check-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid rgba(121, 91, 48, 0.24);
  border-radius: 6px;
  background: #fffaf0;
  color: #3b2a1f !important;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.tta-qimen-check-chip:hover span {
  border-color: rgba(185, 31, 50, 0.35);
  background: #fff4dc;
}

.tta-qimen-check-chip input:checked + span {
  border-color: rgba(125, 22, 36, 0.84);
  background: linear-gradient(135deg, var(--tta-red), #7d1624);
  color: #fff !important;
  box-shadow: 0 5px 13px rgba(185, 31, 50, 0.16);
}

.tta-qimen-multi-select {
  position: relative;
}

.tta-qimen-multi-button {
  width: 100%;
  min-height: 42px;
  padding: 8px 34px 8px 10px;
  border: 1px solid rgba(82, 58, 34, 0.28) !important;
  border-radius: 6px !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: var(--tta-ink) !important;
  text-align: left;
  font: inherit;
  font-weight: 800 !important;
  box-shadow: none !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tta-qimen-multi-button::after {
  content: "⌄";
  position: absolute;
  right: 12px;
  color: #72543a;
}

.tta-qimen-multi-select > .tta-qimen-check-group {
  position: absolute;
  z-index: 80;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  min-height: 0;
  max-height: none;
  overflow: visible;
  box-shadow: 0 16px 34px rgba(98, 68, 36, 0.2);
}

.tta-qimen-multi-select.formations > .tta-qimen-check-group,
.tta-qimen-multi-select[data-filter-name="formations"] > .tta-qimen-check-group {
  max-height: 320px;
  overflow-y: auto;
}

.tta-qimen-multi-select[data-filter-name="spirits"] > .tta-qimen-check-group,
.tta-qimen-multi-select[data-filter-name="stars"] > .tta-qimen-check-group {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 100%;
}


.tta-qimen-widget {
  overflow: visible;
}

.tta-qimen-strategy-panel .tta-qimen-multi-select > .tta-qimen-check-group {
  position: absolute;
  z-index: 120;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  margin-top: 0;
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

.tta-qimen-strategy-panel .tta-qimen-multi-select[data-filter-name="formations"] > .tta-qimen-check-group {
  max-height: min(70vh, 360px);
  overflow-y: auto;
}

.tta-qimen-multi-select.is-open .tta-qimen-multi-button {
  border-color: rgba(185, 31, 50, 0.42) !important;
}
