@layer base {
  body {
    font-size: 1rem;
    color: var(--text);
  }
  html[data-theme] :is(.panel, .widget) {
    background: var(--surface);
    border-color: var(--line);
  }
  .event-log li,
  .right-rail .event-log li {
    font-size: 0.875rem;
    line-height: 1.75;
    color: var(--text);
  }
  html[data-theme] :is(.action-tile p, .widget-tip, .record-note, .personality-note, .life-card small, .collection-entry small, .manual small, .record-heading span, .recipe-story, .recipe-progress, .mastery-hint, .batch-bar > small, .world-options small, .record-intro, .quest-card > p, .raid-entry p) {
    font-size: 0.875rem;
    color: var(--muted);
  }
  html[data-theme] .collection-entry.is-locked,
  html[data-theme] .collection-entry.is-locked small {
    color: var(--muted);
  }
  .stat-pair,
  .cost-chip,
  .widget-intro,
  .choice-row button small,
  .class-choices button small,
  .life-line,
  .life-line span:last-child:not(:first-child),
  .mobile-status:not([hidden]),
  .inventory-items span {
    font-size: 0.875rem;
  }
  .action-tile button,
  .shop-actions button,
  .choice-row button,
  .quest-card > button,
  .game-tabs button {
    font-size: 0.875rem;
  }
  .create-form input,
  .create-form select,
  .save-dialog textarea {
    font-size: 1rem;
  }
  .action-tile {
    display: flex;
    flex-direction: column;
  }
  .action-tile p {
    min-height: 0;
  }
  .action-tile > button[data-action] {
    margin-top: auto;
  }
  html[data-theme] :is(.main-button, .small-button, .gold-button, .outline-button, .recipe-action, .action-tile button, .shop-actions button, .raid-entry button, .quest-card > button, .choice-row button, .class-choices button, .personality-choices button, .personality-edit-choices button, .market-actions button, .batch-switch button, .earned-title, .leisure-block > button, .game-tabs button) {
    min-height: 44px;
    box-shadow: none;
    text-shadow: none;
    border-radius: 3px;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid var(--line);
    background: var(--button-bg);
    color: var(--button-text);
    filter: none;
  }
  html[data-theme] :is(.main-button, .gold-button, .recipe-action, .action-tile button, .raid-entry button, .quest-card > button) {
    background: var(--primary-bg);
    color: var(--primary-text);
  }
  html[data-theme] :is(.choice-row button, .class-choices button, .personality-choices button, .personality-edit-choices button)[aria-checked=true],
  html[data-theme] .game-tabs button[aria-selected=true],
  html[data-theme] .earned-title[aria-pressed=true],
  html[data-theme] .batch-switch button[aria-pressed=true] {
    background: var(--primary-bg);
    color: var(--primary-text);
    box-shadow: none;
    border-color: var(--heading);
  }
  html[data-theme] button.reset-button {
    min-height: 44px;
    padding: 9px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--danger-bg);
    color: var(--danger-text);
    text-decoration: none;
    box-shadow: none;
  }
  html[data-theme] :is(.action-tile, .shop-actions, .raid-entry, .quest-card, .choice-row, .class-choices, .leisure-block, .personality-choices, .personality-edit-choices) button:disabled {
    opacity: 1;
    background: var(--surface);
    color: var(--muted);
    border-color: var(--line);
  }
  .leisure-panel {
    margin-top: 12px;
    padding: 0;
    border-radius: 0;
  }
  .leisure-panel > h2 {
    margin: 0;
    padding: 8px 11px;
    font: 800 0.875rem var(--sans);
    color: var(--heading);
    background: var(--heading-bg);
    border-bottom: 1px solid var(--line);
  }
  .leisure-block {
    padding: 11px 12px;
    border-top: 1px dotted var(--line);
  }
  .leisure-panel > h2 + .leisure-block {
    border-top: 0;
  }
  .leisure-block > h3 {
    margin: 0 0 6px;
    font: 700 1rem var(--serif);
    color: var(--heading);
  }
  .leisure-block > p {
    margin: 0 0 8px;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .leisure-block > button {
    margin: 0 6px 6px 0;
    padding: 9px 14px;
    font-weight: 700;
    max-width: 100%;
    white-space: normal;
  }
  body {
    line-height: 1.75;
  }
  .site-shell {
    max-width: 1320px;
  }
  .main-grid {
    gap: 20px;
    grid-template-columns: 200px minmax(0, 1fr) 280px;
  }
  .left-rail,
  .middle-rail,
  .right-rail {
    gap: 20px;
  }
  .widget-inner,
  .panel-body {
    padding: 18px;
  }
  .action-grid {
    gap: 14px;
  }
  .action-tile {
    padding: 20px 14px 16px;
    box-shadow: none;
    border: 0;
    background: transparent;
  }
  html[data-theme] .action-tile {
    box-shadow: none;
    border: 0;
    background: transparent;
  }
  .tab-panel .panel-body > * + * {
    margin-top: 18px;
  }
  .world-options,
  .batch-bar,
  .profession-strip,
  .mastery-hint,
  .dungeon-entry,
  .endgame-section,
  .combat-style-block {
    margin: 0;
  }
  html[data-theme] .world-options {
    border: 0;
    background: transparent;
    padding: 0;
  }
  .cost-chip {
    border: 0;
    box-shadow: none;
  }
  .event-log li {
    padding: 9px 0 9px 17px;
  }
  .leisure-panel {
    margin-top: 20px;
  }
  .fold {
    min-width: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    text-align: left;
  }
  .fold > summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 12px 14px;
    cursor: pointer;
    font: 700 0.875rem/1.6 var(--serif);
    list-style: none;
    color: var(--text);
  }
  .fold > summary::-webkit-details-marker {
    display: none;
  }
  .fold > summary small {
    display: inline-block;
    font: 500 0.875rem/1.6 var(--sans);
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .fold > summary::after {
    content: "\d3bc\ce58\ae30  +";
    margin-left: auto;
    flex: none;
    font: 500 0.875rem var(--sans);
    color: var(--muted);
  }
  .fold[open] > summary::after {
    content: "\c811\ae30  \2212";
  }
  .fold > *:not(summary) {
    padding: 0 14px 14px;
  }
  html[data-theme] .fold > .world-options {
    padding: 0 14px 14px;
  }
  .fold > .combat-style-block {
    margin: 0 14px 14px;
    padding: 14px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    background: transparent;
  }
  .fold > summary:focus-visible {
    outline: 3px solid var(--heading);
    outline-offset: 2px;
  }
  .gather-fold {
    margin: 8px 0 12px;
  }
  .gather-fold > summary {
    padding: 9px 10px;
    font-size: 0.875rem;
  }
  .gather-fold > .gather-choices {
    margin: 0;
    padding: 0 10px 10px;
    grid-template-columns: 1fr;
  }
  html.list-view .action-tile .gather-fold {
    grid-column: 2;
    grid-row: 2;
  }
  #leisure > .leisure-panel {
    margin-top: 0;
  }
  .header-inner {
    flex-wrap: wrap;
  }
  .moon-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #284e43;
    flex: none;
  }
  .moon-badge svg {
    width: 52px;
    height: 52px;
    flex: none;
  }
  .moon-badge strong,
  .moon-badge small {
    display: block;
  }
  .moon-badge strong {
    font: 700 0.875rem var(--serif);
  }
  .moon-badge small {
    font: 500 0.875rem/1.5 var(--sans);
    max-width: 160px;
  }
  .moon-shadow {
    fill: #294344;
  }
  .moon-lit {
    fill: #fff0bb;
  }
  .moon-rim {
    stroke: #889e84;
    stroke-width: 1;
  }
  html[data-theme] .moon-badge {
    color: var(--heading-text);
  }
  .region-banner {
    position: relative;
    overflow: hidden;
    margin: 0;
    background: #f4f2e7;
    min-height: 110px;
  }
  .region-banner .local-scene-art {
    display: block;
    width: 100%;
    height: clamp(110px, 12vw, 130px);
    object-fit: cover;
  }
  .region-banner figcaption {
    position: absolute;
    left: 18px;
    bottom: 12px;
    display: grid;
    gap: 3px;
    color: #294f43;
  }
  .region-banner figcaption strong {
    font: 700 1.375rem/1.4 var(--display);
  }
  .region-banner figcaption span {
    font: 500 0.875rem/1.6 var(--serif);
  }
  html[data-theme] .region-banner {
    background: var(--surface);
  }
  html[data-theme] .region-banner figcaption {
    color: var(--text);
  }
  html[data-theme] .route-map {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 0;
  }
  html[data-theme] .route-map button {
    position: relative;
    min-width: 0;
    padding: 32px 4px 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.6;
    isolation: isolate;
  }
  html[data-theme] .route-map button small {
    display: block;
    white-space: normal;
    font-size: 0.875rem;
    color: var(--muted);
  }
  html[data-theme] .route-map button::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 17px;
    width: 100%;
    height: 2px;
    background: var(--line);
    z-index: -1;
  }
  html[data-theme] .route-map button:last-child::before,
  html[data-theme] .route-map button.route-last-visible::before {
    display: none;
  }
  html[data-theme] .route-map button::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 12px;
    width: 12px;
    height: 12px;
    transform: translateX(-50%);
    border-radius: 50%;
    border: 2px solid var(--muted);
    background: var(--surface);
  }
  html[data-theme] .route-map button.route-open {
    color: var(--heading);
    font-weight: 800;
  }
  html[data-theme] .route-map button.route-open::after {
    background: var(--heading);
    border-color: var(--heading);
  }
  html[data-theme] .route-map button[aria-checked=true] {
    background: transparent;
    color: var(--text);
    box-shadow: none;
  }
  html[data-theme] .route-map button.route-current::after {
    outline: 2px solid var(--heading);
    outline-offset: 3px;
  }
  html[data-theme] .route-map button:disabled {
    opacity: 1;
    color: var(--muted);
    background: transparent;
  }
  @media (hover: hover) {
    html[data-theme] .route-map button:hover:not(:disabled) {
      background: var(--button-bg);
    }
    html[data-theme] :is(.main-button, .gold-button, .recipe-action, .action-tile button, .raid-entry button, .quest-card > button):hover:not(:disabled) {
      background: var(--primary-hover);
      filter: none;
    }
    html[data-theme] :is(.small-button, .outline-button, .shop-actions button, .choice-row button, .class-choices button, .personality-choices button, .personality-edit-choices button, .market-actions button, .batch-switch button, .earned-title, .leisure-block > button, .game-tabs button):hover:not(:disabled) {
      background: var(--button-hover);
    }
    html[data-theme] button.reset-button:hover {
      background: var(--danger-hover);
    }
  }
  .life-story {
    padding: 14px 0;
    color: var(--text);
  }
  .life-axis {
    position: relative;
    height: 8px;
    margin: 24px 7px 18px;
    border-radius: 4px;
    background: var(--line);
  }
  #life-axis-fill {
    height: 100%;
    background: var(--heading);
    border-radius: 4px;
  }
  .life-dot {
    position: absolute;
    top: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--heading);
    border: 2px solid var(--surface);
    transform: translateX(-50%);
  }
  .life-dot-guardian,
  .life-dot-trial {
    border-radius: 2px;
  }
  .life-dot-death {
    background: var(--text);
    outline: 2px solid var(--text);
    outline-offset: 2px;
  }
  .life-story-events {
    list-style: none;
    max-height: 260px;
    overflow: auto;
    margin: 0;
    overscroll-behavior: contain;
  }
  .life-story-events li {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dotted var(--line);
    font-size: 0.875rem;
    line-height: 1.7;
  }
  .life-story-events strong {
    flex: none;
    font-variant-numeric: tabular-nums;
  }
  .life-story.is-memorial {
    border-top: 3px double var(--line);
    border-bottom: 3px double var(--line);
  }
  .life-story.is-memorial .record-heading h3 {
    color: var(--text);
  }
  .life-axis-labels {
    display: flex;
    justify-content: space-between;
    margin: -6px 0 12px;
    color: var(--muted);
    font-size: 0.875rem;
  }
  html[data-theme] .route-map {
    display: block;
  }
  .route-main {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .route-branches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0 12px;
    padding: 8px 0 4px 14px;
    border-left: 1px dashed var(--line);
  }
  .route-branch-label {
    flex-basis: 100%;
    font-size: 0.875rem;
    color: var(--muted);
  }
  html[data-theme] .route-branches button {
    flex: 1 1 160px;
    max-width: 280px;
    padding-top: 12px;
    padding-left: 28px;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--surface);
  }
  html[data-theme] .route-branches button::before {
    display: none;
  }
  html[data-theme] .route-branches button::after {
    left: 13px;
    top: 17px;
    width: 9px;
    height: 9px;
  }
  html[data-theme] .route-branches button small {
    font-size: 0.875rem;
    line-height: 1.6;
  }
  .main-story-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
  }
  .main-story-card > div {
    flex: 1;
    min-width: 0;
  }
  .story-kicker {
    font-size: 0.875rem;
    color: var(--muted);
  }
  .main-story-card h3 {
    margin: 3px 0 5px;
    font: 700 1.0625rem/1.5 var(--display);
  }
  .main-story-card p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--muted);
  }
  .main-story-card > button {
    flex: none;
    min-height: 44px;
    padding: 10px 14px;
  }
  .story-history {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .story-history button {
    min-height: 44px;
    padding: 9px 12px;
  }
  .story-dialog {
    width: min(640px, calc(100% - 24px));
    max-height: 85dvh;
    overflow: auto;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    padding: 22px;
  }
  .story-dialog::backdrop {
    background: #152925b8;
  }
  .story-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font: 700 1.125rem var(--display);
  }
  .story-dialog-head button {
    min-height: 44px;
    padding: 9px 14px;
  }
  .story-dialog h2 {
    margin: 18px 0;
    font: 700 1.4375rem/1.6 var(--display);
  }
  #story-text p {
    font: 500 0.9375rem/2 var(--serif);
    margin: 0 0 18px;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }
  #story-continue {
    margin-top: 18px;
    min-height: 44px;
    padding: 10px 18px;
    width: 100%;
  }
  .action-tile {
    gap: 12px;
    padding: 22px 16px;
    text-align: left;
    border: 0;
    background: var(--surface);
    box-shadow: none;
  }
  .action-tile h3 {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.5;
  }
  .action-tile .cost-chip {
    align-self: flex-start;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
  }
  .action-tile > button[data-action] {
    min-height: 44px;
    margin-top: auto;
  }
  .action-tile > button[data-action] + button[data-action] {
    margin-top: 0;
  }
  .stat-pair {
    align-items: baseline;
    gap: 12px;
  }
  .stat-pair strong {
    font-size: 1.0625rem;
    font-variant-numeric: tabular-nums;
  }
  .panel-heading h2 {
    font-size: 1rem;
  }
  .action-grid {
    gap: 18px;
    background: transparent;
  }
  .route-main {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    overflow: hidden;
  }
  .manual-grid:has(> .empty-state) {
    display: block;
  }
  #game-world {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }
  #game-world > .left-rail {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 1fr;
    position: static;
    order: 0;
  }
  #game-world > .middle-rail {
    grid-column: 2;
    grid-row: 1;
    gap: 16px;
    order: 0;
  }
  #game-world .right-rail {
    position: static;
    inset: auto;
    width: 100%;
    max-width: none;
    display: block;
    pointer-events: auto;
    order: 0;
    grid-column: auto;
    grid-row: auto;
  }
  #game-world .right-rail .log-panel {
    min-height: 0;
    height: auto;
    max-height: none;
    box-shadow: none;
  }
  #game-world .right-rail .event-log {
    max-height: 220px;
    flex: none;
    padding: 10px 16px;
  }
  #game-world .right-rail .event-log li:first-child {
    font-weight: 500;
    background: transparent;
    margin: 0;
    padding: 9px 0 9px 17px;
  }
  #game-world .log-panel.collapsed .event-log {
    display: none;
  }
  .header-inner {
    min-height: 0;
    padding-top: 18px;
    padding-bottom: 18px;
  }
  .header-caption {
    display: none;
  }
  #adventure > .panel-body > .region-banner {
    margin-top: 0;
  }
  .region-banner .local-scene-art {
    height: 96px;
  }
  .region-banner {
    min-height: 96px;
  }
  #adventure > .panel-body > .action-grid {
    margin-top: 16px;
  }
  html[data-theme] #game-world .action-tile {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 44px;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--line);
    background: var(--surface);
    text-align: left;
    align-content: start;
  }
  #game-world .action-tile h3 {
    margin: 0;
    font-size: 1.0625rem;
  }
  #game-world .action-tile .cost-chip {
    margin: 0;
    line-height: 1.6;
    grid-column: 1;
    grid-row: auto;
  }
  #game-world .action-tile > button[data-action] {
    width: 100%;
    min-height: 44px;
    margin: 0;
    grid-column: 1;
    grid-row: 3;
    white-space: normal;
  }
  .action-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .action-settings > .gather-fold {
    margin: 0;
    flex: 1 1 220px;
  }
  .action-settings > .batch-bar {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    flex: 1 1 220px;
  }
  .action-settings .rest-tools {
    flex: 1 1 220px;
  }
  .rest-tools > button {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    font-size: 0.875rem;
  }
  #game-world .main-story-card {
    padding: 14px 16px;
    border: 1px solid var(--line);
    gap: 14px;
    flex-direction: row;
    align-items: center;
  }
  .main-story-card h3 {
    font-size: 1rem;
  }
  .mastery-fold > .profession-strip {
    margin: 0;
    background: transparent;
    border: 0;
  }
  .mastery-fold > .mastery-hint {
    padding-top: 6px;
  }
  html.list-view #game-world .action-grid {
    grid-template-columns: 1fr;
  }
  html.list-view #game-world .action-tile {
    grid-template-columns: minmax(100px, 1fr) minmax(80px, auto) minmax(150px, 1fr);
    grid-template-rows: auto;
    align-items: center;
  }
  html.list-view #game-world .action-tile > button[data-action] {
    grid-column: 3;
    grid-row: 1;
  }
  html.list-view #game-world .action-tile .cost-chip {
    grid-column: 2;
    grid-row: 1;
  }
  #game-world .action-tile .cost-chip {
    justify-self: start;
    justify-content: flex-start;
    text-align: left;
  }
  html[data-theme] .character-crest strong,
  html[data-theme] .stat-pair strong {
    color: var(--text);
  }
  .save-controls button {
    white-space: nowrap;
    min-height: 44px;
  }
  .left-rail,
.right-rail {
    position: sticky;
    top: 14px;
    align-self: start;
  }
  .choice-label {
    font-size: 0.875rem;
    font-weight: 800;
    color: #446c54;
    display: block;
  }
  .header-controls .bgm-header {
    background: #2f7259;
    color: #fff8e8;
    border-color: #225c47;
    box-shadow: 0 2px 0 #154b3770;
    font-size: 0.875rem;
  }
  .header-controls .bgm-header[aria-pressed=true] {
    background: #ac8450;
    border-color: #826335;
  }
  .left-rail,
  .right-rail {
    position: sticky;
    top: 14px;
    align-self: start;
  }
  .game-welcome {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background:
      linear-gradient(95deg, color-mix(in srgb, var(--surface) 82%, var(--accent)), var(--surface));
    border: 1px solid var(--line);
    flex-wrap: wrap;
  }
  .game-welcome span {
    font: 700 0.875rem var(--serif);
    color: var(--accent);
    border-right: 1px solid var(--line);
    padding-right: 10px;
  }
  .game-welcome strong {
    font: 700 0.875rem var(--serif);
    color: var(--heading);
  }
  .game-welcome small {
    margin-left: auto;
    font-size: 0.875rem;
    color: var(--muted);
  }
  .tab-panel {
    min-width: 0;
    animation: unfurl .22s ease-out;
  }
  @keyframes unfurl {
    from {
      opacity: .5;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  .world-options .choice-label {
    margin: 0;
  }
  .world-options small {
    font-size: 0.875rem;
    line-height: 1.6;
  }
  .choice-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    min-width: 0;
  }
  .choice-row button {
    min-width: 0;
    padding: 10px 5px;
    border: 1px solid #bad2bc;
    background: #fffdf6;
    color: #426a57;
    font: 800 0.875rem var(--sans);
    border-radius: 4px;
    cursor: pointer;
    transition:
      background .15s,
      border-color .15s,
      box-shadow .15s;
  }
  .choice-row button small {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    margin-top: 4px;
    color: inherit;
    opacity: .8;
  }
  .choice-row button[aria-checked=true] {
    background: #397e62;
    color: white;
    border-color: #24664d;
    box-shadow: inset 0 0 0 2px #9acfb0;
  }
  .choice-row button:disabled {
    opacity: .58;
    background: #e8e9e2;
    border-color: #ccd5c9;
    color: #7c887e;
    box-shadow: none;
  }
  .gather-choices {
    margin: 9px 0 8px;
  }
  .action-tile .choice-row button {
    width: 100%;
    font-size: 0.875rem;
    padding: 8px 3px;
  }
  #inventory .shop-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #inventory .shop-actions button {
    min-height: 42px;
  }
  .help-dialog {
    width: min(570px, calc(100% - 28px));
    max-height: min(85vh, 710px);
    padding: 0;
    overflow: auto;
    border: 1px solid #96b7a2;
    background: #fffdf5;
    color: #365d4a;
    box-shadow: 0 17px 75px #152b2d7a;
  }
  .help-dialog::backdrop {
    background: #142f2e99;
    backdrop-filter: blur(3px);
  }
  .help-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: #e0ece0;
    border-bottom: 1px solid #bdd6c0;
  }
  .help-head h2 {
    font: 700 1.125rem var(--display);
    margin: 0;
  }
  .help-head button {
    border: 1px solid #9fbaa3;
    background: #fffdf5;
    padding: 7px 12px;
    color: #456e58;
  }
  .help-dialog .help-rules {
    margin: 13px;
    background: #fffdf5;
    box-shadow: none;
  }
  .help-dialog .help-rules .panel-body {
    padding: 15px;
  }
  .mobile-status {
    display: none;
  }
  html.list-view .gather-choices {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
  }
  html.list-view .action-tile .gather-choices button {
    grid-column: auto;
    grid-row: auto;
    white-space: normal;
  }
  html[data-theme] .game-tabs button {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--line);
  }
  html[data-theme] .help-dialog {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
  }
  html[data-theme] .choice-row button {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--line);
  }
  html[data-theme] .choice-label {
    color: var(--text);
  }
  html[data-theme] .game-tabs button[aria-selected=true] {
    background: var(--primary-bg);
    color: var(--primary-text);
    border-color: var(--line);
  }
  html[data-theme] .choice-row button[aria-checked=true] {
    background: var(--primary-bg);
    color: var(--primary-text);
    border-color: var(--line);
  }
  html[data-theme] .choice-row button:disabled {
    background: var(--button-bg);
    color: var(--button-text);
  }
  html[data-theme] .help-head {
    background: var(--surface);
    color: var(--text);
  }
  html[data-theme] .help-rules {
    background: var(--surface);
    color: var(--text);
  }
  html[data-theme] #log-toggle {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--line);
  }
  @media (max-width: 1100px) {
    .game-welcome small {
      display: none;
    }
    .left-rail,
    .middle-rail,
    .right-rail {
      gap: 14px;
    }
    #game-world {
      grid-template-columns: 190px minmax(0, 1fr);
      gap: 14px;
    }
    #game-world .action-grid {
      grid-template-columns: 1fr;
    }
    html[data-theme] #game-world .action-tile {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-rows: auto auto;
      padding: 14px;
      column-gap: 14px;
    }
    #game-world .action-tile > button[data-action],
    html.list-view #game-world .action-tile > button[data-action] {
      grid-column: 2;
      grid-row: 1/3;
      width: 150px;
      align-self: center;
    }
    #game-world .action-tile .cost-chip,
    html.list-view #game-world .action-tile .cost-chip {
      grid-column: 1;
      grid-row: 2;
    }
  }
  @media (max-width: 1100px) and (min-width: 781px) {
    .middle-rail {
      grid-column: 1;
      grid-row: 1;
    }
    .right-rail {
      grid-column: 2;
      grid-row: 1;
    }
    .left-rail {
      grid-column: 1 / -1;
      grid-row: 2;
      position: static;
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .main-grid {
      gap: 10px;
      grid-template-columns: minmax(0, 1fr) 215px;
    }
  }
  @media (max-width: 780px) {
    .mobile-status:not([hidden]) {
      display: flex;
      position: sticky;
      top: 0;
      z-index: var(--z-hud);
      align-items: center;
      justify-content: space-around;
      gap: 6px;
      background: #234f46;
      color: #f9f2dc;
      padding: 9px 6px;
      box-shadow: 0 3px 9px #203c3555;
      font-size: 0.875rem;
    }
    .mobile-status span {
      white-space: nowrap;
    }
    .mobile-status b {
      color: #f5d99a;
    }
    .header-inner {
      min-height: 0;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      padding: 12px;
    }
    .header-controls {
      display: flex;
      flex-wrap: nowrap;
      gap: 4px;
      width: 100%;
      justify-content: stretch;
    }
    .header-controls .site-credit {
      flex: 1;
      min-width: 0;
      font-size: 0.875rem;
      padding: 8px 2px;
      white-space: nowrap;
    }
    .header-controls .bgm-header {
      flex: 0 0 auto;
      min-width: 66px;
      font-size: 0.875rem;
    }
    .brand-group {
      gap: 10px;
    }
    .wordmark {
      font-size: 1.8125rem;
    }
    .site-footer {
      padding-bottom: 14px;
    }
    .noticebar {
      font-size: 0.875rem;
    }
    .game-welcome {
      padding: 10px;
    }
    .panel-body {
      padding: 10px;
    }
    .choice-row {
      gap: 5px;
    }
    .choice-row button {
      font-size: 0.875rem;
      padding: 9px 3px;
    }
    .action-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }
    .action-tile p {
      min-height: 0;
    }
    .action-tile:last-child {
      grid-column: 1/-1;
    }
    .world-options {
      align-items: stretch;
    }
    .world-options small {
      flex: auto;
    }
    .manual-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .main-grid {
      display: grid;
      gap: 14px;
      grid-template-columns: minmax(0, 1fr);
    }
    .right-rail {
      grid-row: 1;
      position: static;
    }
    .middle-rail {
      grid-row: 2;
      width: 100%;
      display: grid;
    }
    .left-rail {
      grid-row: 3;
      width: 100%;
      position: static;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
    }
    .right-rail .log-panel {
      height: 195px;
      max-height: min(195px, 40dvh);
    }
    .right-rail .log-panel.collapsed {
      height: auto;
      max-height: 105px;
    }
    .right-rail .log-panel.collapsed .event-log {
      display: block;
      flex: none;
      overflow: hidden;
      padding: 4px 12px;
    }
    .right-rail .log-panel.collapsed .event-log li:not(:first-child) {
      display: none;
    }
    .right-rail .log-panel.collapsed .event-log li:first-child {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin: 0;
      padding-top: 5px;
      padding-bottom: 5px;
    }
    .action-tile > button[data-action],
    .shop-actions button,
    .recipe-action {
      min-height: 44px;
    }
    .widget-inner,
    .panel-body {
      padding: 14px;
    }
    .action-tile {
      padding: 18px 14px;
    }
    .leisure-panel {
      margin-top: 14px;
    }
    html.list-view .action-tile .gather-fold {
      grid-column: 1/-1;
      grid-row: auto;
    }
    .moon-badge svg {
      width: 42px;
      height: 42px;
    }
    .moon-badge small {
      max-width: 125px;
      font-size: 0.875rem;
    }
    .region-banner figcaption {
      left: 12px;
      bottom: 9px;
    }
    .region-banner figcaption strong {
      font-size: 1.1875rem;
    }
    html[data-theme] .route-map button {
      font-size: 0.875rem;
      padding-left: 2px;
      padding-right: 2px;
    }
    .main-story-card {
      align-items: stretch;
      flex-direction: column;
      gap: 10px;
    }
    .main-story-card > button {
      align-self: flex-start;
    }
    .story-dialog {
      padding: 16px;
    }
    #game-world {
      grid-template-columns: minmax(0, 1fr);
    }
    #game-world > .middle-rail {
      grid-column: 1;
      grid-row: 1;
    }
    #game-world > .left-rail {
      grid-column: 1;
      grid-row: 2;
    }
    .has-character main {
      padding-bottom: 18px;
    }
    #game-world .right-rail .log-panel {
      height: auto;
      max-height: none;
    }
    #game-world .right-rail .log-panel.collapsed {
      max-height: none;
    }
    #game-world .log-panel.collapsed .event-log {
      display: block;
      max-height: 56px;
    }
    .region-banner .local-scene-art {
      height: 84px;
    }
    .region-banner {
      min-height: 84px;
    }
    #game-world .main-story-card {
      align-items: flex-start;
      flex-direction: column;
    }
    .action-settings > .gather-fold,
    .action-settings > .batch-bar,
    .action-settings > .rest-tools {
      flex: 1 1 100%;
    }
  }
  @media (max-width: 480px) {
    .header-controls .site-credit {
      font-size: 0.875rem;
    }
    .action-grid {
      grid-template-columns: 1fr;
    }
    .action-tile:last-child {
      grid-column: auto;
    }
    .inventory-items {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .choice-row button {
      font-size: 0.875rem;
    }
    html.list-view .action-tile .gather-choices {
      grid-column: 1/-1;
      grid-row: auto;
    }
    .header-inner {
      gap: 12px;
    }
    .moon-badge {
      margin-left: auto;
    }
    .moon-badge span {
      max-width: 115px;
    }
    .region-banner figcaption span {
      font-size: 0.875rem;
    }
    .route-branches {
      margin-left: 6px;
      padding-left: 10px;
    }
    html[data-theme] .route-branches button {
      max-width: none;
    }
    #game-world .action-tile > button[data-action] {
      width: 120px;
    }
    html[data-theme] #game-world .action-tile {
      padding: 12px;
    }
    html.list-view #game-world .action-tile {
      grid-template-columns: minmax(0, 1fr) 120px;
      grid-template-rows: auto auto;
    }
    html.list-view #game-world .action-tile > button[data-action] {
      grid-column: 2;
      grid-row: 1/3;
      width: 120px;
    }
    html.list-view #game-world .action-tile .cost-chip {
      grid-column: 1;
      grid-row: 2;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .tab-panel {
      animation: none;
    }
  }
}




@layer components {
  body { line-height: 1.6; }
  #adventure .field-sidebar .recovery-box {
    border-left: 3px solid var(--accent);
    background: var(--surface);
  }
  #adventure .field-sidebar .recovery-heading {
    font-weight: 700;
    color: var(--accent);
  }
  #adventure .field-sidebar .recovery-box.needs-recovery .recovery-options > button:not(:disabled) {
    background: var(--primary-bg);
    color: var(--primary-text);
    border-color: var(--primary-bg);
  }
  @media (hover: hover) and (pointer: fine) {
    #adventure .field-sidebar .recovery-box.needs-recovery .recovery-options > button:not(:disabled):hover {
      background: var(--primary-hover);
    }
  }
  #game-world .main-story-card {
    border: 1px solid var(--line);
    border-left: 3px solid var(--gold);
    padding: 14px;
    background: var(--surface);
  }
  #adventure :is(.discovered-places, .mastery-fold):not([open]) {
    border-color: transparent;
    border-bottom-color: var(--line);
    background: transparent;
  }
  #log-toggle {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--line);
    min-height: 44px;
    padding: 8px 12px;
  }
  .event-log .log-repeat {
    display: inline-block;
    margin-inline-start: 6px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
  }
}

@layer components {
  .recovery-heading {
    margin: 0 0 10px;
    font-size: 1rem;
    line-height: 1.6;
  }
  #mobile-status #recovery-jump {
    min-height: 44px;
    padding: 6px 10px;
    background: var(--primary-bg);
    color: var(--primary-text);
    border: 1px solid var(--primary-bg);
    font: inherit;
  }
  #profession-strip { display: grid; }
  #profession-strip .mastery-row {
    max-width: 36rem;
    grid-template-columns: 6em minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
  }
  #profession-strip .mastery-row span {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    text-align: left;
  }
  #profession-strip .mastery-value { white-space: nowrap; }
  #profession-strip progress {
    min-width: 0;
    width: 100%;
    height: 12px;
    border: 1px solid var(--line);
    background: var(--surface-sunken);
  }
  #profession-strip progress::-webkit-progress-bar { background: var(--surface-sunken); }
  #profession-strip progress::-webkit-progress-value { background: var(--accent); }
  #profession-strip progress::-moz-progress-bar { background: var(--accent); }
  .field-shell > :is(.field-sense, .field-walk-status) { padding: 8px 12px; }
  .field-shell > .field-walk-status:empty { display: none; }
  #field-encounter > p { padding: 8px 12px; }
  #field-target:empty { display: none; }
  @media (max-width: 480px) {
    #profession-strip .mastery-row { grid-template-columns: 3em minmax(0, 1fr) auto; }
  }
}
