:root {
  color-scheme: light;
  --mj-bg: #f4f1eb;
  --mj-bg-top: #f8f6f1;
  --mj-surface: rgba(255, 255, 255, .78);
  --mj-surface-solid: #fbfaf7;
  --mj-text: #171815;
  --mj-muted: #696b65;
  --mj-placeholder: #93958e;
  --mj-line: rgba(23, 24, 21, .13);
  --mj-line-strong: rgba(23, 24, 21, .23);
  --mj-accent: #2f4a3c;
  --mj-accent-hover: #3d5d4d;
  --mj-accent-soft: rgba(47, 74, 60, .09);
  --mj-warm: #b35a36;
  --mj-warm-soft: #f2e5dc;
  --mj-danger: #9b3f36;
  --mj-warning: #8a621f;
  --mj-radius-control: 6px;
  --mj-radius-panel: 8px;
  --mj-shadow-menu: 0 18px 45px rgba(30, 31, 28, .13);
  --mj-width: 1360px;
  --mj-fast: 160ms;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--mj-bg); color: var(--mj-text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { color: inherit; font: inherit; letter-spacing: 0; }
button, summary, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { border: 0; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid rgba(47, 74, 60, .22); outline-offset: 2px; }

.brand-mark { position: relative; display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; }
.brand-mark span { position: absolute; border: 1px solid var(--mj-accent); border-radius: 50%; }
.brand-mark span:nth-child(1) { width: 31px; height: 31px; opacity: .35; }
.brand-mark span:nth-child(2) { width: 21px; height: 21px; opacity: .65; }
.brand-mark span:nth-child(3) { width: 9px; height: 9px; background: var(--mj-accent); }

.app-header { position: sticky; z-index: 30; top: 0; height: 82px; border-bottom: 1px solid var(--mj-line); background: rgba(248, 246, 241, .93); backdrop-filter: blur(16px); }
.header-inner { width: min(calc(100% - 40px), var(--mj-width)); height: 100%; margin: 0 auto; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(260px, 520px) minmax(180px, 1fr); align-items: center; gap: 24px; }
.product-brand { min-width: 0; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.product-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.product-name small { color: var(--mj-muted); font-size: 12px; font-weight: 500; }
.header-search { position: relative; height: 44px; display: flex; align-items: center; }
.header-search > svg { position: absolute; left: 13px; color: var(--mj-muted); }
.header-search input { width: 100%; height: 44px; padding: 0 42px 0 40px; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: var(--mj-surface-solid); outline: 0; }
.header-search input:focus { border-color: var(--mj-accent); box-shadow: 0 0 0 3px var(--mj-accent-soft); }
.header-search input::placeholder { color: var(--mj-placeholder); }
.header-search button { width: 38px; height: 38px; position: absolute; right: 3px; display: grid; place-items: center; background: transparent; color: var(--mj-muted); cursor: pointer; }
.header-search button svg { width: 15px; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }

.button { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--mj-radius-control); background: transparent; cursor: pointer; font-size: 13px; font-weight: 650; text-decoration: none; transition: background var(--mj-fast), border-color var(--mj-fast), color var(--mj-fast); }
.button:disabled { cursor: wait; opacity: .58; }
.button-primary { background: var(--mj-accent); color: #fff; }
.button-primary:hover { background: var(--mj-accent-hover); }
.button-secondary { border-color: var(--mj-line-strong); background: rgba(255,255,255,.48); }
.button-secondary:hover { border-color: var(--mj-accent); background: #fff; color: var(--mj-accent); }
.button-danger { border-color: rgba(155,63,54,.3); color: var(--mj-danger); }
.button-danger:hover { background: rgba(155,63,54,.07); }
.icon-button { width: 42px; height: 42px; padding: 0; display: inline-grid; flex: 0 0 42px; place-items: center; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: var(--mj-surface); cursor: pointer; }
.icon-button:hover { border-color: var(--mj-accent); color: var(--mj-accent); }

.account-menu { position: relative; }
.account-menu > summary { min-height: 42px; padding: 0 7px 0 5px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--mj-radius-control); list-style: none; cursor: pointer; font-size: 13px; font-weight: 650; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:hover { border-color: var(--mj-line); background: var(--mj-surface); }
.account-menu > summary > svg { width: 14px; color: var(--mj-muted); }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--mj-accent); color: #fff; font-size: 12px; }
.account-menu-panel { width: 240px; padding: 7px; position: absolute; top: calc(100% + 8px); right: 0; border: 1px solid var(--mj-line); border-radius: 7px; background: var(--mj-surface-solid); box-shadow: var(--mj-shadow-menu); }
.service-switcher-menu a, .menu-command { width: 100%; min-height: 39px; padding: 0 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 5px; background: transparent; font-size: 13px; text-decoration: none; cursor: pointer; }
.service-switcher-menu a:hover, .menu-command:hover { background: var(--mj-accent-soft); color: var(--mj-accent); }
.service-switcher-menu a[aria-current="page"] { color: var(--mj-accent); font-weight: 700; }
.service-switcher-menu svg, .menu-command svg { width: 15px; }
.service-switcher-divider { height: 1px; margin: 5px 7px; display: block; background: var(--mj-line); }
.account-menu-panel form { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--mj-line); }
.menu-command { justify-content: flex-start; border: 0; }

.library-shell { width: min(calc(100% - 40px), var(--mj-width)); margin: 0 auto; padding: 52px 0 58px; }
.notice { min-height: 44px; margin: -24px 0 28px; padding: 10px 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: var(--mj-surface); font-size: 13px; }
.notice.is-error { border-color: rgba(155,63,54,.28); color: var(--mj-danger); }
.library-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 36px; }
.eyebrow { margin: 0 0 8px; color: var(--mj-accent); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.library-heading h1 { margin: 0; font-size: 38px; line-height: 1.12; font-weight: 630; }
.heading-copy { margin: 10px 0 0; color: var(--mj-muted); font-size: 14px; }
.library-stats { margin: 0; display: flex; align-items: stretch; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-panel); background: var(--mj-surface); }
.library-stats div { min-width: 92px; padding: 12px 18px; }
.library-stats div + div { border-left: 1px solid var(--mj-line); }
.library-stats dt { color: var(--mj-muted); font-size: 11px; font-weight: 650; }
.library-stats dd { margin: 3px 0 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }

.library-toolbar { min-height: 66px; margin: 34px 0 22px; padding: 10px 0; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--mj-line); border-bottom: 1px solid var(--mj-line); }
.status-tabs { height: 42px; padding: 3px; display: flex; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: rgba(255,255,255,.45); }
.status-tabs button { padding: 0 12px; border-radius: 4px; background: transparent; color: var(--mj-muted); cursor: pointer; font-size: 12px; font-weight: 650; }
.status-tabs button.active { background: var(--mj-surface-solid); box-shadow: 0 1px 3px rgba(30,31,28,.09); color: var(--mj-accent); }
.select-field { position: relative; height: 42px; display: flex; align-items: center; }
.select-field select { min-width: 145px; height: 42px; padding: 0 34px 0 12px; appearance: none; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: var(--mj-surface-solid); cursor: pointer; font-size: 13px; outline: 0; }
.select-field select:focus { border-color: var(--mj-accent); box-shadow: 0 0 0 3px var(--mj-accent-soft); }
.select-field > svg { width: 14px; position: absolute; right: 10px; pointer-events: none; color: var(--mj-muted); }
.sort-field { margin-left: auto; }
.segmented-control { height: 42px; padding: 3px; display: flex; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: rgba(255,255,255,.45); }
.segmented-control button { width: 38px; display: grid; place-items: center; border-radius: 4px; background: transparent; color: var(--mj-muted); cursor: pointer; }
.segmented-control button.active { background: var(--mj-surface-solid); box-shadow: 0 1px 3px rgba(30,31,28,.09); color: var(--mj-accent); }
.result-count { min-width: 58px; color: var(--mj-muted); font-size: 12px; text-align: right; white-space: nowrap; }

.game-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px 18px; }
.game-card { min-width: 0; padding: 0; display: block; overflow: hidden; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-panel); background: var(--mj-surface); text-align: left; cursor: pointer; transition: border-color var(--mj-fast), box-shadow var(--mj-fast), transform var(--mj-fast); }
.game-card:hover { border-color: var(--mj-line-strong); box-shadow: 0 14px 34px rgba(30,31,28,.10); transform: translateY(-2px); }
.game-cover { position: relative; display: grid; aspect-ratio: 4 / 5; place-items: center; overflow: hidden; border-bottom: 1px solid var(--mj-line); background: #e9e6df; }
.game-cover img { width: 100%; height: 100%; display: block; object-fit: contain; transition: transform 240ms ease; }
.game-card:hover .game-cover img { transform: scale(1.018); }
.cover-placeholder { width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--mj-muted); font-size: 11px; }
.cover-placeholder svg { width: 28px; height: 28px; color: var(--mj-accent); opacity: .68; }
.status-badge { min-height: 27px; padding: 0 8px; position: absolute; top: 9px; left: 9px; display: inline-flex; align-items: center; gap: 5px; border-radius: 4px; background: rgba(251,250,247,.94); color: var(--mj-text); box-shadow: 0 2px 8px rgba(23,24,21,.12); font-size: 10px; font-weight: 700; }
.status-badge svg { width: 12px; height: 12px; }
.status-badge.wishlist { color: var(--mj-danger); }
.status-badge.preordered { color: var(--mj-warm); }
.game-card-body { min-width: 0; min-height: 128px; padding: 13px 14px 14px; display: flex; flex-direction: column; }
.game-title-row { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.game-title-row strong { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.game-title-row > span { flex: 0 0 auto; color: var(--mj-muted); font-size: 11px; }
.game-facts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 7px 13px; color: var(--mj-muted); font-size: 11px; }
.game-facts > span { display: inline-flex; align-items: center; gap: 5px; }
.game-facts svg { width: 13px; height: 13px; }
.tag-row { margin-top: auto; padding-top: 13px; display: flex; gap: 5px; overflow: hidden; }
.tag-row span, .detail-tags span { min-width: 0; padding: 4px 7px; overflow: hidden; border-radius: 4px; background: var(--mj-accent-soft); color: var(--mj-accent); font-size: 10px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.game-grid.is-list { grid-template-columns: 1fr 1fr; gap: 10px; }
.game-grid.is-list .game-card { display: grid; grid-template-columns: 104px minmax(0, 1fr); }
.game-grid.is-list .game-cover { aspect-ratio: 4 / 5; border: 0; border-right: 1px solid var(--mj-line); }
.game-grid.is-list .game-card-body { min-height: 130px; }
.game-skeleton { aspect-ratio: 4 / 7; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-panel); background: rgba(255,255,255,.46); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .48; } }
.library-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 9px; color: var(--mj-muted); text-align: center; }
.library-state svg { width: 27px; height: 27px; }
.library-state strong { color: var(--mj-text); font-size: 14px; }
.library-state span { font-size: 13px; }
.library-state.is-error { color: var(--mj-danger); }
.library-footer { margin-top: 56px; padding-top: 22px; display: flex; justify-content: center; border-top: 1px solid var(--mj-line); }
.bgg-credit { display: block; text-decoration: none; }
.bgg-credit img { width: 154px; height: auto; display: block; }

.dialog { width: 100%; max-width: none; height: 100%; max-height: none; padding: 24px; border: 0; background: transparent; }
.dialog::backdrop { background: rgba(23,24,21,.55); backdrop-filter: blur(3px); }
.dialog-panel { width: min(100%, 920px); max-height: calc(100dvh - 48px); margin: auto; position: relative; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-panel); background: var(--mj-surface-solid); box-shadow: 0 30px 80px rgba(20,22,19,.22); }
.dialog-close { position: absolute; z-index: 2; top: 14px; right: 14px; background: rgba(251,250,247,.92); }
.detail-panel { width: min(100%, 940px); display: block; overflow: auto; }
.detail-content { min-height: 520px; display: grid; grid-template-columns: minmax(280px, 42%) minmax(0, 1fr); }
.detail-cover { min-height: 520px; display: grid; place-items: center; overflow: hidden; border-right: 1px solid var(--mj-line); background: #e9e6df; }
.detail-cover img { width: 100%; height: 100%; max-height: 700px; object-fit: contain; }
.detail-copy { min-width: 0; padding: 42px 42px 36px; }
.detail-copy h2 { margin: 0; padding-right: 28px; font-size: 30px; line-height: 1.13; font-weight: 650; }
.detail-facts { margin: 27px 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--mj-line); border-bottom: 1px solid var(--mj-line); }
.detail-facts div { min-width: 0; padding: 13px 8px 13px 0; display: grid; grid-template-columns: 22px 1fr; align-items: center; }
.detail-facts div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--mj-line); }
.detail-facts div:nth-child(n+3) { border-top: 1px solid var(--mj-line); }
.detail-facts svg { grid-row: 1 / 3; width: 16px; color: var(--mj-accent); }
.detail-facts span { color: var(--mj-muted); font-size: 10px; }
.detail-facts strong { margin-top: 2px; font-size: 12px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-section { margin-top: 25px; }
.detail-section h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; }
.detail-section p { margin: 0; color: var(--mj-muted); font-size: 13px; line-height: 1.65; white-space: pre-line; }
.personal-notes { padding: 14px; border-left: 3px solid var(--mj-warm); background: var(--mj-warm-soft); }
.personal-notes p + p { margin-top: 5px; }
.bgg-link { margin-top: 25px; display: inline-flex; align-items: center; gap: 7px; color: var(--mj-warm); font-size: 12px; font-weight: 650; text-decoration: none; }
.bgg-link svg { width: 14px; }
.detail-panel > .dialog-footer { position: sticky; bottom: 0; justify-content: flex-end; }

.dialog-header { min-height: 78px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--mj-line); }
.dialog-header .eyebrow { margin-bottom: 4px; }
.dialog-header h2 { margin: 0; font-size: 21px; font-weight: 650; }
.dialog-body { min-height: 0; overflow-y: auto; }
.form-sections { padding: 22px; display: grid; gap: 18px; }
.form-sections fieldset { margin: 0; padding: 0; border: 0; }
.form-sections legend { width: 100%; margin-bottom: 13px; padding-bottom: 8px; border-bottom: 1px solid var(--mj-line); color: var(--mj-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field.wide { grid-column: 1 / -1; }
.field { min-width: 0; display: grid; gap: 6px; }
.field > span:first-child { color: var(--mj-muted); font-size: 11px; font-weight: 650; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: #fff; outline: 0; }
.field input, .field select { height: 42px; padding: 0 11px; }
.field textarea { min-height: 84px; padding: 10px 11px; line-height: 1.5; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--mj-accent); box-shadow: 0 0 0 3px var(--mj-accent-soft); }
.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix input { padding-right: 42px; }
.input-suffix > span { position: absolute; right: 11px; color: var(--mj-muted); font-size: 11px; }
.bgg-import { padding: 15px !important; border: 1px solid rgba(179,90,54,.25) !important; border-radius: var(--mj-radius-panel); background: var(--mj-warm-soft); }
.bgg-import legend { width: auto; margin: 0 0 5px; padding: 0 5px; border: 0; color: var(--mj-warm); background: var(--mj-warm-soft); }
.import-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.import-row .button { background: #fff; }
.field-help { margin: 8px 0 0; color: var(--mj-muted); font-size: 11px; line-height: 1.4; }
.field-help.is-error { color: var(--mj-danger); }
.field-help.is-success { color: var(--mj-accent); }
.dialog-footer { min-height: 70px; padding: 11px 22px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--mj-line); background: rgba(244,241,235,.62); }
.footer-spacer { flex: 1; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 36px)); padding: 13px 15px; border: 1px solid var(--mj-line); border-radius: var(--mj-radius-control); background: #fff; box-shadow: var(--mj-shadow-menu); font-size: 13px; }
.toast.success { border-left: 3px solid var(--mj-accent); }
.toast.error { border-left: 3px solid var(--mj-danger); }
.toast.warning { border-left: 3px solid var(--mj-warning); }
.error-shell { width: min(calc(100% - 40px), 560px); min-height: 100vh; margin: 0 auto; display: grid; place-content: center; justify-items: start; }
.error-shell .eyebrow { margin-top: 18px; }
.error-shell h1 { margin: 0; font-size: 34px; }
.error-shell p:not(.eyebrow) { margin: 12px 0 24px; color: var(--mj-muted); }

@media (max-width: 1120px) {
  .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .header-inner { grid-template-columns: auto minmax(240px, 1fr) auto; }
  .account-menu > summary > span:not(.avatar) { display: none; }
}
@media (max-width: 880px) {
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-toolbar { flex-wrap: wrap; }
  .sort-field { margin-left: 0; }
  .result-count { margin-left: auto; }
  .detail-content { grid-template-columns: minmax(220px, 36%) minmax(0, 1fr); }
  .detail-copy { padding: 36px 28px 30px; }
}
@media (max-width: 680px) {
  .app-header { height: auto; min-height: 70px; }
  .header-inner { width: calc(100% - 28px); padding: 12px 0; grid-template-columns: 1fr auto; gap: 10px; }
  .header-search { grid-column: 1 / -1; grid-row: 2; }
  .product-name small, .add-button span, .login-button span { display: none; }
  .add-button, .login-button { width: 42px; padding: 0; }
  .library-shell { width: calc(100% - 28px); padding-top: 32px; }
  .library-heading { align-items: flex-start; flex-direction: column; gap: 22px; }
  .library-heading h1 { font-size: 30px; }
  .library-stats { width: 100%; }
  .library-stats div { flex: 1; }
  .library-toolbar { margin-top: 26px; align-items: stretch; }
  .status-tabs { width: 100%; overflow-x: auto; }
  .status-tabs button { flex: 1 0 auto; }
  .select-field { flex: 1 1 calc(50% - 5px); }
  .select-field select { width: 100%; min-width: 0; }
  .sort-field { flex-basis: calc(100% - 104px); }
  .result-count { width: 100%; text-align: left; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .game-card-body { min-height: 116px; padding: 10px; }
  .game-title-row strong { font-size: 12px; }
  .game-facts { gap: 6px; font-size: 10px; }
  .tag-row { padding-top: 10px; }
  .game-grid.is-list { grid-template-columns: 1fr; }
  .dialog { padding: 0; }
  .dialog-panel { width: 100%; min-height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .detail-content { display: block; }
  .detail-cover { min-height: 0; aspect-ratio: 4 / 3; border: 0; border-bottom: 1px solid var(--mj-line); }
  .detail-cover img { max-height: none; }
  .detail-copy { padding: 28px 20px 30px; }
  .detail-copy h2 { font-size: 26px; }
  .field-grid.two { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .form-sections { padding: 17px 14px; }
  .import-row { grid-template-columns: 1fr; }
  .import-row .button { width: 100%; }
  .dialog-footer { padding: 10px 14px; }
}
@media (max-width: 420px) {
  .game-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .game-facts { display: grid; }
  .tag-row span:nth-child(n+2) { display: none; }
  .dialog-footer .button { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
