:root {
  --bg: #fdf8f3;
  --surface: #ffffff;
  --surface-alt: #fff7ed;
  --ink: #29150e;
  --muted: #6b4c3b;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --gold: #d97706;
  --gold-soft: #fef3c7;
  --border: #ecd6c4;
  --deck-bg: #29150e;
  --deck-card: #3d1f14;
  --deck-ink: #fff7ed;
  --deck-muted: #fed7aa;
  --focus: #f59e0b;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.62;
  color: var(--ink);
  background: var(--bg);
  overflow-x: clip;
}
a { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 200;
  padding: 0.65rem 1rem; border-radius: 8px;
  background: var(--accent-strong); color: #fff; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }
.unofficial-ribbon {
  background: #1c0e09; color: #fed7aa; font-size: 0.8rem;
  padding: 0.36rem 0.75rem; text-align: center;
}
.unofficial-ribbon a { color: #fbbf24; font-weight: 700; }
.site-header {
  position: sticky; top: 0; z-index: 60;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px);
}
.header-inner {
  width: min(1320px, calc(100% - 1.5rem)); margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 0.7rem;
}
.brand-link {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--ink); font-weight: 800; font-size: 1.02rem; text-decoration: none;
  min-width: 0;
}
.brand-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-link img { width: 30px; height: 30px; border-radius: 7px; display: block; flex-shrink: 0; }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  min-height: 40px; padding: 0.4rem 0.75rem; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer;
}
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.main-nav a {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0.35rem 0.7rem;
  border-radius: 8px; color: var(--ink); font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { background: #ffedd5; color: var(--accent-strong); }
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  font-size: 0.84rem; color: var(--muted); margin: 0 0 0.7rem;
}
.breadcrumb a { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.ad-slot {
  width: min(1320px, calc(100% - 1.5rem)); max-width: 100%;
  overflow-x: clip; margin: 0.85rem auto 0; text-align: center;
}
.main-deck .ad-slot { width: 100%; margin: 0 0 1.1rem; }
.ad-slot[data-active="false"] { display: none; }
.ad-label {
  display: block; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.25rem;
}
.workspace-shell {
  width: min(1320px, calc(100% - 1.5rem)); margin: 1rem auto 1.5rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 1.1rem; align-items: start;
}
.main-deck, .side-rail { min-width: 0; }
.side-rail { display: flex; flex-direction: column; gap: 0.9rem; }
.tool-panel {
  background: var(--deck-bg); color: var(--deck-ink); border-radius: 16px;
  border: 1px solid #5c2d16; padding: clamp(0.95rem, 2.2vw, 1.45rem);
  box-shadow: 0 14px 36px rgba(41, 21, 14, 0.18); margin-bottom: 1.1rem;
}
.tool-panel h1 { margin: 0 0 0.3rem; font-size: clamp(1.3rem, 2.5vw, 1.85rem); line-height: 1.2; color: #fff; }
.tool-subtitle { margin: 0 0 1rem; font-size: 0.92rem; color: var(--deck-muted); }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 0.75rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field label { font-size: 0.8rem; font-weight: 700; color: #fed7aa; }
.field input, .field select {
  width: 100%; min-height: 40px; padding: 0.45rem 0.65rem; border-radius: 8px;
  border: 1px solid #6b3a22; background: #1a0d08; color: #fff; font-size: 0.92rem; font-weight: 600;
}
.kpi-strip {
  margin-top: 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 0.65rem;
}
.kpi-box { background: var(--deck-card); border: 1px solid #6b3a22; border-radius: 10px; padding: 0.65rem 0.75rem; }
.kpi-label { display: block; font-size: 0.74rem; color: var(--deck-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { display: block; font-size: 1.22rem; font-weight: 850; color: #fbbf24; font-variant-numeric: tabular-nums; }
.sub-deck { margin-top: 1rem; padding-top: 0.95rem; border-top: 1px solid #5c2d16; }
.sub-deck h2 { margin: 0 0 0.55rem; font-size: 1rem; color: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 38px; padding: 0.45rem 0.85rem; border-radius: 8px;
  border: 1px solid #6b3a22; background: var(--deck-card); color: #fff;
  font-size: 0.85rem; font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation;
}
.btn:hover { background: #52291a; }
.btn--primary { background: #f59e0b; border-color: #fbbf24; color: #29150e; }
.btn--primary:hover { background: #fbbf24; }
.btn--danger { border-color: #7f1d1d; background: #450a0a; color: #fecaca; }
.compare-result {
  margin-top: 0.65rem; padding: 0.6rem 0.8rem; border-radius: 9px;
  background: #1f0f09; border: 1px solid #6b3a22; font-size: 0.88rem; color: #ffedd5;
}
.roster-list, .code-list { display: grid; gap: 0.5rem; margin-top: 0.65rem; }
.roster-row, .code-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.55rem; padding: 0.6rem 0.8rem; border-radius: 9px;
  background: #331910; border: 1px solid #6b3a22; font-size: 0.86rem;
}
.roster-row.is-weakest { border-color: #fbbf24; }
.code-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem; font-weight: 800; color: #fde047; letter-spacing: 0.03em;
}
.tier-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; padding: 0.14rem 0.5rem; border-radius: 6px; font-weight: 800; font-size: 0.78rem; color: #fff; white-space: nowrap;
}
.tier-S, .tier-Masterpiece { background: #b91c1c; }
.tier-A, .tier-Very-Hard { background: #c2410c; }
.tier-B, .tier-Advanced { background: #0f766e; }
.tier-C, .tier-Easy { background: #15803d; }
.rail-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.95rem; }
.rail-title { margin: 0 0 0.65rem; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.quick-list { display: grid; gap: 0.6rem; }
.quick-card {
  display: block; padding: 0.68rem 0.75rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--ink); text-decoration: none;
}
.quick-card:hover, .quick-card[aria-current="page"] { border-color: var(--accent); background: #ffedd5; }
.quick-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.2rem; }
.quick-card-title { font-weight: 750; font-size: 0.9rem; }
.badge { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 0.12rem 0.42rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.quick-card p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.content-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: clamp(1.1rem, 2.5vw, 1.9rem); margin-bottom: 1.1rem;
}
.content-card h2 { font-size: 1.28rem; margin: 1.4rem 0 0.6rem; color: var(--ink); }
.content-card h2:first-child { margin-top: 0; }
.content-card p { margin: 0 0 0.85rem; color: #3f2418; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.7rem; }
.related-card {
  display: flex; flex-direction: column; gap: 0.2rem; padding: 0.75rem 0.85rem;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-alt);
  color: var(--ink); text-decoration: none;
}
.related-card:hover { border-color: var(--accent); background: #ffedd5; }
.related-card strong { font-size: 0.92rem; color: var(--accent-strong); }
.related-card span { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.notice-box {
  padding: 0.88rem 1rem; border-radius: 10px; border-left: 4px solid var(--gold);
  background: var(--gold-soft); color: #422006; margin: 0.9rem 0; font-size: 0.92rem;
}
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; margin: 0.8rem 0 1rem; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
th, td { padding: 0.64rem 0.78rem; border-top: 1px solid var(--border); }
thead th { border-top: 0; background: #ffedd5; font-weight: 750; color: var(--ink); }
.tool-panel .table-scroll { border-color: #6b3a22; }
.tool-panel table { color: #fff7ed; }
.tool-panel thead th { background: #3d1f14; color: #fed7aa; }
.tool-panel th, .tool-panel td { border-color: #5c2d16; }
.faq-list { display: grid; gap: 0.6rem; }
.faq-item { border: 1px solid var(--border); border-radius: 10px; padding: 0.72rem 0.95rem; background: var(--surface-alt); }
.faq-item summary { font-weight: 750; cursor: pointer; }
.faq-item p { margin: 0.55rem 0 0; font-size: 0.92rem; }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1.65rem 0 2.25rem; font-size: 0.88rem; color: var(--muted); }
.footer-inner {
  width: min(1320px, calc(100% - 1.5rem)); margin-inline: auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.footer-links a { color: var(--ink); font-weight: 600; text-decoration: none; }
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 120;
  padding: 0.6rem 1rem; border-radius: 999px; background: #29150e; color: #fff7ed; font-size: 0.86rem; font-weight: 600;
}
.toast[hidden] { display: none; }

@media (max-width: 980px) {
  .workspace-shell { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; padding: 0.75rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch;
  }
  .main-nav.is-open { display: flex; }
}
