@layer shell {
  .app-shell { min-height: 100vh; }
  .brand small { display: block; color: var(--faint); font-size: 10px; letter-spacing: 0.18em; margin-top: 3px; text-transform: uppercase; }
  .token-control { align-items: center; color: var(--faint); display: flex; font-size: 11px; gap: 8px; }
  .token-control input { min-width: 0; width: 140px; }
  .status-banner[hidden] { display: none; }
  .status-banner:not(:empty) { align-items: center; background: var(--gold-soft); border-bottom: 1px solid rgba(240, 189, 105, 0.2); color: var(--gold); display: flex; gap: 12px; justify-content: space-between; min-height: 38px; padding-bottom: 10px; padding-top: 10px; }
  .status-banner.error:not(:empty) { background: rgba(242, 139, 139, 0.1); border-color: rgba(242, 139, 139, 0.22); color: var(--red); }
  .sidebar { min-height: 0; padding: 20px; }
  .archive-drawer { background: transparent; border: 0; color: var(--text); margin: auto; max-height: min(86dvh, 760px); max-width: min(560px, calc(100vw - 32px)); overflow: visible; padding: 0; width: 100%; }
  .archive-drawer::backdrop { background: rgba(3, 7, 18, 0.72); backdrop-filter: blur(3px); }
  .archive-drawer .sidebar { background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-large); box-shadow: var(--shadow-panel); max-height: min(86dvh, 760px); overflow-y: auto; }
  .archive-heading-actions { align-items: center; display: flex; gap: 8px; }
  .new-game-form { border-bottom: 1px solid var(--line); padding-bottom: 20px; }
  .new-game-form label { color: var(--text); display: block; font-size: 13px; font-weight: 650; margin-bottom: 9px; }
  .new-game-form small { display: block; font-size: 11px; line-height: 1.45; margin-top: 9px; }
  .inline-form { display: flex; gap: 7px; }
  .save-list { display: grid; gap: 8px; margin-top: 18px; }
  .save-empty { color: var(--faint); font-size: 13px; line-height: 1.6; padding: 8px 2px; }
  .save-card { background: rgba(157, 174, 207, 0.05); border: 1px solid transparent; border-radius: 11px; padding: 12px; text-align: left; width: 100%; }
  .save-card:hover { background: var(--gold-soft); border-color: rgba(240, 189, 105, 0.35); }
  .save-card.active { background: var(--gold-soft); border-color: rgba(240, 189, 105, 0.35); }
  .save-card strong { display: block; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
  .save-card small { display: block; font-size: 11px; margin-top: 5px; }
  .game-column { min-width: 0; }
  .welcome-view::after { background: linear-gradient(135deg, transparent 40%, rgba(240, 189, 105, 0.07)); content: ""; inset: 0; pointer-events: none; position: absolute; }
  .welcome-art { color: var(--gold); font-size: 22px; opacity: 0.8; position: absolute; right: 12%; top: 15%; }
  .welcome-art span { display: inline-block; margin: 0 8px; }
  .welcome-art span:nth-child(2) { color: var(--teal); font-size: 68px; opacity: 0.32; transform: rotate(-18deg); }
  .welcome-view h1 { font-family: Georgia, serif; font-size: clamp(42px, 7vw, 82px); font-weight: 400; letter-spacing: -0.04em; line-height: 0.98; margin: 20px 0; max-width: 800px; position: relative; z-index: 1; }
  .welcome-view h1 em { color: var(--gold); font-style: normal; }
  .welcome-view p { color: var(--muted); font-size: 16px; line-height: 1.8; max-width: 520px; position: relative; z-index: 1; }
  .view-tab:hover { color: var(--text); }
  .summary-mana .meter { background: rgba(112, 166, 255, 0.16); }
  .summary-mana .meter span { background: linear-gradient(90deg, #6ea7ff, #b5d8ff); }
  .topbar { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: var(--topbar-height); padding: 0 max(16px, calc((100vw - 1240px) / 2)); position: sticky; top: 0; z-index: 40; background: rgba(11, 16, 32, 0.88); backdrop-filter: blur(18px); }
  .brand { align-items: center; color: var(--text); display: flex; gap: 9px; text-decoration: none; }
  .brand-mark { color: var(--gold); font-size: 22px; line-height: 1; }
  .brand strong { display: block; font-family: Georgia, serif; font-size: 16px; letter-spacing: 0.05em; }
  .topbar-button { align-items: center; background: rgba(157, 174, 207, 0.07); border: 1px solid var(--line); border-radius: 9px; color: var(--muted); display: inline-flex; font-size: 12px; justify-content: center; min-height: 36px; padding: 7px 11px; white-space: nowrap; }
  .topbar-button:hover { border-color: var(--gold); color: var(--gold); }
  .settings-menu { position: relative; }
  .settings-menu summary { cursor: pointer; list-style: none; }
  .settings-menu summary::-webkit-details-marker { display: none; }
  .settings-popover { background: rgba(15, 23, 42, 0.98); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 20px 55px rgba(0, 0, 0, 0.42); display: grid; gap: 12px; padding: 14px; position: absolute; right: 0; top: calc(100% + 9px); max-height: calc(100vh - var(--topbar-height) - 24px); overflow-y: auto; width: min(360px, calc(100vw - 28px)); z-index: 50; }
  .settings-popover .token-control { align-items: stretch; display: grid; gap: 6px; }
  .settings-popover .token-control input { width: 100%; }
  .settings-popover .button { width: 100%; }
  .settings-section { border-top: 1px solid var(--line); display: grid; gap: 8px; padding-top: 12px; }
  .settings-section h3 { font-size: 13px; margin: 2px 0 0; }
  .settings-label { color: var(--muted); font-size: 11px; }
  .settings-description { color: var(--faint); font-size: 10px; line-height: 1.5; margin: 0; }
  .settings-section select { background: #111c31; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); min-height: 38px; padding: 7px 9px; width: 100%; }
  .status-banner { min-height: 0; padding: 0 4vw; padding-left: max(16px, calc((100vw - 1240px) / 2)); padding-right: max(16px, calc((100vw - 1240px) / 2)); }
  .workspace { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); margin: 22px auto; max-width: 1240px; padding: 0 4vw 50px; padding-left: max(16px, calc((100vw - 1240px) / 2)); padding-right: max(16px, calc((100vw - 1240px) / 2)); }
  .welcome-view { min-height: 560px; overflow: hidden; padding: clamp(42px, 9vw, 120px) clamp(28px, 7vw, 100px); position: relative; }
  .summary-identity p { font-size: 11px; margin: 0; }
  .save-card-row { align-items: stretch; display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) auto; }
  .save-card-row .save-card { min-width: 0; }
  .save-delete { background: rgba(242, 139, 139, 0.06); border: 1px solid rgba(242, 139, 139, 0.18); border-radius: 9px; color: #e9a8a8; font-size: 10px; padding: 0 9px; }
  .save-delete:hover { background: rgba(242, 139, 139, 0.14); border-color: rgba(242, 139, 139, 0.42); color: #ffd0d0; }
  .summary-action:hover { background: rgba(240, 189, 105, 0.22); border-color: var(--gold); transform: translateY(-1px); }
  .summary-action:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  .version-pill { background: var(--gold-soft); border: 1px solid rgba(240, 189, 105, 0.25); border-radius: 999px; color: var(--gold); font-size: 10px; padding: 5px 8px; white-space: nowrap; }
  .version-pill strong { font-size: 12px; margin-left: 3px; }
  .view-tab.active { background: var(--gold-soft); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(240, 189, 105, 0.13); }
  .view-tab span { font-size: 18px; line-height: 1; }
  .view-tab small { color: inherit; font-size: 10px; font-weight: 650; letter-spacing: 0.02em; }
  .view-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
  .topbar-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
  .inline-form input { min-width: 0; width: 100%; flex: 1 1 0; }
  .inline-form .button { flex: 0 0 auto; min-width: 58px; white-space: nowrap; }
  .game-summary { background: linear-gradient(135deg, rgba(25, 37, 62, 0.98), rgba(15, 24, 43, 0.97)); border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22); margin-bottom: 8px; padding: 5px 9px; position: sticky; top: calc(var(--topbar-height) + 4px); z-index: 8; border-color: rgba(157, 174, 207, 0.24); }
  .summary-heading { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
  .summary-identity { min-width: 0; display: grid; }
  .summary-identity > .eyebrow { display: none; }
  .summary-title-row { align-items: center; display: flex; gap: 7px; min-width: 0; }
  .summary-title-row h1 { font-family: Georgia, serif; font-size: 16px; font-weight: 500; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.1; max-width: min(36vw, 320px); }
  .game-summary .game-subtitle { font-size: 10px; margin: 0; color: var(--muted); line-height: 1.2; margin-top: 3px; max-width: min(50vw, 460px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .summary-controls { align-items: center; display: flex; flex: 0 0 auto; flex-direction: row; gap: 5px; }
  .summary-state { background: rgba(116, 210, 194, 0.08); border: 1px solid rgba(116, 210, 194, 0.18); border-radius: 999px; flex: 0 0 auto; min-width: 0; padding: 4px 7px; text-align: center; }
  .summary-state span { color: var(--faint); display: none; font-size: 11px; }
  .summary-state strong { color: var(--teal); display: block; font-size: 11px; margin-top: 3px; margin: 0; white-space: nowrap; }
  .summary-action { align-items: center; background: linear-gradient(135deg, rgba(240, 189, 105, 0.17), rgba(240, 189, 105, 0.08)); border: 1px solid rgba(240, 189, 105, 0.34); border-radius: 8px; color: var(--gold); display: inline-flex; font-size: 10px; font-weight: 700; gap: 4px; justify-content: center; min-height: 29px; padding: 3px 8px; transition: background 160ms ease, border-color 160ms ease, transform 160ms ease; white-space: nowrap; }
  .summary-action > span:first-child { font-size: 12px; }
  .summary-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); display: grid; gap: 0; margin-top: 10px; border-top: 1px solid rgba(157, 174, 207, 0.12); margin: 4px -3px 0; padding-top: 4px; }
  .summary-health + .summary-health { border-left: 1px solid rgba(157, 174, 207, 0.13); }
  .summary-health { background: transparent; border: 0; border-radius: 0; min-height: 0; padding: 0 7px; align-content: center; display: grid; gap: 2px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 3px; }
  .summary-health .stat-label { font-size: 11px; gap: 3px; line-height: 1.25; }
  .summary-health .meter { margin-top: 7px; height: 3px; grid-column: 1; margin: 0; }
  .summary-stat { background: transparent; border: 0; border-radius: 0; min-height: 0; padding: 0 7px; align-content: center; border-left: 1px solid rgba(157, 174, 207, 0.13); align-items: center; display: flex; gap: 5px; justify-content: space-between; }
  .summary-stat > span { color: var(--muted); display: block; font-size: 11px; white-space: nowrap; }
  .summary-stat > strong { display: block; font-size: 10px; margin-top: 3px; line-height: 1.1; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .view-tab { align-items: center; background: transparent; border: 0; border-radius: 10px; color: var(--faint); display: flex; flex-direction: column; gap: 3px; justify-content: center; min-height: 48px; padding: 6px 8px; position: relative; transition: background 140ms ease, color 140ms ease; }
  .view-navigation { align-items: center; background: rgba(17, 24, 43, 0.88); border: 1px solid var(--border); border-radius: 14px; display: flex; gap: 5px; justify-content: center; margin: 10px 0 14px; padding: 5px; position: relative; }
  .view-navigation .view-tab { flex: 1 1 0; flex-direction: row; min-height: 42px; }
  .view-navigation .view-tab span[aria-hidden="true"] { font-size: 15px; }
  .mobile-more-toggle { display: none; }
  .view-more-menu { background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-panel); display: grid; gap: 4px; min-width: 160px; padding: 6px; position: absolute; right: 8px; top: calc(100% + 8px); z-index: 30; }
  .view-more-item { background: transparent; border: 0; border-radius: 8px; color: var(--text); min-height: 42px; padding: 8px 12px; text-align: left; }
  .view-more-item:hover, .view-more-item:focus-visible { background: var(--accent-soft); color: var(--accent); }
  .settings-advanced { border-top: 1px solid var(--border); padding-top: 10px; }
  .settings-advanced > summary { color: var(--muted); cursor: pointer; font-size: 12px; min-height: 38px; padding: 9px 0; }
  .settings-advanced[open] > summary { color: var(--accent); }
}
