@layer base {
  .header-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    position: relative;
    z-index: var(--z-menu);
  }
  .header-controls .site-credit {
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
  }
  .site-nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
  .entrance-button {
    font: 700 1rem/1.24 var(--serif);
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 3px 0 #6d423533, 0 0 0 4px #fff7e899;
  }
  @media (hover: hover) {
    .entrance-button:hover {
      background: #fff1dc;
      transform: rotate(-3deg);
    }
  }
  .world-options {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px;
    margin-bottom: 12px;
    background: #f4f8ed;
    border: 1px solid #d4dfcc;
    flex-wrap: wrap;
  }
  .world-options label {
    color: #3b6753;
    font-weight: 800;
    font-size: 0.75rem;
  }
  .world-options select,
  .action-tile select {
    border: 1px solid #b8d2bd;
    background: #fffcf0;
    color: #375e4b;
    padding: 7px 8px;
    min-width: 0;
    font-size: 0.75rem;
  }
  .world-options select {
    max-width: 230px;
  }
  .world-options small {
    flex: 1 1 150px;
    font-size: 0.75rem;
    color: var(--muted);
  }
  .action-tile select {
    display: block;
    margin: 8px auto;
    width: 100%;
    font-size: 0.75rem;
    padding: 7px 4px;
  }
  .profession-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px dotted #c8d8c5;
    background: #f7faef;
    font-size: 0.75rem;
    color: #41715e;
  }
  .profession-strip span {
    flex: 1 1 80px;
    text-align: center;
    white-space: nowrap;
  }
  .dungeon-entry {
    margin-top: 11px;
    padding: 11px;
    border: 1px solid #bea978;
    background:
      linear-gradient(
        115deg,
        #f6f2e3,
        #e9eadb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .dungeon-entry strong {
    display: block;
    font: 700 1rem var(--serif);
    color: #805b3e;
  }
  .dungeon-entry small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.8;
  }
  .dungeon-entry button {
    border: 1px solid #875a45;
    background: linear-gradient(#cda07a, #965f4c);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 9px;
    color: white;
    white-space: nowrap;
  }
  .manual-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
  }
  .manual {
    min-width: 0;
    border: 1px solid #d1d7c3;
    padding: 11px 8px;
    text-align: center;
    background: linear-gradient(#fffdf5, #f2f1e2);
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 4px;
    position: relative;
  }
  .manual .seal {
    width: 42px;
    height: 49px;
    background: var(--button-bg);
    color: var(--accent);
    display: grid;
    place-items: center;
    font: 700 1.3125rem var(--display);
    border: 1px solid #c8b28f;
    box-shadow: inset 0 0 0 3px #fff9e8;
  }
  .manual strong {
    font: 700 0.8125rem var(--serif);
    color: #386a54;
  }
  .manual small {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.6;
    word-break: keep-all;
  }
  .manual.locked {
    opacity: .8;
  }
  .manual.locked .seal {
    color: var(--muted);
    background: #ebe8dc;
  }
  .manual .bonus {
    color: #a05d45;
    font-size: 0.75rem;
    font-weight: 700;
  }
  html[data-theme] body {
    background: var(--page-bg);
    color: var(--text);
  }
  html[data-theme] :is(.panel, .widget, .noticebar, .ticker, .world-options, .profession-strip, .action-tile p, .rules-list p, .event-log li, .panel-body p, .widget-inner p, .stat-pair, .rules-list b) {
    color: var(--text);
  }
  html[data-theme] .site-shell {
    background: var(--surface);
  }
  html[data-theme] main {
    background: var(--surface);
  }
  html[data-theme] .header-inner {
    background: var(--header-bg);
  }
  html[data-theme] .brand-group .wordmark {
    color: var(--heading-text);
  }
  html[data-theme] .header-caption {
    color: var(--heading-text);
  }
  html[data-theme] .panel {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .widget {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .panel-heading {
    background: var(--heading-bg);
    border-color: var(--line);
    color: var(--heading-text);
  }
  html[data-theme] .widget-heading {
    background: var(--heading-bg);
    border-color: var(--line);
    color: var(--heading-text);
  }
  html[data-theme] .panel-heading h2 {
    color: var(--heading-text);
  }
  html[data-theme] .action-tile h3 {
    color: var(--heading);
  }
  html[data-theme] .manual strong {
    color: var(--heading);
  }
  html[data-theme] .noticebar {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .ticker {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .world-options {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .profession-strip {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .manual {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
  }
  html[data-theme] .dungeon-entry {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
  }
  html[data-theme] .action-tile {
    background: var(--surface);
    border-color: var(--line);
  }
  html[data-theme] .widget-tip {
    color: var(--muted);
  }
  html[data-theme] .world-options small {
    color: var(--muted);
  }
  html[data-theme] .manual small {
    color: var(--muted);
  }
  html[data-theme] .world-options label {
    color: var(--text);
  }
  html[data-theme] .profession-strip {
    color: var(--text);
  }
  html[data-theme] .dungeon-entry strong {
    color: var(--heading);
  }
  html[data-theme] .hero-shade {
    background: var(--intro-bg);
  }
  html[data-theme] #onboarding-title {
    color: var(--text);
    text-shadow: none;
  }
  html[data-theme] .hero-copy p {
    color: var(--text);
  }
  html[data-theme] .hero-kicker {
    color: var(--text);
  }
  html[data-theme] .site-footer {
    background: var(--chrome-bg);
    color: var(--heading-text);
  }
  html[data-theme] .manual .bonus {
    color: var(--heading);
  }
  html.list-view .action-grid {
    grid-template-columns: 1fr;
  }
  html.list-view .action-tile {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) minmax(110px, auto);
    align-items: center;
    gap: 8px;
    text-align: left;
  }
  html.list-view .action-tile h3 {
    margin: 0;
  }
  html.list-view .action-tile .tile-icon {
    font-size: 1.5rem;
  }
  html.list-view .action-tile p {
    grid-column: 2;
    margin: 0;
    min-height: 0;
  }
  html.list-view .action-tile button {
    grid-column: 3;
    grid-row: 1/3;
    white-space: nowrap;
  }
  html.list-view .action-tile select {
    grid-column: 2;
    max-width: 250px;
    margin: 0;
  }
  html.list-view .manual-grid {
    grid-template-columns: 1fr;
  }
  html.list-view .manual {
    display: flex;
    align-items: center;
    text-align: left;
    justify-content: flex-start;
  }
  html.list-view .manual .seal {
    width: 28px;
    height: 30px;
    font-size: 0.875rem;
  }
  @media (max-width: 780px) {
    .header-controls {
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .header-controls .site-credit {
      font-size: 0.75rem;
    }
    .world-options {
      align-items: stretch;
      flex-direction: column;
      gap: 5px;
    }
    .world-options select {
      max-width: none;
      width: 100%;
    }
    .world-options small {
      flex: 0 0 auto;
    }
    .manual-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dungeon-entry {
      align-items: stretch;
      flex-direction: column;
    }
    .dungeon-entry button {
      width: 100%;
    }
  }
  @media (max-width: 480px) {
    .manual-grid {
      grid-template-columns: 1fr;
    }
    .header-caption {
      display: none;
    }
    html.list-view .action-tile {
      grid-template-columns: 30px minmax(0, 1fr);
    }
    html.list-view .action-tile button {
      grid-column: 1/-1;
      grid-row: auto;
      min-width: 0;
      white-space: normal;
    }
  }
}
