/* ==========================================================================
   Dynamic Dexter design tokens (shared with TV / Movie trackers)
   ========================================================================== */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #eef1f5;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e6ec;
  --border-strong: #cdd4dd;

  --brand: #ff7828;
  --brand-strong: #e8620f;
  --brand-ink: #b84a08;
  --brand-soft: rgba(255, 120, 40, 0.12);
  --brand-ring: rgba(255, 120, 40, 0.32);

  --navy: #0f172a;
  --navy-2: #1e293b;
  --danger: #c0362c;
  --danger-soft: rgba(192, 54, 44, 0.1);
  --success: #1c8a4a;
  --success-soft: rgba(28, 138, 74, 0.12);
  --violet: #6d4bd8;
  --violet-soft: rgba(109, 75, 216, 0.12);
  --heart: #e0245e;

  --btn-bg: var(--navy);
  --btn-fg: #ffffff;
  --btn-hover: var(--brand);
  --focus: var(--brand);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -2px rgba(15, 23, 42, 0.05), 0 10px 24px -6px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.28);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2rem);
  font-weight: 800;
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

strong {
  font-weight: 700;
}

svg {
  flex: 0 0 auto;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input[type="checkbox"] {
  accent-color: var(--brand);
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  flex: 0 0 auto;
}

.wrap {
  width: min(1240px, 92%);
  margin: 0 auto;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding-top: env(safe-area-inset-top);
  background: rgba(244, 245, 247, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand nav account";
  align-items: center;
  gap: 24px;
  padding: 10px 0;
}

.header-row.is-guest {
  grid-template-columns: 1fr;
  grid-template-areas: "brand";
  justify-items: center;
}

.brand {
  grid-area: brand;
  display: block;
  height: 56px;
}

.header-row:not(.is-guest) .brand {
  justify-self: start;
}

.brand-logo {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.header-nav {
  grid-area: nav;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.header-link .icon {
  color: var(--muted);
  transition: color 0.15s ease;
}

.header-link:hover {
  background: var(--panel-3);
  color: var(--text);
}

.header-link:hover .icon {
  color: var(--text);
}

.header-link.is-active {
  background: var(--navy);
  color: #fff;
}

.header-link.is-active .icon {
  color: var(--brand);
}

.header-account {
  grid-area: account;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 3px 14px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.header-profile-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), #ff9a52);
  color: #fff;
  font-weight: 700;
  user-select: none;
}

.header-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.header-logout-form {
  display: flex;
  margin: 0;
}

.header-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.header-logout:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   Layout shell
   ========================================================================== */
main.wrap {
  flex: 1 0 auto;
  padding: 28px 0 56px;
}

.hub-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  margin-top: auto;
}

.hub-footer-inner {
  display: flex;
  justify-content: center;
  text-align: center;
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    background 0.18s ease,
    visibility 0.18s ease;
  z-index: 1100;
}

.back-to-top .icon {
  width: 20px;
  height: 20px;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--brand);
}

/* ==========================================================================
   Flash + toasts
   ========================================================================== */
.flash {
  margin: 18px 0 0;
  padding: 12px 16px 12px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  border-left-width: 4px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.flash-error {
  background: #fdf3f2;
  border-color: rgba(192, 54, 44, 0.25);
  border-left-color: var(--danger);
  color: #8a241d;
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1500;
  display: grid;
  gap: 10px;
  width: min(440px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.32s var(--bounce) both;
}

.toast.is-leaving {
  animation: toastOut 0.22s ease both;
}

.toast .icon {
  color: var(--brand);
}

.toast.is-error .icon {
  color: #ff8a80;
}

.toast-msg {
  flex: 1;
  min-width: 0;
}

.toast-action {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.toast-action:hover {
  background: var(--brand);
  color: var(--navy);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--btn-bg);
  border-radius: 12px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.08s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
  border-color: var(--btn-hover);
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn.secondary {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.btn.secondary[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.btn.secondary[aria-pressed="true"] .icon {
  color: var(--brand);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  box-shadow: none;
  padding: 0 12px;
}

.btn-ghost:hover {
  background: var(--panel-3);
  border-color: transparent;
  color: var(--text);
}

.btn.danger {
  background: var(--panel);
  border-color: rgba(192, 54, 44, 0.35);
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--navy);
}

.btn-brand:hover {
  background: #ff8c47;
  border-color: #ff8c47;
  color: var(--navy);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  box-shadow: none;
}

.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  cursor: progress;
  opacity: 0.75;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.icon-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}

.show-sm {
  display: none;
}

/* ==========================================================================
   Cards, headings, chips
   ========================================================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card h1,
.card h2 {
  margin: 0 0 8px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 18px;
}

.card-head h2 {
  margin: 0;
}

.card-head-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.card-head-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--brand-ink);
}

.card-head-link:hover {
  text-decoration: underline;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0 0 4px;
}

.page-sub {
  margin: 0;
  color: var(--muted);
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 380px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.narrow {
  max-width: 440px;
}

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 48px 24px;
}

.empty p {
  max-width: 420px;
}

.empty-icon {
  width: 44px;
  height: 44px;
  color: var(--brand);
  margin-bottom: 8px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.chip .icon {
  width: 15px;
  height: 15px;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--text);
}

.chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.chip.is-active .icon {
  color: var(--brand);
}

.tag {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.8rem;
  font-weight: 600;
}

.tag-soft {
  background: var(--panel-3);
  color: var(--text-2);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.stack {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--text-2);
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: #94a0b0;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b5bfcb;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-field {
  position: relative;
  width: 100%;
}

.search-field > .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding-left: 42px;
}

.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font: 600 0.75rem/1.4 var(--font);
  text-align: center;
  pointer-events: none;
}

.search-field input:focus ~ .search-kbd,
.search-field input:not(:placeholder-shown) ~ .search-kbd {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.span-2 {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label {
  display: block;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-help {
  margin: -6px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  justify-self: start;
}

.segmented label {
  position: relative;
  margin: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.segmented input:checked + span {
  background: var(--navy);
  color: #fff;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.file-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
}

.file-input::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.file-input:hover::file-selector-button {
  border-color: var(--brand);
}

.cover-picker {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cover-picker-preview {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-3);
  color: var(--muted);
}

.cover-picker-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-picker-preview .icon {
  width: 28px;
  height: 28px;
}

.cover-picker-actions {
  display: grid;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.cover-picker-actions .form-help {
  margin: 0;
}

/* Password reveal */
.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 3.2em;
}

.password-toggle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 1px;
  background: transparent;
  border: none;
  padding: 0 0.7em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  border-radius: 0 11px 11px 0;
  transition: color 0.15s ease;
}

.password-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .password-icon--hide,
.password-toggle.is-revealed .password-icon--show {
  display: none;
}

.password-toggle.is-revealed .password-icon--hide {
  display: block;
}

.password-toggle:hover,
.password-toggle.is-revealed {
  color: var(--brand-strong);
}

/* ==========================================================================
   Login
   ========================================================================== */
.auth-card {
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  font-size: 1.75rem;
  margin-bottom: 4px;
}

.auth-lead {
  color: var(--muted);
  margin: 0;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.auth-lead.is-swapping {
  opacity: 0;
  transform: translateY(3px);
}

.auth-form {
  margin-top: 22px;
}

.auth-actions {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.is-login-scene main.wrap {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  align-content: center;
}

.is-login-scene main.wrap::before {
  content: "";
  position: fixed;
  inset: 70px -16vw -8vh -16vw;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(40% 30% at 18% 22%, rgba(255, 120, 40, 0.2), transparent 70%),
    radial-gradient(36% 26% at 78% 28%, rgba(15, 23, 42, 0.12), transparent 70%),
    radial-gradient(45% 36% at 52% 74%, rgba(255, 120, 40, 0.13), transparent 72%);
  filter: blur(26px);
  animation: loginAmbientDrift 12s ease-in-out infinite alternate;
}

.login-card {
  position: relative;
  overflow: hidden;
}

.login-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background: repeating-linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.26) 0px,
    rgba(15, 23, 42, 0.26) 1px,
    transparent 1px,
    transparent 3px
  );
}

.login-dice {
  position: absolute;
  top: 26px;
  right: 26px;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff4ec, #ffe6d5);
  color: var(--brand-strong);
  transform: rotate(12deg);
  box-shadow: var(--shadow-sm);
  animation: diceWobble 5s ease-in-out infinite;
}

.login-dice .icon {
  width: 30px;
  height: 30px;
}

.login-title.is-tuning {
  animation: loginTitleIn 0.5s var(--ease) both;
}

.btn[data-login-submit].is-submitting {
  background: linear-gradient(90deg, var(--btn-bg), #22345e, var(--btn-bg));
  background-size: 220% 100%;
  animation: loginSubmitSweep 1s linear infinite;
}

@keyframes loginAmbientDrift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(0, -8px, 0) scale(1.03);
  }
}

@keyframes loginTitleIn {
  from {
    opacity: 0;
    transform: translateY(4px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes loginSubmitSweep {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 220% 50%;
  }
}

@keyframes diceWobble {
  0%,
  80%,
  100% {
    transform: rotate(12deg);
  }
  86% {
    transform: rotate(-14deg) scale(1.05);
  }
  92% {
    transform: rotate(24deg);
  }
}

/* ==========================================================================
   Box-art covers (board game boxes vary in shape, so art is contained over a blurred backdrop)
   ========================================================================== */
.cover-frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel-3), #dfe5ec);
}

.cover {
  position: absolute;
  inset: 0;
  display: block;
}

.cover-backdrop {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(18px) saturate(1.2);
  opacity: 0.55;
}

.cover-img {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.35));
  transition: transform 0.4s var(--ease);
}

.cover-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 14px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
}

.cover-placeholder .icon {
  width: 32px;
  height: 32px;
  color: var(--brand);
}

.cover-thumb .cover-placeholder span {
  display: none;
}

.cover-thumb .cover-placeholder .icon {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Home
   ========================================================================== */
.home-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
  padding: 32px;
  border-radius: var(--radius-lg);
  color: #e2e8f0;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 120, 40, 0.28), transparent 55%),
    radial-gradient(80% 120% at 0% 100%, rgba(56, 89, 160, 0.35), transparent 60%),
    var(--navy);
  box-shadow: var(--shadow-md);
}

/* Subtle game-board grid in the hero */
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.9) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.9) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(100deg, transparent 20%, #000 75%);
  -webkit-mask-image: linear-gradient(100deg, transparent 20%, #000 75%);
}

.home-hero > * {
  position: relative;
}

.home-hero-main {
  min-width: 0;
  flex: 1 1 auto;
}

.home-eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffa66e;
}

.home-greeting {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem);
}

.home-hero-sub {
  margin: 0 0 20px;
  max-width: 46ch;
  color: #cbd5e1;
}

.home-hero-sub strong {
  color: #fff;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-insights {
  flex: 0 1 440px;
  min-width: 0;
}

.home-continue {
  display: block;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: inherit;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.home-continue:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 120, 40, 0.55);
}

.home-rotator-frame {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  transition:
    opacity 0.42s ease,
    transform 0.42s ease;
}

.home-rotator-frame.is-fading {
  opacity: 0;
  transform: translateY(5px);
}

.home-continue-poster {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.home-continue-img {
  position: absolute;
  inset: 6%;
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.home-continue-placeholder {
  width: 30px;
  height: 30px;
  color: var(--brand);
}

.home-continue-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.home-insight-key {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.home-insight-title {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-insight-meta {
  color: #cbd5e1;
  font-size: 0.92rem;
}

.home-continue-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: #ffa66e;
  font-size: 0.84rem;
  font-weight: 700;
}

.home-continue-cta .icon {
  width: 15px;
  height: 15px;
  transition: transform 0.15s ease;
}

.home-continue:hover .home-continue-cta .icon {
  transform: translateX(3px);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.home-section {
  margin-top: 32px;
}

.info-card {
  display: flex;
  flex-direction: column;
}

.stat-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  min-height: 116px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}

a.stat-tile:hover {
  border-color: var(--brand-ring);
  transform: translateY(-2px);
}

.stat-tile-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--muted);
  opacity: 0.7;
}

.stat-tile-value {
  font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.3rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-tile-label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-tile-accent {
  background: linear-gradient(135deg, #fff4ec, #ffe6d5);
  border-color: rgba(255, 120, 40, 0.3);
}

.stat-tile-accent .stat-tile-value,
.stat-tile-accent .stat-tile-icon {
  color: var(--brand-ink);
}

/* "What should we play?" picker */
.picker-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px 20px;
  margin-bottom: 16px;
}

.picker-field {
  display: grid;
  gap: 8px;
  align-content: start;
}

.stepper {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
}

.stepper-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--text);
  font: 700 1.1rem/1 var(--font);
  cursor: pointer;
  transition: background 0.15s ease;
}

.stepper-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.stepper-value {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.picker-stage {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  background:
    radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.08) 1px, transparent 0) 0 0 / 16px 16px,
    var(--panel-2);
}

.picker-idle {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.picker-idle p {
  margin: 0;
  max-width: 42ch;
  font-size: 0.92rem;
}

.picker-die {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.picker-die .icon {
  width: 30px;
  height: 30px;
}

.picker-die.is-rolling {
  animation: dieRoll 0.5s linear infinite;
}

.picker-result {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  width: 100%;
}

.picker-result.is-landed {
  animation: pickLand 0.45s var(--bounce) both;
}

.picker-result-cover {
  display: grid;
  place-items: center;
  width: 96px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.picker-result-cover img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.picker-result-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.picker-result-key {
  color: var(--brand-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.picker-result-title {
  font-size: 1.2rem;
  line-height: 1.25;
}

.picker-result-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.picker-result:hover .picker-result-title {
  color: var(--brand-ink);
}

.picker-result.is-shuffling {
  opacity: 0.55;
  filter: blur(0.5px);
}

.picker-roll .icon {
  width: 20px;
  height: 20px;
}

@keyframes dieRoll {
  0% {
    transform: rotate(0) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(0.9);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes pickLand {
  from {
    transform: scale(0.92);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* Shelves */
.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.shelf-item {
  display: grid;
  gap: 8px;
  scroll-snap-align: start;
  min-width: 0;
}

.shelf-item .cover-frame {
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition:
    transform 0.22s var(--ease),
    box-shadow 0.22s ease;
}

.shelf-item:hover .cover-frame {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.shelf-item .poster-badge {
  position: absolute;
  top: 8px;
  left: 8px;
}

.shelf-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.3;
}

.mini-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.mini-shelf-item .cover-frame {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s var(--ease);
}

.mini-shelf-item:hover .cover-frame {
  transform: translateY(-3px) rotate(-2deg);
}

.mini-shelf-item .cover-placeholder span {
  display: none;
}

.mini-empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 16px;
  text-align: center;
}

.mini-empty p {
  max-width: 40ch;
  margin: 0 0 8px;
}

.play-feed {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.play-feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.play-feed-item:hover {
  background: var(--panel-2);
}

.cover-thumb {
  flex: 0 0 auto;
  width: 48px;
  border-radius: 10px;
}

.play-feed-body {
  display: grid;
  min-width: 0;
}

.play-feed-body strong,
.play-feed-body span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-feed-body span {
  font-size: 0.86rem;
}

/* ==========================================================================
   My Games
   ========================================================================== */
.games-search-wrap {
  max-width: 360px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: var(--radius);
}

.toolbar-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-wrap > .icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.select-wrap select {
  min-height: 38px;
  padding: 6px 34px 6px 36px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
}

.select-wrap select.is-set {
  border-color: var(--navy);
  color: var(--text);
}

.toolbar-reorder {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.88rem;
}

.results-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 24px;
  margin-bottom: 14px;
}

.results-line p {
  margin: 0;
  font-size: 0.9rem;
}

.reorder-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.92rem;
  font-weight: 550;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 22px;
}

.card.game-card {
  position: relative;
  display: flex;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  transition:
    transform 0.22s var(--ease),
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 120, 40, 0.4);
  box-shadow: var(--shadow-md);
}

.game-card:hover .cover-img {
  transform: scale(1.05);
}

.game-card.is-moved {
  animation: cardMoved 0.5s var(--ease);
}

.game-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.game-link .cover-frame {
  border-radius: 0;
}

.cover-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
}

.poster-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.poster-badge .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}

.poster-badge.is-expansion {
  background: rgba(109, 75, 216, 0.9);
}

.poster-badge.is-rating {
  position: absolute;
  left: 10px;
  bottom: 10px;
}

.poster-badge.is-rating .icon {
  color: var(--brand);
  fill: var(--brand);
}

.card-body {
  padding: 14px 14px 16px;
  display: grid;
  gap: 6px;
  flex: 1;
  align-content: start;
  min-width: 0;
}

.game-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  min-height: 2.6em;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 550;
}

.game-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.game-meta .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.game-plays {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}

.game-plays.is-unplayed {
  color: var(--muted);
  font-weight: 500;
}

.fav-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  transition:
    color 0.15s ease,
    transform 0.15s ease;
}

.fav-toggle:hover {
  color: var(--heart);
  transform: scale(1.08);
}

.fav-toggle.is-on {
  color: var(--heart);
}

.fav-toggle.is-on .icon,
.pill-toggle.is-on .icon {
  fill: currentColor;
}

.fav-toggle.is-popping,
.pill-toggle.is-popping .icon {
  animation: heartPop 0.4s var(--bounce);
}

.reorder-controls {
  position: absolute;
  inset: auto 8px 8px auto;
  display: flex;
  gap: 6px;
}

.reorder-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

.reorder-btn:hover {
  background: var(--brand);
  color: var(--navy);
}

.reorder-btn[disabled] {
  opacity: 0.35;
  cursor: default;
  background: var(--navy);
  color: #fff;
}

.is-reordering .game-card:hover {
  transform: none;
}

.is-reordering .game-card .card-body {
  padding-bottom: 58px;
}

@keyframes heartPop {
  40% {
    transform: scale(1.3);
  }
}

@keyframes cardMoved {
  from {
    box-shadow: 0 0 0 4px var(--brand-ring);
  }
}

/* ==========================================================================
   Game detail
   ========================================================================== */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.page-actions-right {
  display: flex;
  gap: 10px;
}

.page-actions .btn {
  min-height: 40px;
}

.game-header {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-areas:
    "cover heading"
    "cover meta";
  grid-template-rows: auto 1fr;
  column-gap: 32px;
  margin-bottom: 24px;
  padding: 28px;
}

.game-header-cover {
  grid-area: cover;
  align-self: start;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.game-heading {
  grid-area: heading;
  min-width: 0;
}

.game-heading h1 {
  margin: 0 0 6px;
}

.game-tagline {
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 1.02rem;
  max-width: 60ch;
}

.game-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.pill-toggle,
.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.pill-toggle .icon,
.pill-link .icon {
  width: 16px;
  height: 16px;
}

.pill-toggle:hover,
.pill-link:hover {
  border-color: var(--brand);
  color: var(--text);
}

.pill-toggle.is-on {
  border-color: rgba(224, 36, 94, 0.35);
  background: rgba(224, 36, 94, 0.08);
  color: var(--heart);
}

.game-meta-block {
  grid-area: meta;
  min-width: 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.stat-icon {
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-icon .icon {
  width: 17px;
  height: 17px;
}

.stat strong {
  overflow: hidden;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat strong small {
  margin-left: 1px;
  color: var(--muted);
  font-size: 0.7em;
  font-weight: 600;
}

.stat > span:last-child {
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-accent {
  background: linear-gradient(135deg, #fff4ec, #ffe6d5);
  border-color: rgba(255, 120, 40, 0.3);
}

.stat-accent strong,
.stat-accent .stat-icon {
  color: var(--brand-ink);
}

.rating-block {
  display: grid;
  gap: 8px;
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.rating-pips {
  display: flex;
  gap: 4px;
}

.rating-pip {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font: 700 0.85rem/1 var(--font);
  cursor: pointer;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease,
    transform 0.12s ease;
}

.rating-pip.is-on {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--navy);
}

.rating-pips:hover .rating-pip {
  border-color: var(--border-strong);
  background: var(--panel);
  color: var(--muted);
}

.rating-pips .rating-pip.is-preview {
  border-color: var(--brand);
  background: #ffd2b5;
  color: var(--navy);
}

.rating-pip:active {
  transform: scale(0.92);
}

.rating-readout {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}

.play-form {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.play-form label {
  margin: 0;
}

.play-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.play-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 8px 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.play-item.is-new {
  animation: pickLand 0.4s var(--bounce);
}

.play-date {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-date .icon {
  color: var(--brand-strong);
}

.play-date > span {
  display: grid;
  line-height: 1.25;
}

.play-date strong {
  font-size: 0.92rem;
  white-space: nowrap;
}

.play-date small {
  color: var(--muted);
  font-size: 0.78rem;
}

.play-note {
  overflow-wrap: anywhere;
  color: var(--text-2);
  font-size: 0.92rem;
}

.play-empty {
  margin: 0;
}

.notes-text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text-2);
  padding-left: 14px;
  border-left: 3px solid var(--brand);
}

.about-card {
  margin-top: 24px;
}

.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 28px;
}

.about-desc {
  color: var(--text-2);
  max-width: 72ch;
}

.about-desc p:last-child {
  margin-bottom: 0;
}

.about-text.is-clamped .about-desc {
  max-height: 11.5em;
  overflow: hidden;
  mask-image: linear-gradient(#000 60%, transparent);
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
}

.about-text .link-btn {
  margin-top: 8px;
}

.facts {
  display: grid;
  gap: 14px;
  margin: 0;
  align-content: start;
}

.facts > div {
  display: grid;
  gap: 4px;
}

.facts dt {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-weight: 550;
}

.facts .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.about-hint {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.about-hint .empty-icon {
  margin: 0;
  width: 36px;
  height: 36px;
}

.about-hint h2 {
  margin: 0 0 4px;
}

.about-hint p {
  margin: 0;
}

/* Bottom-sheet style dialog */
.sheet {
  width: min(640px, calc(100% - 24px));
  max-height: min(88vh, 860px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.sheet[open] {
  animation: sheetIn 0.28s var(--ease);
}

.sheet::backdrop {
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet-form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.sheet-head,
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 16px 24px;
}

.sheet-head {
  border-bottom: 1px solid var(--border);
}

.sheet-head h2 {
  margin: 0;
}

.sheet-body {
  overflow-y: auto;
  padding: 22px 24px;
  overscroll-behavior: contain;
}

.sheet-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Add games
   ========================================================================== */
.add-card {
  max-width: 860px;
  padding: 0;
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.93rem;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.tab .icon {
  color: var(--muted);
}

.tab:hover {
  background: var(--panel-3);
}

.tab.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab.is-active .icon {
  color: var(--brand);
}

.tab-panel {
  padding: 24px;
}

.inline-form {
  display: flex;
  gap: 10px;
}

.inline-form .search-field {
  flex: 1;
}

.status-line {
  min-height: 1.5em;
  margin: 12px 0 0;
  font-size: 0.92rem;
}

.status-line.is-error {
  color: var(--danger);
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.result-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  animation: pickLand 0.3s var(--ease) both;
}

.result-item:hover {
  border-color: var(--border-strong);
}

.result-cover {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel-3);
  color: var(--muted);
}

.result-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.result-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-info span {
  color: var(--muted);
  font-size: 0.86rem;
}

.result-item .btn {
  min-height: 38px;
  padding: 0 14px;
}

.result-owned {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  min-height: 38px;
  border-radius: 12px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.result-owned .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.6;
}

.skeleton {
  pointer-events: none;
}

.skeleton .result-cover,
.skeleton .sk-line {
  background: linear-gradient(90deg, var(--panel-3) 0%, #f7f9fb 50%, var(--panel-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.sk-line {
  display: block;
  height: 12px;
  border-radius: 6px;
}

.sk-line.w-60 {
  width: 60%;
  height: 14px;
}

.sk-line.w-40 {
  width: 40%;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.scan-intro {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.scan-intro p {
  margin: 0;
}

.scan-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.scan-badge .icon {
  width: 26px;
  height: 26px;
}

.scan-input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 1.1rem !important;
  letter-spacing: 0.12em;
  border-width: 2px !important;
  border-color: var(--brand) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
  .header-row {
    gap: 16px;
  }

  .brand {
    height: 48px;
  }

  .header-link {
    padding: 8px 12px;
  }

  .header-profile {
    padding: 3px;
  }

  .header-profile-name {
    display: none;
  }

  .game-header {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .about-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .home-grid,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 124px;
  }

  main.wrap {
    padding: 18px 0 40px;
  }

  .header-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand account"
      "nav nav";
    gap: 8px 12px;
    padding: 8px 0 10px;
  }

  .header-row.is-guest {
    grid-template-columns: 1fr;
    grid-template-areas: "brand";
    padding: 6px 0;
  }

  .brand {
    height: 42px;
  }

  .header-row.is-guest .brand {
    height: 50px;
  }

  .header-nav {
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 3px;
  }

  .header-link {
    gap: 6px;
    padding: 8px 6px;
    font-size: 0.86rem;
  }

  .header-link .icon {
    width: 16px;
    height: 16px;
  }

  .header-icon-btn {
    width: 38px;
    height: 38px;
  }

  .card {
    padding: 18px;
    border-radius: 16px;
  }

  .auth-card {
    padding: 22px;
  }

  .login-dice {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }

  .home-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 22px;
    gap: 20px;
  }

  .home-insights {
    flex: none;
  }

  .home-rotator-frame,
  .picker-result {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .home-continue-poster,
  .picker-result-cover {
    width: 80px;
  }

  .stat-tile {
    min-height: 96px;
    padding: 14px;
  }

  .picker-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-section {
    margin-top: 24px;
  }

  .shelf {
    grid-auto-columns: 128px;
    gap: 12px;
  }

  .page-head {
    align-items: stretch;
    margin-bottom: 18px;
  }

  .page-head-actions {
    flex-basis: 100%;
  }

  .games-search-wrap {
    max-width: none;
  }

  .search-kbd {
    display: none;
  }

  .toolbar {
    padding: 10px;
  }

  .toolbar .chip-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    margin: -2px;
    padding: 2px;
    scrollbar-width: none;
  }

  .toolbar-selects {
    width: 100%;
  }

  .select-wrap {
    flex: 1 1 calc(50% - 4px);
  }

  .select-wrap select {
    width: 100%;
  }

  .toolbar-reorder {
    flex: 1 1 calc(50% - 4px);
  }

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .card-body {
    padding: 10px 10px 12px;
    gap: 4px;
  }

  .game-title {
    font-size: 0.92rem;
  }

  .game-meta {
    font-size: 0.8rem;
  }

  .game-card:hover {
    transform: none;
  }

  .fav-toggle {
    width: 32px;
    height: 32px;
  }

  .fav-toggle .icon {
    width: 16px;
    height: 16px;
  }

  .page-actions .btn {
    padding: 0 12px;
  }

  .page-actions .btn-ghost {
    padding: 0 8px 0 4px;
  }

  .game-header {
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-areas:
      "cover heading"
      "meta meta";
    grid-template-rows: auto;
    column-gap: 16px;
    row-gap: 16px;
    padding: 18px;
  }

  .game-heading-actions {
    margin-bottom: 0;
  }

  .game-tagline {
    font-size: 0.92rem;
  }

  .stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat strong {
    font-size: 1.1rem;
    white-space: normal;
  }

  .rating-pips {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    width: 100%;
  }

  .rating-pip {
    width: auto;
    height: 36px;
  }

  .play-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .play-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .play-note {
    grid-column: 1;
    grid-row: 2;
  }

  .play-note:empty {
    display: none;
  }

  .play-item .icon-btn {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .hide-sm {
    display: none;
  }

  .show-sm {
    display: inline;
  }

  .tab-panel {
    padding: 18px;
  }

  .form-grid {
    gap: 14px;
  }

  .result-item {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .result-cover {
    width: 52px;
    height: 52px;
  }

  .result-item > :last-child {
    grid-column: 1 / -1;
    width: 100%;
  }

  .sheet {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .sheet-foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .sheet-foot .btn {
    flex: 1;
  }

  .back-to-top {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 440px) {
  .header-link .icon {
    display: none;
  }

  .header-link {
    padding: 8px 4px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .segmented {
    justify-self: stretch;
  }
}

@media (max-width: 380px) {
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
