:root {
  color-scheme: dark;
  --ink: #100e10;
  --cream: #f1e7dc;
  --muted: #c3b1a6;
  --gold: #d3ad73;
  --rule: #d3ad7328;
  --red: #9e2835;
  --photo: url("assets/farm-valley.png");
  font-family: "Noto Sans Thai", sans-serif;
  color: var(--cream);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p, dl { margin: 0; }
kbd, b, td { font-variant-numeric: tabular-nums; }
kbd {
  display: inline-grid;
  place-items: center;
  padding: 1px 6px;
  min-height: 1.6em;
  border: 1px solid #cdaa7666;
  border-radius: 6px;
  color: var(--gold);
  font: 600 .9em "Chakra Petch", sans-serif;
}

.scene {
  --crop: 0%;
  min-height: 100svh;
  background: linear-gradient(180deg, #170e1366, transparent 36%, #100b11b8), var(--photo) var(--crop) center / cover;
}
.scene[data-job="ore_valentine"] { --crop: 53%; }
.scene[data-job="lumber_valentine"] { --crop: 100%; }
.zone-hud {
  position: fixed;
  top: clamp(14px, 5vh, 56px);
  right: clamp(12px, 4.2vw, 76px);
  width: min(338px, calc(100vw - 24px));
  padding: 15px 17px 13px;
  border: 1px solid #a63846a0;
  border-radius: 24px 24px 26px 26px;
  background: radial-gradient(ellipse at top left, #4c1c24a6, transparent 72%), #151013f5;
  box-shadow: 0 10px 36px #0a0608a3, inset 0 1px #efa78517;
  animation: arrive .24s ease-out both;
}
.hud-head { display: flex; align-items: center; gap: 9px; }
.hud-name { flex: 1; min-width: 0; }
.hud-name > span { color: var(--gold); font-size: 11px; }
.hud-name h1 { line-height: 1.24; font-weight: 700; font-size: 18px; }
.location-mark {
  flex: 0 0 26px;
  height: 26px;
  border: 1px solid #d3ad7360;
  border-radius: 50%;
  background: radial-gradient(circle, #e0bb7d 0 2px, transparent 3px), radial-gradient(circle, transparent 6px, #b68a595a 7px, transparent 8px);
}
.detail-trigger, .preview-tools button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: #100b1094;
  white-space: nowrap;
  font-size: 11px;
}
.detail-trigger:hover, .preview-tools button:hover { border-color: #be905c99; background: #351a20; }
.hud-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--rule);
  margin-top: 11px;
  padding-top: 10px;
}
.stock, .availability > div { display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 11px; }
.stock > span:nth-child(2) { flex: 1; line-height: 1.25; }
.stock small { display: block; color: var(--muted); margin-top: 3px; }
.stock b, .availability b { font: 600 16px "Chakra Petch", sans-serif; white-space: nowrap; }
.availability { padding-left: 10px; border-left: 1px solid var(--rule); }
.availability small { color: var(--muted); font-size: 11px; }
progress { display: block; width: 100%; height: 3px; margin-top: 5px; border: 0; border-radius: 99px; overflow: hidden; background: #38232a; }
progress::-webkit-progress-bar { background: #38232a; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--red), var(--gold)); }

.resource-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #ceaa7540;
  border-radius: 50%;
  color: #d3ad73;
  background: radial-gradient(circle at 46% 35%, #5c3f32, #20171a 70%);
}
.resource-icon::before { content: ""; display: block; width: 14px; height: 13px; }
.herb::before { transform: rotate(-33deg); border-radius: 80% 0; background: linear-gradient(28deg, #99804e 45%, #382824 48%, #382824 53%, #d3ad73 56%); }
.tonic::before { border-radius: 3px; width: 8px; height: 11px; background: #cfad73; box-shadow: 0 -4px 0 -2px #f0d6a9; }
.stone::before, .ore::before { clip-path: polygon(12% 32%, 47% 5%, 84% 22%, 100% 61%, 68% 92%, 18% 86%, 0 61%); background: linear-gradient(142deg, #d1bab0 45%, #826f67 48%); }
.ore::before { background: linear-gradient(142deg, #c59667 45%, #8e533b 48%); }
.wood::before { border-radius: 3px 6px 6px 3px; height: 8px; transform: rotate(-27deg); background: linear-gradient(#d4a367, #8f5c3e); border-right: 3px solid #e7bc8c; }

.detail {
  width: min(798px, calc(100vw - 26px));
  max-width: none;
  max-height: calc(100dvh - 26px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #a7494f;
  border-radius: 28px;
  background: #151114;
  color: var(--cream);
  box-shadow: 0 20px 100px #080405d9, 0 0 40px #65212e33;
}
.detail[open] { animation: arrive .24s cubic-bezier(.18,.78,.35,1) both; }
.detail::backdrop { background: #0f090dd1; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.42fr); }
.detail-info {
  isolation: isolate;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 27px 24px 20px;
  border-right: 1px solid var(--rule);
  background: #211316;
}
.detail-photo {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, #1c1014e0, #1c101425 42%, #211316 83%),
    var(--photo) var(--crop) 44% / auto 115% no-repeat;
}
.detail-heading > span { color: #efd09d; font: 600 10px "Chakra Petch", "Noto Sans Thai", sans-serif; letter-spacing: .07em; }
.detail-heading i { display: inline-block; margin: 0 4px 2px; width: 4px; height: 4px; transform: rotate(45deg); background: var(--gold); }
.detail-heading h2 { margin: 7px 0 4px; line-height: 1.26; font-size: clamp(21px, 3.2vw, 30px); }
.detail-heading p { color: #eee0d1; font-size: 12px; line-height: 1.65; text-shadow: 0 1px 5px #150608; }
.survey {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 49px 0 13px;
  padding: 7px 12px 7px 7px;
  width: fit-content;
  border-radius: 99px;
  background: #160f14ed;
  border: 1px solid #d3ad7357;
}
.survey-ring { isolation: isolate; position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: conic-gradient(#e4bd83 var(--ready), #57353c 0); }
.survey-ring::before { content: ""; z-index: -1; position: absolute; inset: 2px; border-radius: 50%; background: #24181c; }
.survey-ring b { font: 600 17px "Chakra Petch", sans-serif; color: #f1d1a0; }
.survey strong, .survey span { display: block; font-size: 11px; line-height: 1.35; }
.survey span { color: var(--muted); }
.facts { margin-top: auto; padding-top: 5px; }
.facts > div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--rule); font-size: 11px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--cream); text-align: right; }
.detail-rewards { min-width: 0; display: flex; flex-direction: column; padding: 24px; background: radial-gradient(ellipse at top right, #38181f8c, transparent 66%); }
.reward-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 13px; }
.reward-heading h3 { font-size: 20px; line-height: 1.35; }
.reward-heading p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.close { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 1px solid #d2a47255; background: #171015; font: 23px/1 sans-serif; }
.close:hover { background: #512028; border-color: #d06b70; }
.reward-scroll { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { color: var(--gold); font-weight: 500; white-space: nowrap; font-size: 11px; text-align: right; padding: 0 0 6px 9px; }
thead th:first-child { text-align: left; padding-left: 0; }
tbody tr { border-top: 1px solid var(--rule); }
tbody th { text-align: left; font-size: 12px; padding: 8px 0; }
tbody th > span { display: flex; align-items: center; gap: 8px; }
tbody th small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
tbody td { padding: 8px 0 8px 9px; text-align: right; }
tbody tr[data-kind="rare"] th small, tbody tr[data-kind="rare"] strong { color: var(--gold); }
.perks { border-top: 1px solid var(--rule); padding: 9px 0 0; font-size: 12px; }
.perks summary { cursor: pointer; color: var(--gold); }
.perks summary span { float: right; color: var(--muted); }
.perks ul { list-style: none; margin: 7px 0 0; padding: 0; }
.perks li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 3px 0; font-size: 11px; }
.perks li span { color: var(--muted); }
.detail footer { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 11px; }
.detail footer span { margin-left: auto; white-space: nowrap; }

.preview-tools {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 12px;
  bottom: 19px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 18px);
  width: max-content;
  padding: 8px 12px;
  border: 1px solid #d3ad7355;
  border-radius: 32px;
  background: #160e13f0;
}
.preview-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.preview-label i { display: inline-block; vertical-align: 2px; width: 5px; height: 5px; margin-right: 3px; background: var(--gold); border-radius: 50%; }
.jobs { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; }
.preview-tools button[aria-pressed="true"] { background: #4c2027; color: #fff1e3; border-color: #a35e4f; }

@keyframes arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 620px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-info { border-right: 0; border-bottom: 1px solid var(--rule); padding: 18px 17px 12px; }
  .detail-heading { padding-right: 33px; }
  .survey { margin-top: 13px; }
  .detail-rewards { padding: 14px 17px; }
  .close { position: absolute; top: 14px; right: 14px; }
  .preview-tools { flex-direction: column; gap: 4px; padding: 6px 8px; bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .zone-hud, .detail[open] { animation: none; }
}
