/*
 * Terra Life -- persistent in-game HUD (Day/Time/Location/Money) and the
 * Options menu (gear button -> Resume/Save/Options/Return to Title).
 *
 * The HUD artwork (hud-frame.webp) is a visual frame ONLY -- no values
 * and no gear icon are baked into it. All four values below are real
 * HTML text absolutely positioned over its blank fields (percentages
 * measured directly against the source art's pixel layout). The gear
 * button is a separate real element, fixed to the viewport's
 * bottom-right corner rather than living beside the frame -- always
 * reachable regardless of scroll position, and it lets the HUD bar
 * itself stretch to fill the available width instead of sharing the
 * row with a button.
 */

.hud {
  margin-bottom: 20px;
}

.hud__frame {
  position: relative;
  width: 100%;
}

.hud__art {
  width: 100%;
  height: auto;
  display: block;
}

.hud__value {
  position: absolute;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-family: "IM Fell English", Georgia, serif;
  font-weight: bold;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(10px, 3vw, 20px);
}

@media (min-width: 640px) {
  .hud__value {
    font-size: clamp(14px, 1.5vw, 20px);
  }
}

/* Positions measured against the 1774x887 source artwork: each box
   starts just after its icon + vertical divider, ending with a small
   margin before the box's own right edge. */
.hud__value--day {
  left: 23.22%;
  top: 17.02%;
  width: 16.12%;
  height: 24.35%;
}

.hud__value--time {
  left: 68.88%;
  top: 17.02%;
  width: 15.67%;
  height: 24.35%;
}

.hud__value--location {
  left: 23.22%;
  top: 51.52%;
  width: 21.31%;
  height: 21.42%;
  /* Building names ("Boswick's Butcher Shop") can be longer than this
     box is wide at any readable font size on a phone -- unlike the
     other three fields (always short: "Day 1", "Morning", "$25"), this
     one wraps to 2 lines and runs a smaller/tighter scale instead of
     truncating into unreadable mush. */
  white-space: normal;
  line-height: 1.05;
  font-size: clamp(7px, 1.8vw, 11px);
}

@media (min-width: 640px) {
  .hud__value--location {
    font-size: clamp(9px, 0.85vw, 11px);
  }
}

.hud__value--money {
  left: 64.83%;
  top: 51.52%;
  width: 22.04%;
  height: 21.31%;
}

.hud__gear-btn,
.hud__character-btn {
  position: fixed;
  bottom: 16px;
  z-index: 500; /* above page content, below .options-overlay (1000) so the modal still covers it when open */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #3a2a17, #1c140c);
  border: 3px solid var(--gold);
  color: var(--gold);
  font-size: 20px;
  text-decoration: none;
  box-shadow: var(--panel-shadow);
  cursor: pointer;
}

.hud__gear-btn {
  right: 16px;
}

/* Character Menu button mirrored to the opposite corner -- a separate,
   real page (not the Options CSS-overlay modal), so it gets its own
   distinct button rather than sharing the gear's. */
.hud__character-btn {
  left: 16px;
}

.hud__gear-btn:hover,
.hud__gear-btn:focus-visible,
.hud__character-btn:hover,
.hud__character-btn:focus-visible {
  background: var(--gold);
  color: #1c140c;
  outline: none;
}

@media (min-width: 640px) {
  .hud__gear-btn,
  .hud__character-btn {
    width: 52px;
    height: 52px;
    font-size: 24px;
  }
}

/* --- Options menu: pure-CSS :target modal, JS (hud.js) only makes
   opening/closing nicer -- see the comment in base.html. --- */

.options-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 4, 0.72);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.options-overlay:target,
.options-overlay.is-open {
  display: flex;
}

.options-menu {
  position: relative;
  background: var(--parchment-bg);
  background-image: radial-gradient(rgba(138, 106, 61, 0.12) 1px, transparent 1px);
  background-size: 6px 6px;
  border: 3px solid var(--parchment-edge);
  border-radius: 8px;
  box-shadow: var(--panel-shadow), inset 0 0 40px rgba(138, 106, 61, 0.25);
  padding: 36px 28px 28px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.options-menu h2 {
  margin: 0 0 8px;
}

.options-menu__close {
  position: absolute;
  top: 6px;
  right: 14px;
  font-size: 30px;
  line-height: 1;
  color: var(--ink-faint);
  text-decoration: none;
}

.options-menu__close:hover,
.options-menu__close:focus-visible {
  color: var(--accent);
}

.options-menu form {
  margin: 0;
}

.options-menu .btn {
  width: 100%;
}

.options-menu__save-status {
  margin: -4px 0 0;
  color: var(--gold);
  font-weight: bold;
  font-style: italic;
}
