/* BELOW product presentation. Loaded after all pinned upstream styles. */
:root {
  --below-ivory: #faf9f7;
  --below-paper: #faf9f7;
  --below-ink: #252525;
  --below-muted: #77716d;
  --below-red: #af3434;
  --below-wave: #ebc4bf;
  --below-line: #dedad6;
  --below-panel-width: 700px;
}

html {
  background: var(--below-ivory);
  color-scheme: light;
}

body,
.tooltip,
select.menuBtn {
  background: var(--below-ivory);
  color: var(--below-ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  margin: 0;
  overflow-x: hidden;
}

button,
textarea,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

#belowChrome {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 120;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(68px + env(safe-area-inset-top));
  box-sizing: border-box;
  padding: env(safe-area-inset-top) 20px 0;
  background: rgba(250, 249, 247, 0.94);
}

#belowWordmark {
  color: var(--below-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  letter-spacing: 0.52em;
  text-indent: 0.52em;
}

#belowWordmark::after {
  content: "";
  display: block;
  width: 18px;
  height: 1px;
  margin: 9px auto 0;
  background: var(--below-ink);
}

.below-chrome-control {
  min-width: 48px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--below-muted);
  font-size: 12px;
  cursor: pointer;
}

.below-sound-control { justify-self: start; }
.below-menu-control { justify-self: end; }

#belowStage {
  position: relative;
  max-width: 520px;
  min-height: 440px;
  box-sizing: border-box;
  margin: 0 auto;
  text-align: center;
}

#belowCopy {
  position: relative;
  z-index: 2;
}

#belowKicker {
  margin: 0 0 12px;
  color: var(--below-muted);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.08em;
}

#belowNarrative {
  margin: 0;
  font-family: Georgia, "Noto Serif KR", "Apple SD Gothic Neo", serif;
  font-size: clamp(27px, 5.4vw, 38px);
  font-weight: 400;
  line-height: 1.32;
  letter-spacing: -0.035em;
}

#belowNarrative span { display: block; }
#belowNarrativeAccent { color: var(--below-red); }

#belowSignalFrame {
  position: relative;
  width: min(300px, 82vw);
  height: 240px;
  margin: 2px auto 0;
}

#belowSignal {
  display: block;
  width: 100%;
  height: 100%;
}

#belowHeartbeat {
  position: absolute;
  right: 0;
  bottom: 17px;
  left: 0;
  color: var(--below-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

#belowBpmUnit {
  margin-left: 7px;
  color: var(--below-muted);
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.2em;
}

#belowCue {
  min-height: 20px;
  margin: -4px 0 6px;
  color: var(--below-muted);
  font-size: 12px;
}

#belowGoal {
  max-width: 390px;
  min-height: 38px;
  margin: 0 auto;
  color: var(--below-muted);
  font-size: 13px;
  line-height: 1.55;
}

#belowPrimaryActions {
  position: relative;
  z-index: 3;
  width: min(370px, 100%);
  min-height: 58px;
  margin: 8px auto 20px;
}

#belowPrimaryActions[data-location="room"] .below-action-outside,
#belowPrimaryActions[data-location="room"] .below-action-path,
#belowPrimaryActions[data-location="room"] .below-action-world,
#belowPrimaryActions[data-location="outside"] .below-action-room,
#belowPrimaryActions[data-location="outside"] .below-action-path,
#belowPrimaryActions[data-location="outside"] .below-action-world,
#belowPrimaryActions[data-location="path"] .below-action-room,
#belowPrimaryActions[data-location="path"] .below-action-outside,
#belowPrimaryActions[data-location="path"] .below-action-world,
#belowPrimaryActions[data-location="world"] .below-action-room,
#belowPrimaryActions[data-location="world"] .below-action-outside,
#belowPrimaryActions[data-location="world"] .below-action-path,
#belowPrimaryActions[data-location="combat"] > * {
  display: none !important;
}

div.button {
  min-height: 44px;
  box-sizing: border-box;
  padding: 12px 14px;
  border-color: var(--below-line);
  color: var(--below-ink);
  touch-action: manipulation;
}

div.button:hover,
div.button:focus {
  color: var(--below-red);
  text-decoration: none;
}

div.button:focus,
button:focus,
a:focus,
[role="button"]:focus {
  outline: 2px solid var(--below-red);
  outline-offset: 3px;
}

#belowPrimaryActions div.below-main-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  min-width: 0;
  min-height: 56px;
  margin: 0;
  padding: 14px 52px 14px 24px;
  border: 0;
  border-radius: 30px;
  background: linear-gradient(105deg, #252525 62%, #5d3031 88%, #af3434 140%);
  box-shadow: 10px 10px 28px rgba(175, 52, 52, 0.12);
  color: #fff;
  font-size: 16px;
  text-align: center;
}

#belowPrimaryActions div.below-main-action::after {
  content: "→";
  position: absolute;
  right: 24px;
  color: #fff;
}

#belowPrimaryActions div.below-main-action.disabled {
  opacity: 0.48;
}

#belowDirections {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

#belowDirections button {
  min-width: 0;
  min-height: 52px;
  border: 1px solid var(--below-line);
  border-radius: 50%;
  background: transparent;
  color: var(--below-ink);
}

#belowResume {
  position: absolute;
  inset: -12px 0;
  z-index: 160;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 28px;
  background: rgba(250, 249, 247, 0.97);
  text-align: center;
}

#belowResume h2 {
  margin: 0 0 12px;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 24px;
  font-weight: 400;
}

#belowResume p {
  max-width: 320px;
  color: var(--below-muted);
}

#belowContinue,
.below-shell-button,
.menu button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--below-line);
  background: transparent;
  color: var(--below-ink);
  cursor: pointer;
}

#belowContinue {
  border-color: var(--below-ink);
  background: var(--below-ink);
  color: #fff;
}

div#wrapper {
  position: relative;
  max-width: 700px;
  min-height: 100vh;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 100px 20px 80px;
}

div#content {
  width: 100%;
  height: auto;
  min-height: 340px;
  overflow: hidden;
}

#main {
  overflow: hidden;
}

#locationSlider {
  position: relative;
  display: flex;
  align-items: flex-start;
}

div.location {
  flex: 0 0 auto;
  min-height: 300px;
  box-sizing: border-box;
}

#header {
  margin-bottom: 22px;
  text-align: center;
}

div.headerButton {
  min-height: 40px;
  border-left-color: var(--below-line);
  color: var(--below-muted);
  line-height: 40px;
}

div.headerButton.selected,
div.headerButton.selected:hover {
  color: var(--below-red);
  text-decoration: none;
}

#storesContainer,
#main[data-active-location="room"] #storesContainer {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  margin: 0 0 24px;
}

#stores,
#weapons,
#village,
#outfitting,
#perks {
  max-width: 100%;
  box-sizing: border-box;
  border-color: var(--below-line);
  color: var(--below-muted);
}

.storeRow,
.outfitRow,
.workerRow {
  min-height: 36px;
  border-bottom-color: var(--below-line);
}

#buildBtns,
#craftBtns,
#buyBtns {
  position: relative;
  top: auto;
  left: auto;
  clear: both;
  margin-top: 20px;
}

#roomPanel div.button,
#outsidePanel div.button,
#pathPanel div.button {
  width: 100% !important;
  min-width: 180px;
  min-height: 48px;
  height: auto;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--below-line);
  white-space: normal;
  line-height: 1.4;
  text-align: left;
}

#buildBtns .tooltip,
#craftBtns .tooltip,
#buyBtns .tooltip {
  z-index: 40;
}

#village,
#main[data-active-location="outside"] #village,
#workers,
#main[data-active-location="outside"] #workers {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  margin-bottom: 24px;
}

.upBtn,
.dnBtn,
.upManyBtn,
.dnManyBtn {
  min-width: 30px;
  min-height: 34px;
  text-align: center;
}

#worldOuter {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

#map {
  max-width: 100%;
  color: var(--below-muted);
  font: 8px/1.15 monospace;
  letter-spacing: 0;
}

#supplies {
  color: var(--below-muted);
}

#belowChrome ~ .menu,
.menu {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 240;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px 14px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--below-line);
  background: var(--below-paper);
  box-shadow: 0 -18px 50px rgba(37, 37, 37, 0.08);
  transform: translateY(110%);
  transition: transform 180ms ease-out;
  pointer-events: none;
}

body.below-menu-open #belowChrome ~ .menu,
body.below-menu-open .menu {
  transform: translateY(0);
  pointer-events: auto;
}

.menu span,
.menu button,
.menu a {
  float: none;
  min-width: 44px;
  min-height: 44px;
  margin-left: 0;
  padding: 0 5px;
  color: var(--below-muted);
  line-height: 44px;
  white-space: nowrap;
}

.menu button {
  padding: 0 14px;
}

.below-license-link {
  text-decoration: none;
}

#belowBrand,
.logo {
  display: none;
}

div#saveNotify {
  top: 72px;
  z-index: 130;
  background: var(--below-paper);
  color: var(--below-muted);
  font-size: 11px;
}

#notifications {
  color: var(--below-muted);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 12px;
}

.below-event-active #notifications {
  opacity: 0;
}

div#notifyGradient { display: none; }

.below-save-status,
.below-native-status {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  width: min(620px, calc(100vw - 32px));
  transform: translateX(-50%);
  box-sizing: border-box;
  padding: 14px 18px;
  border: 1px solid var(--below-red);
  background: var(--below-paper);
  color: var(--below-red);
}

.below-native-status {
  border-color: var(--below-line);
  color: var(--below-muted);
}

.below-event-active #content,
.below-event-active #belowPrimaryActions {
  display: none;
}

.eventPanel,
.below-event-active .eventPanel {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  max-width: 100%;
  max-height: none;
  overflow: visible;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  z-index: 5;
}

.eventPanel::before,
.eventPanel::after {
  display: none !important;
}

.eventPanel:focus {
  outline: none;
}

.eventPanel .eventTitle {
  position: relative;
  top: auto;
  display: block;
  margin: 0 0 12px;
  color: var(--below-muted);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
}

#fight {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 56px;
  margin: 12px 0 20px;
}

#description #fight .fighter {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  min-width: 80px;
  color: var(--below-ink);
  text-align: center;
}

#description #fight .fighter .label {
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 18px;
}

#description #fight .fighter .hp {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  display: block;
  margin-top: 4px;
  margin-left: 0;
  color: var(--below-muted);
  font-variant-numeric: tabular-nums;
}

.eventPanel #attackButtons,
.eventPanel #healButtons,
.eventPanel #exitButtons {
  width: min(370px, 100%);
  margin: 0 auto;
}

.eventPanel .button {
  float: none;
  width: 100%;
  min-height: 50px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--below-line);
  background: transparent;
  color: var(--below-ink);
  text-align: left;
}

#attackButtons .button:first-child {
  padding-right: 44px;
  border: 1px solid rgba(175, 52, 52, 0.58);
  border-radius: 30px;
  background: linear-gradient(105deg, #252525 62%, #5d3031 88%, #af3434 140%);
  box-shadow: 0 8px 22px rgba(175, 52, 52, 0.12);
  color: #fff;
  text-align: center;
}

#attackButtons .button:first-child:hover,
#attackButtons .button:first-child:focus {
  color: #fff;
}

#attackButtons .button:first-child::after {
  content: "→";
  float: right;
}

#lootButtons {
  width: min(370px, 100%);
  margin: 0 auto 16px;
  border-color: var(--below-line);
}

.lootRow {
  position: relative;
  min-height: 50px;
}

.lootRow .lootTakeAll {
  position: absolute;
  right: 0;
  width: 90px !important;
  text-align: right;
}

.takeETrow .button {
  text-align: center;
}

#description {
  overflow-wrap: anywhere;
}

#description > div:first-child:not(#fight):not(#lootButtons) {
  color: var(--below-muted);
  text-align: center;
}

#description textarea {
  width: 100%;
  max-width: 100%;
  max-height: 40dvh;
  box-sizing: border-box;
  user-select: text;
}

.below-recovery {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 20px;
  background: rgba(37, 37, 37, 0.58);
}

.below-recovery-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  box-sizing: border-box;
  padding: 28px;
  border-top: 3px solid var(--below-red);
  background: var(--below-paper);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.below-recovery-panel h1 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
}

.below-recovery-note { color: var(--below-muted); }

.below-recovery-actions,
.below-recovery-confirmation {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.below-recovery-panel button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--below-line);
  background: transparent;
  color: var(--below-ink);
  cursor: pointer;
  font: inherit;
}

.below-recovery-panel button:first-child,
.below-recovery-panel button:focus { border-color: var(--below-red); }

.below-recovery-panel textarea {
  width: 100%;
  min-height: 150px;
  box-sizing: border-box;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--below-line);
  background: var(--below-ivory);
  color: var(--below-ink);
  font: 12px/1.5 monospace;
  user-select: text;
}

[hidden] { display: none !important; }

@media (max-width: 900px) {
  :root { --below-panel-width: calc(100vw - 32px); }

  div#wrapper {
    width: 100%;
    max-width: 700px;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 140px 16px 128px;
  }

  div#content {
    width: 100%;
    height: auto;
    min-height: 340px;
  }

  div#outerSlider > div {
    height: auto;
    min-height: 340px;
  }

  div.location {
    width: var(--below-panel-width);
    max-width: 668px;
  }

  #roomPanel div.button {
    width: 100% !important;
    min-width: 180px;
    min-height: 44px;
    height: auto;
    white-space: normal;
    line-height: 1.4;
  }

  #outsidePanel div.button {
    width: 100% !important;
    min-width: 180px;
    min-height: 44px;
    height: auto;
    white-space: normal;
    line-height: 1.4;
  }

  #buildBtns,
  #craftBtns,
  #buyBtns {
    position: relative;
    top: auto;
    left: auto;
    clear: both;
    margin-top: 24px;
  }

  #main[data-active-location="room"] #storesContainer {
    position: relative;
    top: auto !important;
    right: auto !important;
    margin: 0 0 24px;
  }

  #main[data-active-location="outside"] #village,
  #main[data-active-location="outside"] #workers {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    margin-bottom: 24px;
  }

  #stores,
  #weapons,
  #village {
    max-width: 100%;
    box-sizing: border-box;
  }

  .eventPanel {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    width: min(335px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: 22px 18px;
    background: var(--below-paper);
    box-shadow: 0 18px 60px rgba(37, 37, 37, 0.16);
    transform: translate(-50%, -50%);
    z-index: 180;
  }

  .eventPanel:before {
    inset: 0;
    width: auto;
    height: auto;
  }

  .eventPanel:after { pointer-events: none; }

  .eventPanel .eventTitle {
    position: relative;
    top: auto;
    display: block;
    margin: 0 0 12px;
    line-height: 1.4;
  }

  .eventPanel .button {
    float: none;
    min-height: 44px;
    margin: 0;
  }

  #exitButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
  }

  #description { overflow-wrap: anywhere; }

  #description textarea {
    max-width: 100%;
    max-height: 40dvh;
    box-sizing: border-box;
    user-select: text;
  }

  div#notifications {
    position: absolute;
    top: 76px;
    top: calc(76px + env(safe-area-inset-top));
    left: 16px;
    z-index: 30;
    width: min(300px, calc(100vw - 32px));
    height: 64px;
    pointer-events: none;
  }

  div#notifyGradient { display: none; }

  .menu {
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    gap: 4px 12px;
    overflow-x: visible;
    box-sizing: border-box;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--below-paper);
  }

  .menu span {
    float: none;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    margin-left: 0;
    padding: 0 4px;
    line-height: 44px;
    white-space: nowrap;
  }

  #belowBrand { left: 16px; }
  .below-tagline { display: none; }
  .logo { display: none; }
}

@media (max-width: 380px) {
  #belowStage { min-height: 420px; }
  #belowSignalFrame { height: 218px; }
  #belowNarrative { font-size: 27px; }
  #belowGoal { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
