:root {
  --paper: #f7f3e8;
  --paper-strong: #fffdf7;
  --ink: #17202a;
  --muted: #5d6673;
  --line: #d3c9b3;
  --line-dark: #a99a7e;
  --blue: #2f6f9f;
  --blue-dark: #1f4e70;
  --red: #b33a3a;
  --gold: #b78b1e;
  --green: #3f7f57;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.12);
  --radius: 8px;
  font-family:
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 78, 112, 0.06), transparent 22%, transparent 78%, rgba(179, 58, 58, 0.06)),
    radial-gradient(circle at top left, rgba(183, 139, 30, 0.12), transparent 36rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-strong);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(47, 111, 159, 0.16);
}

button:disabled {
  cursor: not-allowed;
  color: #9a9387;
  background: #eee7d8;
}

a {
  color: var(--blue-dark);
  text-decoration-color: rgba(47, 111, 159, 0.32);
  text-underline-offset: 0.18em;
}

.app-shell {
  min-height: 100vh;
}

.wiki-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 0;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.82);
  backdrop-filter: blur(12px);
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 48px;
  height: 48px;
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.05;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.nav-list a,
.nav-list button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
}

.nav-list a:hover,
.nav-list button:hover {
  border-color: var(--line-dark);
  background: rgba(47, 111, 159, 0.08);
}

.side-note {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 54px) 56px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.page-subtitle {
  max-width: 780px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.4vw, 1.12rem);
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.danger-button,
.quiet-button {
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-button {
  color: white;
  border-color: var(--blue-dark);
  background: var(--blue);
}

.danger-button {
  color: white;
  border-color: #8f2e2e;
  background: var(--red);
}

.quiet-button {
  background: rgba(255, 253, 247, 0.72);
}

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

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.88);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 16px;
}

.panel h2,
.panel h3,
.article-section h2,
.article-section h3 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.panel p {
  margin: 0;
  line-height: 1.75;
}

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

.hero-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.hero-row:first-child {
  border-top: 0;
}

.hero-row a {
  font-weight: 700;
}

.hero-row small,
.muted {
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #3d4652;
  background: #f1eadb;
  font-size: 0.8rem;
}

.source-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 14px;
}

.source-strip > span {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.source-error {
  margin: 0 0 12px;
  color: #8a3d22;
  font-size: 0.9rem;
}

.top-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 20px;
}

.lead-box {
  padding: clamp(18px, 3vw, 28px);
  border-left: 5px solid var(--blue);
}

.seal-box {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.seal-box img {
  width: 116px;
  height: 116px;
}

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

.stat {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(247, 243, 232, 0.76);
}

.stat b {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat span {
  display: block;
  font-size: 1.28rem;
  font-weight: 800;
}

.meter {
  position: relative;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4dcc9;
}

.meter > i {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--meter-color, var(--blue));
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
  align-items: start;
}

.encounter-stack {
  display: grid;
  gap: 16px;
}

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

.article-card {
  min-height: 220px;
  padding: 14px;
  text-align: left;
}

.article-card h3 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.article-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.6;
}

.article-card .risk {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.86rem;
}

.extract-summary {
  margin-top: 10px;
  color: #58616d;
  font-size: 0.84rem;
  line-height: 1.45;
}

.extraction-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  background: rgba(244, 237, 221, 0.62);
}

.source-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.86rem;
}

.extract-text {
  color: #4b5563;
  font-size: 0.92rem;
}

.extract-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.extract-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.72);
}

.extract-grid strong,
.extract-grid span {
  display: block;
}

.extract-grid strong {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.extract-grid span {
  line-height: 1.55;
}

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

.action-button {
  min-height: 98px;
  padding: 12px;
  text-align: left;
}

.action-button strong {
  display: block;
  margin-bottom: 6px;
}

.action-button span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.wiki-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  gap: 18px;
  align-items: start;
}

.article-body {
  padding: clamp(18px, 3vw, 28px);
}

.article-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.article-section:first-child {
  border-top: 0;
}

.article-section p,
.article-section li {
  line-height: 1.78;
}

.toc {
  display: grid;
  gap: 4px;
  width: min(100%, 420px);
  padding: 12px 16px;
  margin: 14px 0 0;
  border: 1px solid var(--line);
  background: #f4eddd;
}

.toc a {
  font-size: 0.9rem;
}

.infobox {
  position: sticky;
  top: 20px;
  padding: 14px;
}

.infobox h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.info-table th,
.info-table td {
  padding: 8px 6px;
  vertical-align: top;
  border-top: 1px solid var(--line);
}

.info-table th {
  width: 38%;
  color: var(--muted);
  text-align: left;
}

.warning {
  padding: 12px;
  border: 1px solid #d9a441;
  border-left: 5px solid var(--gold);
  background: #fff5d7;
}

.warning ul {
  margin: 8px 0 0;
  padding-left: 1.2rem;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  padding: 0;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.log-list li {
  padding: 8px 10px;
  border-left: 3px solid var(--line-dark);
  background: rgba(247, 243, 232, 0.72);
  line-height: 1.55;
}

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

.memory-list li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.72);
}

.memory-list strong {
  display: block;
}

.result-banner {
  padding: 18px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: #f4eddd;
}

.result-banner h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
}

.vote-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vote-grid button {
  padding: 8px 10px;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.84);
}

.rank-table th,
.rank-table td {
  padding: 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.rank-table th {
  color: var(--muted);
  background: #f0e8d6;
}

.rank-table tr:first-child th,
.rank-table tr:first-child td {
  border-top: 0;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-dark);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 253, 247, 0.52);
  text-align: center;
}

@media (max-width: 1040px) {
  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 0;
  }

  .side-note {
    display: none;
  }

  .top-intro,
  .play-layout,
  .wiki-page {
    grid-template-columns: 1fr;
  }

  .infobox {
    position: static;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px 12px 42px;
  }

  .page-head {
    display: grid;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .grid,
  .grid.two,
  .choice-grid,
  .action-grid,
  .extract-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .source-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .seal-box {
    grid-template-columns: 72px 1fr;
  }

  .seal-box img {
    width: 72px;
    height: 72px;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }
}

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