@font-face {
  font-family: "Ahron";
  src: url("./assets/theme/ahronbd.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "KhmerUI";
  src: url("./assets/theme/KhmerUIb.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #ebe4cf;
  --ink-soft: #b7ad92;
  --gold: #c8a666;
  --gold-soft: #8e6d38;
  --panel: rgba(18, 14, 9, 0.86);
  --panel-strong: rgba(14, 10, 6, 0.94);
  --line: rgba(200, 166, 102, 0.34);
  --ok: #95cd87;
  --danger: #d47a68;
  --shadow: 0 18px 36px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "KhmerUI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: #090806;
  line-height: 1.4;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -3;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  filter: saturate(0.95) contrast(1.08);
}

body::after {
  z-index: -2;
  background: linear-gradient(
      to bottom,
      rgba(5, 3, 2, 0.1) 0%,
      rgba(10, 7, 4, 0.62) 35%,
      rgba(7, 5, 3, 0.86) 65%,
      rgba(4, 3, 2, 0.97) 100%
    ),
    radial-gradient(circle at 15% 15%, rgba(255, 217, 148, 0.18), transparent 36%);
}

body[data-mode="landing"]::before {
  background-image: url("./assets/theme/bg.jpg");
}

body[data-fixed-tool="Item"]::before {
  background-image: url("./assets/theme/background-2.jpg");
}

body[data-fixed-tool="Quest"]::before {
  background-image: url("./assets/theme/background-3.jpg");
}

body[data-fixed-tool="Creature"]::before {
  background-image: url("./assets/theme/body-background.jpg");
}

body[data-mode="wiki"]::before {
  background-image: url("./assets/theme/footer-background.jpg");
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("./assets/theme/top-body-border.png"), url("./assets/theme/main_top.png"),
    url("./assets/theme/ornament-bar.jpg"), url("./assets/theme/vertical_divider.png");
  background-repeat: repeat-x, no-repeat, repeat-x, repeat-y;
  background-position: top center, top center, bottom center, center center;
  opacity: 0.42;
}

.app-shell {
  width: min(1500px, 96vw);
  margin: 0 auto;
  padding: 4.9rem 1rem 2.8rem;
  display: grid;
  gap: 0.95rem;
}

.top-menu-shell {
  display: block;
}

.hero {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.2rem 1.1rem;
  background: linear-gradient(to bottom, rgba(29, 22, 13, 0.86), rgba(12, 9, 5, 0.9));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.hero::before {
  top: 0;
  height: 26px;
  background: url("./assets/theme/news-top.png") center top / cover no-repeat;
  opacity: 0.52;
}

.hero::after {
  bottom: 0;
  height: 25px;
  background: url("./assets/theme/news-bot-shadow.png") center bottom / contain no-repeat;
  opacity: 0.55;
}

.eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #f2dfaf;
}

.eyebrow::before {
  content: "";
  width: 14px;
  height: 14px;
  background: url("./assets/theme/bullet.png") center / contain no-repeat;
}

h1 {
  margin: 0.28rem 0 0.26rem;
  font-family: "Ahron", Georgia, serif;
  font-size: clamp(1.78rem, 4.2vw, 2.85rem);
  letter-spacing: 0.03em;
  color: #f4deb0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.subtitle {
  margin: 0;
  max-width: 76ch;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.top-nav {
  margin: 0;
  position: fixed;
  top: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  border-top: 1px solid rgba(190, 147, 84, 0.32);
  border-bottom: 1px solid rgba(190, 147, 84, 0.26);
  border-left: 1px solid rgba(190, 147, 84, 0.2);
  border-right: 1px solid rgba(190, 147, 84, 0.2);
  background: linear-gradient(to bottom, rgba(34, 25, 13, 0.82), rgba(19, 14, 8, 0.8));
  padding: 0.4rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.44);
}

.top-nav-link {
  text-decoration: none;
  color: #ead8ad;
  font-family: "Ahron", Georgia, serif;
  letter-spacing: 0.03em;
  padding: 0.34rem 0.78rem;
  border: 1px solid transparent;
  background: transparent;
  position: relative;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease;
}

.top-nav-link::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  width: 2px;
  height: 16px;
  transform: translateY(-50%);
  background: url("./assets/theme/menu-seperator.png") center / cover no-repeat;
  opacity: 0.52;
}

.top-nav-link:last-child::after {
  display: none;
}

.top-nav-link:hover {
  transform: translateY(-1px);
  border-color: rgba(214, 176, 111, 0.55);
  color: #ffefc7;
}

.top-nav-link.is-active {
  border-color: rgba(219, 176, 104, 0.65);
  background: linear-gradient(to bottom, rgba(89, 61, 27, 0.52), rgba(44, 29, 12, 0.62));
  color: #ffe9bc;
}

body[data-mode="landing"] .top-nav {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

body[data-mode="landing"] .top-nav-link {
  border: 0;
  background: transparent;
  padding: 0.15rem 0.6rem;
}

body[data-mode="landing"] .top-nav-link.is-active {
  border: 0;
  background: transparent;
  color: #ffefc7;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(to bottom, var(--panel), var(--panel-strong));
  box-shadow: var(--shadow);
  padding: 0.9rem;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 28px;
  background: url("./assets/theme/titles-grad.png") center / cover no-repeat;
  opacity: 0.3;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.landing-intro-card {
  padding-top: 1.05rem;
  width: min(430px, calc(100vw - 1.2rem));
  max-width: 100%;
  margin-left: auto;
  margin-right: 0;
  justify-self: end;
}

.portal-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 1fr;
}

.portal-card {
  min-height: 150px;
  border: 1px solid rgba(201, 160, 87, 0.48);
  border-radius: 10px;
  text-decoration: none;
  color: #f3dfb4;
  display: grid;
  gap: 0.3rem;
  align-content: start;
  padding: 0.78rem;
  background: linear-gradient(to bottom, rgba(31, 22, 11, 0.72), rgba(15, 10, 5, 0.86));
  box-shadow: inset 0 0 0 1px rgba(255, 218, 150, 0.06), 0 8px 16px rgba(0, 0, 0, 0.35);
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
  position: relative;
  overflow: hidden;
}

.portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.27;
  pointer-events: none;
}

.portal-item::before {
  background-image: url("./assets/theme/background-2.jpg");
}

.portal-quest::before {
  background-image: url("./assets/theme/background-3.jpg");
}

.portal-creature::before {
  background-image: url("./assets/theme/body-background.jpg");
}

.portal-wiki::before {
  background-image: url("./assets/theme/footer-background.jpg");
}

.portal-card:hover {
  transform: translateY(-3px);
  border-color: rgba(239, 199, 122, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 163, 0.24), 0 15px 22px rgba(0, 0, 0, 0.44);
}

.portal-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #c9b78f;
}

.portal-card strong {
  font-family: "Ahron", Georgia, serif;
  font-size: 1.16rem;
  letter-spacing: 0.03em;
}

.portal-card span:last-child {
  font-size: 0.86rem;
  line-height: 1.36;
  color: #ceb98e;
}

.landing-footnote {
  border-style: dashed;
}

.auth-card {
  max-width: 820px;
}

.auth-tabs {
  display: inline-flex;
  border: 1px solid rgba(204, 160, 86, 0.48);
  background: rgba(19, 13, 7, 0.75);
}

.tab-btn {
  border: 0;
  border-right: 1px solid rgba(204, 160, 86, 0.35);
  border-radius: 0;
  color: #ead8ab;
  background: transparent;
  font-family: "Ahron", Georgia, serif;
  letter-spacing: 0.03em;
  padding: 0.44rem 0.92rem;
}

.tab-btn:last-child {
  border-right: 0;
}

.tab-btn.active {
  background: linear-gradient(to bottom, rgba(104, 69, 28, 0.45), rgba(65, 43, 17, 0.5));
}

.auth-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.42rem;
}

.input-row {
  display: grid;
  gap: 0.18rem;
}

.inline-label {
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c8b483;
}

.password-row {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.password-row .inline-label,
.password-row input {
  grid-column: 1 / 2;
}

.password-row button {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.46rem;
  font-size: 0.87rem;
  color: #cdb98f;
}

.checkbox-line input {
  width: auto;
}

.workspace {
  display: grid;
  gap: 0.82rem;
}

.grid {
  display: grid;
  gap: 0.7rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.62rem;
  flex-wrap: wrap;
}

h2 {
  margin: 0;
  font-family: "Ahron", Georgia, serif;
  letter-spacing: 0.03em;
  font-size: 1.03rem;
  color: #efd9a9;
}

label {
  color: #cbb78d;
  font-size: 0.83rem;
  display: grid;
  gap: 0.26rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(188, 147, 77, 0.35);
  background: rgba(8, 6, 4, 0.88);
  color: #f2e1b6;
  padding: 0.52rem 0.57rem;
}

input::placeholder,
textarea::placeholder {
  color: #89734d;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(236, 199, 126, 0.82);
  box-shadow: 0 0 0 2px rgba(234, 195, 118, 0.2);
}

button {
  border-radius: 8px;
  border: 1px solid rgba(202, 162, 94, 0.62);
  color: #f9e8bc;
  background: url("./assets/theme/button_bg.png") center / cover no-repeat,
    linear-gradient(to bottom, rgba(103, 68, 27, 0.65), rgba(55, 35, 14, 0.72));
  padding: 0.48rem 0.8rem;
  font-family: "Ahron", Georgia, serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.09);
}

.ghost {
  background: rgba(34, 24, 13, 0.82);
}

.action-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.fields {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.72rem;
}

.field-panel {
  border: 1px solid rgba(190, 148, 80, 0.37);
  border-radius: 10px;
  background: linear-gradient(to bottom, rgba(20, 14, 8, 0.78), rgba(9, 7, 4, 0.86));
  padding: 0.64rem;
}

.field-panel-title {
  margin: 0 0 0.55rem;
  font-family: "Ahron", Georgia, serif;
  letter-spacing: 0.03em;
  font-size: 0.92rem;
  color: #e9d6a8;
}

.field-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.56rem;
}

.field-note {
  margin: 0.2rem 0;
  color: var(--ink-soft);
}

.bitmask-editor {
  border: 1px solid rgba(190, 147, 80, 0.28);
  border-radius: 8px;
  background: rgba(8, 6, 4, 0.72);
  padding: 0.5rem;
}

.bitmask-current-value {
  margin: 0 0 0.4rem;
  font-size: 0.79rem;
  color: #e8d6aa;
}

.bitmask-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem 0.55rem;
}

.bitmask-option {
  display: flex;
  align-items: flex-start;
  gap: 0.34rem;
  color: #d6c193;
  font-size: 0.77rem;
}

.bitmask-option input {
  width: auto;
  margin-top: 0.12rem;
}

.bitmask-hidden-value {
  display: none;
}

#sqlOutput {
  margin-top: 0.62rem;
  min-height: 230px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.status {
  margin: 0.58rem 0 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.status.ok {
  color: var(--ok);
}

.history-list,
.wiki-list {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.53rem;
}

.history-item,
.wiki-item {
  border: 1px solid rgba(193, 152, 86, 0.34);
  border-radius: 10px;
  background: rgba(8, 6, 4, 0.82);
  padding: 0.58rem;
}

.history-meta,
.wiki-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.history-meta strong,
.wiki-meta strong {
  color: #f1ddae;
}

.history-meta span,
.wiki-type,
.wiki-desc,
.wiki-guidance,
.wiki-enum,
.wiki-plain-help,
.wiki-bitmask-intro,
.wiki-flag-list {
  color: #c8b58c;
}

.wiki-guidance,
.wiki-bitmask-help {
  border: 1px solid rgba(184, 142, 74, 0.24);
  background: rgba(17, 12, 7, 0.68);
  border-radius: 8px;
  padding: 0.44rem 0.5rem;
  margin-top: 0.45rem;
}

.wiki-enum,
.wiki-plain-help,
.wiki-desc,
.wiki-bitmask-intro,
.wiki-flag-list {
  margin-top: 0.45rem;
  font-size: 0.82rem;
}

.wiki-flag-list {
  padding-left: 1rem;
}

.history-sql {
  margin-top: 0.5rem;
  padding: 0.42rem;
  border-radius: 8px;
  border: 1px dashed rgba(185, 147, 84, 0.35);
  background: rgba(0, 0, 0, 0.58);
  max-height: 130px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.79rem;
  color: #decda4;
}

@media (max-width: 1030px) {
  .field-panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .portal-grid,
  .grid.two,
  .field-panel-grid {
    grid-template-columns: 1fr;
  }

  .top-nav {
    position: fixed;
    top: 0.4rem;
    left: 0.5rem;
    right: 0.5rem;
    transform: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-nav-link::after {
    display: none;
  }

  .bitmask-options {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: calc(100vw - 1rem);
    padding: 5.4rem 0.6rem 2rem;
  }
}
