/* The close control owns a row; only the content below it scrolls. */
/* All in-game panels share the inventory's footprint; content scrolls within. */
#sound[data-sound="on"] {
  color: #355c42;
  background: #e6edcf;
}
#sound[data-sound="off"] {
  color: #796f60;
  background: #f3efdf;
}
#sound .ui-icon {
  width: 22px;
  height: 22px;
}
dialog.wide-menu:not(.cinematic-menu) {
  width: 850px;
  height: 90dvh;
  max-height: 90dvh;
}
dialog.wide-menu #modal-content {
  flex: 1 1 auto;
  scrollbar-gutter: stable;
}
.menu-heading {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 140px;
  padding: 0 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid #d9ddc4;
}
.menu-art {
  flex: 0 0 144px;
  height: 124px;
  display: grid;
  place-items: center;
}
.menu-art > svg {
  width: 100%;
  height: 100%;
}
.menu-art .menu-portrait {
  width: 106px;
  height: 116px;
  border-radius: 24px;
  box-shadow: 0 5px 0 #d8dcc0;
}
.menu-emblem {
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  color: #648471;
  border-radius: 32px;
  border: 1px solid #cbd5b6;
  background: radial-gradient(circle at 35% 25%, #fff9da, #e3ead0);
  box-shadow: 0 5px 0 #d8dcc0;
}
.menu-emblem .ui-icon {
  width: 60px;
  height: 60px;
  stroke-width: 1.25;
}
.menu-heading-copy {
  min-width: 0;
}
.menu-heading .modal-eyebrow:empty {
  display: none;
}
.menu-heading h2 {
  margin: 0 0 12px;
}
.menu-heading .modal-eyebrow:not(:empty) {
  margin-bottom: 10px;
}
.menu-heading p {
  margin: 0;
  color: #69775e;
}
.gear-card .inline-actions button {
  white-space: nowrap;
}
dialog.wide-menu #modal-content > .inline-actions {
  flex-wrap: wrap;
}
dialog.wide-menu #modal-content > .inline-actions > button {
  flex: 1 1 120px;
  font-size: 15px;
  min-height: 44px;
}
.in-town .single-actions {
  justify-content: center;
}
.in-town .single-actions > button[data-action="shop-door"] {
  min-width: 88px;
}
@media (max-width: 600px) {
  .menu-heading {
    gap: 14px;
    min-height: 105px;
    margin-bottom: 18px;
    padding-bottom: 18px;
  }
  .menu-art {
    flex-basis: 78px;
    height: 88px;
  }
  .menu-art .menu-portrait {
    width: 74px;
    height: 81px;
    border-radius: 18px;
  }
  .menu-emblem {
    width: 72px;
    height: 72px;
    border-radius: 22px;
  }
  .menu-emblem .ui-icon {
    width: 42px;
    height: 42px;
  }
  .menu-heading .modal-eyebrow {
    display: none;
  }
  .menu-heading h2 {
    font-size: 22px;
    letter-spacing: 0;
    margin-bottom: 8px;
  }
  .menu-heading p {
    font-size: 13px;
    line-height: 1.65;
  }
  .in-town .single-actions > button {
    flex: 0 0 86px;
    max-width: 110px;
  }
}

dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  margin: -12px -12px 10px 0;
}
.modal-toolbar:has(.modal-close[hidden]) {
  display: none;
}
.modal-toolbar .modal-close {
  position: static;
  float: none;
  margin: 0;
  flex: 0 0 42px;
}
#modal-content {
  min-height: 0;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
}
.language-control {
  padding-top: 0;
}

/* Keep the quest near the corner; a single icon reopens a folded quest. */
#game-hud .quest-panel {
  top: 12px;
  right: 16px;
  width: 256px;
  padding: 18px;
  max-height: calc(100dvh - 260px);
  overflow-y: auto;
}
#quest-content .section-label {
  padding-right: 32px;
  min-height: 28px;
  font-size: 12px;
  letter-spacing: 1px;
}
#quest-toggle {
  position: absolute;
  right: 9px;
  top: 9px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #c1caaa;
  border-radius: 9px;
  background: #f3f2de;
  color: #4f6844;
  cursor: pointer;
}
#quest-toggle:focus-visible,
.conversation-close:focus-visible {
  outline: 3px solid #cda34b;
  outline-offset: 2px;
}
.quest-collapsed #game-hud .quest-panel {
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}
.quest-collapsed #quest-toggle {
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
.quest-collapsed .quest-panel::before,
.quest-collapsed .quest-panel::after {
  display: none;
}
.in-town:not(.split-play) #wallet {
  top: 12px;
  left: 16px;
  right: auto;
}
.in-town:not(.split-play) .party-panel {
  top: 152px;
}
.split-play:not(.any-battle):not(.in-shop) #game-hud .quest-panel {
  display: block;
  z-index: 9;
}
.split-play #game-hud .quest-panel {
  max-width: calc(50vw - 28px);
}

/* Conversations never cover the world with a modal backdrop or block movement. */
.conversation {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: 210px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 30px;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid #c8cfad;
  border-radius: 16px;
  background: #fffbedf5;
  box-shadow: 0 8px 28px #34452b24;
  pointer-events: auto;
}
.conversation-face {
  width: 76px;
  height: 84px;
  border-radius: 12px;
  object-fit: cover;
}
.conversation-copy {
  max-height: min(180px, 28dvh);
  overflow-y: auto;
}
.conversation h3 {
  margin: 0 0 8px;
  font:
    700 16px/1.5 "Noto Sans JP",
    sans-serif;
  color: #3f5840;
}
.conversation p {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: #52614a;
  overflow-wrap: anywhere;
}
.conversation-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #efeed9;
  font: 24px/1 sans-serif;
  color: #68785b;
  cursor: pointer;
}
.split-play .conversation {
  width: calc(50vw - 24px);
  left: 12px;
  transform: none;
  bottom: 172px;
  grid-template-columns: 60px minmax(0, 1fr) 30px;
  gap: 10px;
}
.split-play .conversation[data-seat="1"] {
  left: calc(50vw + 12px);
}
.split-play .conversation-face {
  width: 60px;
  height: 68px;
}
.disconnected .conversation {
  display: none;
}
body:has(.conversation:not([hidden])) #field-strip {
  visibility: hidden;
}
@media (max-width: 600px) {
  #game-hud .quest-panel {
    top: 12px;
    right: 12px;
    width: calc(100% - 170px);
    padding: 12px;
    max-height: calc(100dvh - 270px);
  }
  #game-hud .quest-panel h2 {
    font-size: 17px;
  }
  #game-hud .quest-panel p {
    font-size: 13px;
  }
  .in-town:not(.split-play) #wallet {
    top: 12px;
    left: 12px;
    width: 140px;
    min-width: 0;
    padding: 12px;
  }
  .in-town:not(.split-play) #wallet .resource-items {
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
  }
  .in-town:not(.split-play) .party-panel {
    top: 224px;
    left: 12px;
  }
  .quest-collapsed.in-town:not(.split-play) #wallet {
    width: calc(100% - 84px);
  }
  .quest-collapsed.in-town:not(.split-play) #wallet .resource-items {
    flex-wrap: nowrap;
    justify-content: space-around;
  }
  .quest-collapsed.in-town:not(.split-play) .party-panel {
    top: 128px;
  }
  .conversation {
    bottom: 210px;
    grid-template-columns: 58px minmax(0, 1fr) 28px;
    gap: 10px;
    padding: 12px;
  }
  .conversation-face {
    width: 58px;
    height: 66px;
  }
  .conversation h3 {
    font-size: 14px;
  }
  .conversation p {
    font-size: 14px;
    line-height: 1.65;
  }
  .split-play .conversation {
    grid-template-columns: 40px minmax(0, 1fr) 26px;
    gap: 6px;
    padding: 8px;
  }
  .split-play .conversation-face {
    width: 40px;
    height: 46px;
  }
}

/* Adventure records share the existing dialog; the header stays quiet. */
.record-day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.record-day b {
  font-size: 24px;
}
.record-day > span {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  background: #e8eddb;
  color: #38513a;
}
.record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}
.record-grid > div {
  min-width: 0;
  padding: 14px 10px;
  border-radius: 12px;
  background: #eef0e3;
  text-align: center;
}
.record-grid b {
  display: block;
  font-size: 25px;
  color: #344f3c;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.record-grid span {
  display: block;
  font-size: 14px;
  line-height: 1.5;
}
.record-resources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}
.record-resources > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border-bottom: 1px solid #dfe3d3;
  padding: 8px 0;
}
.record-resources .res {
  flex: 0 0 24px;
}
.record-resources .res .ui-icon {
  width: 24px;
  height: 24px;
}
.record-resources > div > span:nth-child(2) {
  min-width: 0;
  font-size: 15px;
}
.record-resources b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.offline-report {
  margin: 20px 0;
  padding: 2px 16px;
  border-radius: 12px;
  background: #f2ead7;
}
@media (max-width: 600px) {
  header .brand {
    max-width: calc(100% - 160px);
  }
  .record-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .record-day b {
    font-size: 21px;
  }
  .record-resources {
    grid-template-columns: 1fr;
  }
}

.conversation-action {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: #344f3c;
  color: #fffdf1;
  font: inherit;
  line-height: 1.5;
  cursor: pointer;
}
.conversation-action:disabled {
  opacity: 0.6;
  cursor: default;
}
.conversation {
  max-height: min(50vh, 360px);
  overflow-y: auto;
}

/* One unbroken title, sized to the narrowest supported dialog. */
#modal-content[data-rendered-menu="title"] h2 {
  white-space: nowrap;
  font-size: clamp(20px, 6vw, 28px);
  letter-spacing: 0;
}
#modal-content .title-seal {
  width: 128px;
  height: 112px;
  border: 0;
  border-radius: 0;
  background: none;
  margin-bottom: 18px;
}
.title-house {
  display: block;
  width: 100%;
  height: 100%;
}
@media (max-height: 720px) {
  #modal-content .title-seal {
    width: 100px;
    height: 88px;
    margin-bottom: 12px;
  }
}

/* This programmatic focus target is a scroll container, not an action. */
#modal-content:focus {
  outline: none;
}
#modal-content[data-rendered-menu="title"] {
  container-type: inline-size;
}
#modal-content[data-rendered-menu="title"] h2 {
  font-size: min(28px, 8.5cqi);
}
html:lang(en) #modal-content[data-rendered-menu="title"] h2,
html:lang(fr) #modal-content[data-rendered-menu="title"] h2 {
  font-size: min(28px, 6.5cqi);
}

/* Visible release number inside the header settings panel. */
.build-version {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: #e6edcf;
  color: #355c42;
  font-weight: 600;
  font-size: 15px;
}

.save-entry {
  position: relative;
  margin: 12px 0;
}
.save-entry .save-card {
  margin: 0;
  padding-bottom: 54px;
}
.save-entry .save-card small {
  font-size: 13px;
  line-height: 1.6;
}
.save-entry .save-card > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.save-delete {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 5px 12px;
  border: 1px solid #b8a494;
  border-radius: 6px;
  background: #fffaf0;
  color: #855c4c;
}
.menu-button.danger {
  color: #873f32;
  border-color: #b77c67;
  background: #f8e9df;
}
.save-delete-error {
  color: #873f32;
}

/* Keep growth visible without competing with health. */
.party-job {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.party-level {
  margin-left: auto;
  white-space: nowrap;
  color: #526549;
  font-size: 11px;
  font-weight: 700;
}
.party-xp {
  height: 3px;
  margin-top: 3px;
  overflow: hidden;
  border-radius: 4px;
  background: #dddcc7;
}
.party-xp i {
  display: block;
  height: 100%;
  width: 0;
  background: #b48d36;
  transition: width 0.2s ease;
}
[data-fullscreen] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
[data-fullscreen] .ui-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.inline-actions:has([data-fullscreen]) {
  flex-wrap: wrap;
}
.inline-actions [data-fullscreen] {
  min-width: 130px;
}
@media (max-width: 600px) {
  header .brand {
    max-width: calc(100% - 195px);
  }
}
@media (max-width: 380px) {
  header .brand-mark {
    display: none;
  }
}
.inline-actions:has([data-fullscreen]) > button {
  flex: 1 0 auto;
  white-space: nowrap;
}
/* Respect display cutouts in fullscreen, without shrinking the game canvas. */
header {
  padding-left: max(42px, env(safe-area-inset-left));
  padding-right: max(42px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
}
@media (max-width: 600px) {
  header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .game-dock {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}
