/* ==========================================================================
   Bunot Na! Filipino Mahjong — Online User Manual Stylesheet
   Brand Theme: Dark Emerald Felt & Warm Antique Gold
   WCAG AA+ High-Contrast | Responsive | Print-Ready
   ========================================================================== */

:root {
  /* Core Brand Palette */
  --bg-felt: #0c1f17;
  --bg-felt-deep: #071510;
  --bg-surface: #132d22;
  --bg-elevated: #1a3c2d;
  --bg-hover: #214937;

  /* Gold & Ivory Accents */
  --gold: #d4af37;
  --gold-bright: #f2cf66;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --gold-border: rgba(212, 175, 55, 0.42);
  --ivory: #fbf7ee;
  --ivory-shade: #ede4d1;
  --ivory-edge: #cbbca0;

  /* Semantic & Mahjong Suit Accents */
  --crimson: #d94a43;
  --crimson-soft: rgba(217, 74, 67, 0.16);
  --crimson-border: rgba(217, 74, 67, 0.42);
  --emerald-bright: #34c385;
  --emerald-soft: rgba(52, 195, 133, 0.14);

  /* Typography Colors (WCAG AA/AAA on felt & surface) */
  --text-primary: #f4f7f5;
  --text-muted: #b7c9be;
  --text-ink: #111c16;

  /* Borders & Shadows */
  --border-subtle: rgba(212, 175, 55, 0.22);
  --border-faint: rgba(244, 247, 245, 0.1);
  --shadow-sm: 0 2px 8px rgba(3, 10, 7, 0.28);
  --shadow-md: 0 8px 24px rgba(3, 10, 7, 0.42);
  --shadow-lg: 0 18px 44px rgba(2, 8, 5, 0.58);
  --shadow-tile: 0 4px 0 var(--ivory-edge), 0 8px 16px rgba(2, 10, 6, 0.42);

  /* Layout & Spacing */
  --header-height: 64px;
  --sidebar-width: 280px;
  --content-max-width: 940px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-serif: 'Cinzel', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;

  /* Motion */
  --transition-fast: 150ms ease;
  --transition-med: 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------------------------
   Base & Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
  background-color: var(--bg-felt);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(28, 72, 52, 0.52), transparent 70%),
    radial-gradient(circle at 12% 85%, rgba(212, 175, 55, 0.05), transparent 45%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(212, 175, 55, 0.32);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip Link for Keyboard Accessibility */
.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--gold);
  color: var(--text-ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 12px;
}

/* Typography Defaults */
h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  line-height: 1.25;
  margin-top: 0;
}

h1,
h2 {
  font-family: var(--font-serif);
  letter-spacing: 0.015em;
}

h1 {
  font-size: clamp(1.85rem, 3.2vw, 2.65rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: clamp(1.38rem, 2.2vw, 1.85rem);
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-bright);
  margin-top: 1.25rem;
  margin-bottom: 0.45rem;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin-top: 0;
  margin-bottom: 1.1rem;
  padding-left: 1.35rem;
}

li {
  margin-bottom: 0.42rem;
}

li::marker {
  color: var(--gold);
}

strong {
  color: #ffffff;
  font-weight: 600;
}

a {
  color: var(--gold-bright);
  text-decoration: underline;
  text-decoration-color: rgba(242, 207, 102, 0.42);
  text-underline-offset: 3px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
  color: #fff0b8;
  text-decoration-color: var(--gold-bright);
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

code {
  padding: 0.14em 0.42em;
  border-radius: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--gold-bright);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55em;
  padding: 0.12em 0.45em;
  border-radius: 5px;
  background: var(--bg-felt-deep);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 -1px 0 rgba(212, 175, 55, 0.25);
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.25;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 2rem 0;
}

img,
svg {
  max-width: 100%;
  display: block;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg-felt-deep);
}

::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.28);
  border-radius: 999px;
  border: 2px solid var(--bg-felt-deep);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.48);
}

/* --------------------------------------------------------------------------
   Sticky Top Header (64px)
   -------------------------------------------------------------------------- */

.site-header,
.top-header,
.manual-header {
  position: sticky;
  top: 0;
  z-index: 120;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(12, 31, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(3, 10, 7, 0.32);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-right,
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Hamburger Toggle (Mobile Only) */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--gold-bright);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-elevated);
  border-color: var(--gold-border);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* Brand Mark & Title */
.brand,
.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-primary);
  min-width: 0;
}

.brand:hover,
.header-brand:hover {
  color: var(--gold-bright);
}

.brand-mark,
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #1a3c2d 0%, #0c1f17 72%, #071510 100%);
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.28), 0 4px 10px rgba(0, 0, 0, 0.42);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Header Search Bar & Floating Results */
.search-wrapper,
.search-box,
.header-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 440px;
  min-width: 180px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input,
#manual-search,
#search-input {
  width: 100%;
  height: 38px;
  padding: 0 40px 0 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), background var(--transition-fast),
    box-shadow var(--transition-fast);
}

.search-input::placeholder,
#manual-search::placeholder,
#search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

.search-input:focus,
#manual-search:focus,
#search-input:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.search-shortcut,
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.75rem;
  color: var(--gold-bright);
  background: var(--bg-felt-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.4;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(420px, 68vh);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  z-index: 250;
}

.search-results[hidden] {
  display: none;
}

.search-result-item {
  display: block;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.active,
.search-result-item:focus-visible {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  text-decoration: none;
}

.search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--gold-bright);
}

.search-result-type,
.search-result-section {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-felt);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.search-result-snippet {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.search-result-snippet mark,
mark {
  background: rgba(242, 207, 102, 0.26);
  color: var(--gold-bright);
  padding: 0 2px;
  border-radius: 3px;
}

.search-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Primary Play CTA Button */
.play-cta,
.btn-play,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1.05rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-bright);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--text-ink);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.28);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    filter var(--transition-fast);
}

.play-cta:hover,
.btn-play:hover,
.btn-primary:hover {
  color: var(--text-ink);
  text-decoration: none;
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.42);
}

.play-cta:active,
.btn-play:active,
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-border);
  background: var(--bg-elevated);
  color: var(--gold-bright);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--gold-bright);
  color: #fff2bf;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Desktop 2-Column Layout & Sticky Left Sidebar TOC
   -------------------------------------------------------------------------- */

.manual-layout,
.manual-shell,
.page-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--header-height));
  max-width: 1440px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 1.35rem 1rem 2rem;
  background: rgba(14, 34, 25, 0.72);
  border-right: 1px solid var(--border-subtle);
}

.sidebar-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--gold-bright);
  cursor: pointer;
}

.toc-group {
  margin-bottom: 1.35rem;
}

.toc-group:last-child {
  margin-bottom: 0;
}

.toc-group-title,
.toc-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  padding: 0 0.65rem;
  margin-bottom: 0.45rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-list li {
  margin: 0;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.48rem 0.7rem;
  border-radius: var(--radius-sm);
  border-left: 2.5px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.toc-link:hover {
  background: rgba(26, 60, 45, 0.65);
  color: var(--text-primary);
  text-decoration: none;
}

.toc-link.active {
  background: var(--gold-soft);
  border-left-color: var(--gold-bright);
  color: var(--gold-bright);
  font-weight: 600;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(4, 12, 8, 0.72);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.sidebar-backdrop.open,
.sidebar-backdrop.active,
.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Main Content Column */
.manual-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 2rem 2.25rem 4.5rem;
}

/* --------------------------------------------------------------------------
   Sections & Hero Banner
   -------------------------------------------------------------------------- */

.manual-section {
  scroll-margin-top: 84px;
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.manual-section:first-child {
  padding-top: 0;
}

.manual-section:last-of-type {
  border-bottom: none;
}

.section-lead {
  font-size: 1.04rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 2.35rem 2.25rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 88% 18%, rgba(212, 175, 55, 0.16), transparent 46%),
    linear-gradient(145deg, #163729 0%, #0f271d 55%, #0a1b14 100%);
  border: 1px solid var(--gold-border);
  box-shadow: var(--shadow-md);
}

.hero::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: calc(var(--radius-xl) - 5px);
  border: 1px solid rgba(212, 175, 55, 0.14);
  pointer-events: none;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.78rem;
  margin-bottom: 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold-bright);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.hero h1 {
  color: #ffffff;
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 66ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.hero-stats,
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.hero-stat strong,
.hero-meta strong {
  color: var(--gold-bright);
}

/* --------------------------------------------------------------------------
   Callouts & Badges
   -------------------------------------------------------------------------- */

.callout {
  padding: 1.05rem 1.25rem;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--emerald-bright);
  box-shadow: var(--shadow-sm);
}

.callout-gold {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.11), rgba(19, 45, 34, 0.94));
  border-color: var(--gold-border);
  border-left: 4px solid var(--gold-bright);
}

.callout-warning,
.callout-danger {
  background: linear-gradient(135deg, var(--crimson-soft), rgba(19, 45, 34, 0.95));
  border-color: var(--crimson-border);
  border-left: 4px solid var(--crimson);
}

.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-bright);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.62rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.3;
  background: var(--gold-soft);
  color: var(--gold-bright);
  border: 1px solid var(--gold-border);
  white-space: nowrap;
}

.badge-gold {
  background: var(--gold);
  color: var(--text-ink);
  border-color: var(--gold-bright);
}

.badge-sagabal,
.badge-crimson,
.badge-red {
  background: var(--crimson-soft);
  color: #ff9c96;
  border-color: var(--crimson-border);
}

.badge-emerald,
.badge-green {
  background: var(--emerald-soft);
  color: #7ee8b7;
  border-color: rgba(52, 195, 133, 0.42);
}

.badge-muted {
  background: rgba(244, 247, 245, 0.07);
  color: var(--text-muted);
  border-color: var(--border-faint);
}

/* --------------------------------------------------------------------------
   Responsive Rule Tables
   -------------------------------------------------------------------------- */

.table-wrap,
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.rule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.rule-table thead th {
  background: var(--bg-elevated);
  color: var(--gold-bright);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--gold-border);
  white-space: nowrap;
}

.rule-table tbody td {
  padding: 0.78rem 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.12);
  color: var(--text-primary);
  vertical-align: top;
}

.rule-table tbody tr:last-child td {
  border-bottom: none;
}

.rule-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.018);
}

.rule-table tbody tr:hover {
  background: rgba(212, 175, 55, 0.06);
}

.rule-table .num,
.rule-table td:last-child {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Card Grids & AI Persona Cards
   -------------------------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.1rem;
  margin: 1.25rem 0;
}

.card-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card,
.info-card,
.rule-card,
.persona-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), transform var(--transition-fast),
    background var(--transition-fast);
}

.card:hover,
.persona-card:hover {
  border-color: var(--gold-border);
}

.card h3,
.card h4,
.persona-card h3,
.persona-card h4 {
  margin-top: 0;
}

/* Persona Cards */
.persona-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
}

.persona-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.persona-name {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.persona-role {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.skill-stars {
  color: var(--gold-bright);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
  flex-shrink: 0;
}

.persona-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
}

.strategy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.strategy-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.58rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--gold-bright);
  background: var(--bg-felt);
  border: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   39-Tile Visual Gallery
   -------------------------------------------------------------------------- */

.tile-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0 1.15rem;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.44rem 0.9rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
}

.filter-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--gold-border);
}

.filter-btn.active {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--text-ink);
  border-color: var(--gold-bright);
  font-weight: 700;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.4rem;
}

.tile-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: center;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: transform var(--transition-fast), border-color var(--transition-fast),
    background var(--transition-fast), box-shadow var(--transition-fast);
}

.tile-card:hover {
  transform: translateY(-3px);
  background: var(--bg-elevated);
  border-color: var(--gold-border);
  box-shadow: var(--shadow-md);
}

.tile-card.active,
.tile-card.selected,
.tile-card[aria-pressed='true'] {
  background: var(--bg-elevated);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(242, 207, 102, 0.28), var(--shadow-md);
}

.tile-art {
  width: 68px;
  aspect-ratio: 3 / 4;
  padding: 5px;
  border-radius: 9px;
  background: linear-gradient(160deg, #fffefb 0%, var(--ivory) 68%, var(--ivory-shade) 100%);
  border: 1.5px solid #e4d8c0;
  box-shadow: var(--shadow-tile);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.tile-art img,
.tile-art svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.tile-sub,
.tile-suit {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.tile-card .badge-sagabal,
.tile-card .sagabal-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0.12rem 0.42rem;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #b92c25;
  color: #fff5f4;
  border: 1px solid rgba(255, 195, 190, 0.45);
  border-radius: var(--radius-pill);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Selected Tile Detail Inspector Panel */
.tile-detail-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
  padding: 1.35rem 1.5rem;
  margin-top: 1.15rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--gold-border);
  box-shadow: var(--shadow-md);
}

.tile-detail-panel[hidden] {
  display: none;
}

.tile-detail-panel .tile-art {
  width: 96px;
  padding: 8px;
  border-radius: 12px;
}

.tile-detail-body {
  min-width: 0;
}

.tile-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.tile-detail-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0;
}

.tile-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.tile-detail-desc {
  font-size: 0.93rem;
  color: var(--text-primary);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Interactive Puntas & Scoring Calculator
   -------------------------------------------------------------------------- */

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 1.25rem;
  align-items: start;
  margin: 1.35rem 0;
}

.calc-card,
.calc-inputs,
.calc-output {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow-sm);
}

.calc-output {
  background: linear-gradient(160deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border-color: var(--gold-border);
}

.calc-field {
  margin-bottom: 1.1rem;
}

.calc-field:last-child {
  margin-bottom: 0;
}

.calc-field label,
.calc-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.42rem;
}

.calc-field .field-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.calc-field input[type='number'],
.calc-field input[type='text'],
.calc-field select {
  width: 100%;
  height: 40px;
  padding: 0 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-felt);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.calc-field input[type='number']:focus,
.calc-field input[type='text']:focus,
.calc-field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.calc-field input[type='range'] {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Segmented Toggle Group */
.calc-toggle-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.45rem;
}

.calc-toggle-btn,
.calc-toggle-group button,
.calc-toggle-group label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.52rem 0.75rem;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-felt);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.calc-toggle-btn:hover,
.calc-toggle-group button:hover,
.calc-toggle-group label:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--gold-border);
}

.calc-toggle-btn.active,
.calc-toggle-group button.active,
.calc-toggle-group button[aria-pressed='true'],
.calc-toggle-group label:has(input:checked) {
  background: var(--gold-soft);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  font-weight: 700;
}

.calc-toggle-group input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Checkbox Grid for Special Hands / Bonuses */
.calc-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.calc-checkbox,
.calc-checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.62rem 0.75rem;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-felt);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.calc-checkbox:hover,
.calc-checkbox-grid label:hover {
  background: var(--bg-elevated);
  border-color: var(--gold-border);
}

.calc-checkbox:has(input:checked),
.calc-checkbox-grid label:has(input:checked) {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.calc-checkbox input[type='checkbox'],
.calc-checkbox-grid input[type='checkbox'] {
  margin-top: 2px;
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Payout Summary Breakdown */
.payout-summary {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.payout-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed rgba(212, 175, 55, 0.22);
  font-size: 0.92rem;
}

.payout-row:last-of-type {
  border-bottom: none;
}

.payout-row .label,
.payout-label {
  color: var(--text-muted);
}

.payout-row .value,
.payout-value {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.payout-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.85rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.22), rgba(212, 175, 55, 0.08));
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.14);
}

.payout-total .label,
.payout-total-label {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--gold-bright);
}

.payout-total .value,
.payout-total-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff4c9;
  white-space: nowrap;
}

.payout-note {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Searchable Glossary
   -------------------------------------------------------------------------- */

.glossary-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1.2rem;
}

.glossary-controls input[type='search'],
.glossary-controls input[type='text'] {
  flex: 1 1 240px;
  height: 40px;
  padding: 0 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.glossary-controls input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.glossary-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: auto;
}

.glossary-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.95rem;
}

.glossary-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.05rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  scroll-margin-top: 90px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.glossary-card:hover {
  border-color: var(--gold-border);
  background: var(--bg-elevated);
}

.glossary-card:target {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(242, 207, 102, 0.25);
  background: var(--bg-elevated);
}

.glossary-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.glossary-term {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0;
}

.glossary-anchor {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.65;
  padding: 0 4px;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.glossary-card:hover .glossary-anchor,
.glossary-anchor:focus-visible {
  opacity: 1;
  color: var(--gold-bright);
}

.glossary-def {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.55;
}

/* Footer */
.manual-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */

@media (max-width: 960px) {
  .menu-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: min(300px, 85vw);
    z-index: 200;
    background: var(--bg-felt);
    border-right: 1px solid var(--gold-border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--transition-med);
    padding-top: 1rem;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
  }

  .manual-main {
    padding: 1.5rem 1.25rem 3.5rem;
  }

  .calculator-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header,
  .top-header,
  .manual-header {
    padding: 0 0.85rem;
    gap: 0.6rem;
  }

  .brand-subtitle,
  .search-shortcut,
  .search-kbd {
    display: none;
  }

  .brand-title {
    font-size: 0.94rem;
  }

  .play-cta,
  .btn-play {
    padding: 0.45rem 0.78rem;
    font-size: 0.82rem;
  }

  .hero {
    padding: 1.5rem 1.25rem;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.65rem;
  }

  .tile-art {
    width: 58px;
  }

  .tile-detail-panel {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
    padding: 1.15rem;
  }

  .tile-detail-header,
  .tile-detail-meta {
    justify-content: center;
  }

  .calc-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .glossary-list {
    grid-template-columns: 1fr;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Print Stylesheet (Light, Ink-Friendly)
   -------------------------------------------------------------------------- */

@media print {
  @page {
    margin: 16mm 14mm;
  }

  html,
  body {
    background: #ffffff !important;
    background-image: none !important;
    color: #111827 !important;
    font-size: 11pt;
    line-height: 1.5;
  }

  .site-header,
  .top-header,
  .manual-header,
  .sidebar,
  .sidebar-backdrop,
  .menu-toggle,
  .search-wrapper,
  .search-box,
  .search-results,
  .play-cta,
  .btn-play,
  .btn-primary,
  .btn-secondary,
  .hero-actions,
  .tile-filters,
  .glossary-controls,
  .glossary-anchor,
  .skip-link {
    display: none !important;
  }

  .manual-layout,
  .manual-shell,
  .page-layout,
  .manual-main {
    display: block !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .manual-section {
    padding: 12pt 0 !important;
    border-bottom: 1px solid #d1d5db !important;
  }

  h1,
  h2,
  h3,
  h4,
  .persona-name,
  .glossary-term,
  .tile-detail-title,
  .callout-title {
    color: #0f291e !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  p,
  li,
  td,
  th,
  .section-lead,
  .persona-desc,
  .glossary-def,
  .payout-label,
  .payout-value {
    color: #1f2937 !important;
  }

  a {
    color: #111827 !important;
    text-decoration: none !important;
  }

  .hero,
  .callout,
  .callout-gold,
  .card,
  .persona-card,
  .tile-card,
  .tile-detail-panel,
  .calc-card,
  .calc-inputs,
  .calc-output,
  .glossary-card,
  .payout-total {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .hero::after {
    display: none !important;
  }

  .badge,
  .strategy-tag {
    background: #f3f4f6 !important;
    color: #111827 !important;
    border: 1px solid #9ca3af !important;
  }

  .tile-grid {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 8pt !important;
  }

  .tile-art {
    box-shadow: none !important;
    border: 1px solid #9ca3af !important;
    background: #ffffff !important;
  }

  .table-wrap,
  .table-responsive {
    overflow: visible !important;
    border: 1px solid #9ca3af !important;
    box-shadow: none !important;
  }

  .rule-table thead th {
    background: #f3f4f6 !important;
    color: #111827 !important;
    border-bottom: 1.5px solid #6b7280 !important;
  }

  .rule-table tbody td {
    border-bottom: 1px solid #e5e7eb !important;
  }

  .rule-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .manual-ad-slot {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   Optional AdSense Display Units (Fail-Closed & Felt-Matched)
   -------------------------------------------------------------------------- */
.manual-ad-slot {
  margin: 20px 0 24px;
  padding: 10px 14px 12px;
  background: #0a241a;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  text-align: center;
}

.manual-ad-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(244, 247, 245, 0.52);
  margin-bottom: 6px;
}

.manual-ad-preview-card {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: #103526;
  border: 1px dashed rgba(212, 175, 55, 0.5);
  border-radius: var(--radius-sm);
  color: var(--gold-bright);
  font-size: 0.85rem;
  font-weight: 600;
}
