:root {
  --bg: #efe3c8;
  --paper: #fffaf0;
  --paper-2: #f5ecd8;
  --ink: #332f29;
  --muted: #726a5d;
  --blue: #688aa5;
  --green: #78966d;
  --gold: #e6c25a;
  --red: #bd604d;
  --line: #8f826d;
  --shadow: 0 8px 0 rgba(74, 63, 46, 0.12);
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-out 0.12s ease-in both;
}

::view-transition-new(root) {
  animation: page-in 0.18s ease-out both;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(104, 138, 165, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(104, 138, 165, 0.04) 1px, transparent 1px),
    linear-gradient(135deg, #f7efdf, #e8d4ad);
  background-size: 24px 24px, 24px 24px, auto;
  font-family: "Yu Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.75;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; }

.site-header {
  position: sticky;
  top: 8px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1120px, calc(100% - 24px));
  margin: 12px auto 20px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 4px 4px 0 rgba(74, 63, 46, 0.15);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: white;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 3px;
}

.site-nav a {
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a.active {
  background: var(--blue);
  color: white;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  cursor: pointer;
}

.page {
  width: min(1120px, calc(100% - 24px));
  min-height: 70vh;
  margin: 0 auto;
}

.page > *,
.home-hero > *,
.latest-feature-grid > *,
.game-screen > * {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

h1, h2, h3 { line-height: 1.35; }

.button {
  display: inline-block;
  padding: 11px 17px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.button:hover,
.button:focus-visible {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.youtube-button {
  background: #d95545;
  color: white;
}

.button.secondary {
  background: var(--paper);
  color: var(--ink);
}

.is-hidden { display: none !important; }

/* トップ */
.home-hero {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  gap: 32px;
  align-items: center;
  min-height: 510px;
  padding: clamp(24px, 5vw, 58px);
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.home-hero h1 {
  margin: 10px 0 18px;
  font-size: clamp(2.2rem, 4.6vw, 3.8rem);
  letter-spacing: 0.03em;
}

.hero-lead {
  margin-bottom: 24px;
  font-size: clamp(0.96rem, 1.5vw, 1.08rem);
}

.home-hero-visual {
  position: relative;
  padding: 14px;
  border: 3px solid var(--line);
  background: var(--paper-2);
  transform: rotate(1deg);
}

.home-hero-visual > img:first-child {
  width: 100%;
  border: 1px solid var(--line);
}

.hero-mascot {
  position: absolute;
  right: -35px;
  bottom: -44px;
  width: 150px;
  filter: drop-shadow(3px 5px 0 rgba(51, 47, 41, 0.18));
}

.latest-feature,
.quick-menu,
.page-heading,
.game-screen,
.quest-screen,
.scene-jumps {
  margin-top: 22px;
  padding: clamp(20px, 4vw, 36px);
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-title h2,
.page-heading h1 {
  margin: 5px 0 8px;
  font-size: clamp(1.65rem, 3.5vw, 2.6rem);
}

.latest-feature-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: center;
  margin-top: 18px;
}

.video-thumbnail {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: #1c1c1c;
}

.video-thumbnail img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.play-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 66px;
  height: 52px;
  border: 3px solid white;
  border-radius: 8px;
  background: #d95545;
  color: white;
  font-size: 1.5rem;
  transform: translate(-50%, -50%);
}

.quest-label {
  display: inline-block;
  padding: 3px 8px;
  background: var(--green);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.latest-copy h3 { font-size: clamp(1.25rem, 2.4vw, 1.75rem); }

.quick-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--paper-2);
}

.quick-menu a {
  display: grid;
  gap: 2px;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--line);
  background: var(--paper);
  text-decoration: none;
}

.quick-menu a:hover { background: #fff4cf; }
.quick-menu span { color: var(--blue); font-weight: 900; }
.quick-menu strong { font-size: 1.06rem; }
.quick-menu small { color: var(--muted); }

/* 共通ページ */
.page-heading {
  text-align: center;
}

.page-heading.compact { padding-block: 22px; }
.page-heading p:last-child { margin-bottom: 0; }

.site-footer {
  display: grid;
  place-items: center;
  gap: 10px;
  width: min(1120px, calc(100% - 24px));
  margin: 24px auto 30px;
  padding: 24px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  text-align: center;
}

.site-footer p { margin: 0; font-size: 0.78rem; }
.map-credit a { color: var(--blue); }
.text-link { color: #426c8a; font-weight: 900; }

/* ルール */
.rule-flow {
  display: grid;
  gap: 12px;
  max-width: 820px;
  margin: 22px auto 0;
}

.rule-flow article {
  position: relative;
  padding: 24px 24px 24px 94px;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.rule-flow article h2 { margin: 4px 0; }
.pixel-icon { position: absolute; top: 24px; left: 24px; font-size: 2.6rem; }
.step { color: var(--blue); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.15em; }
.flow-arrow { color: var(--green); font-size: 1.7rem; font-weight: 900; text-align: center; }

/* ログ */
.log-list {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.part-card {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) 1.2fr;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.part-thumbnail { position: relative; background: #222; }
.part-thumbnail img { width: 100%; height: 100%; min-height: 290px; object-fit: cover; }
.part-thumbnail span { position: absolute; right: 12px; bottom: 12px; padding: 5px 9px; background: #d95545; color: white; font-weight: 900; }
.part-body { padding: clamp(20px, 4vw, 34px); }
.part-body h2 { margin: 8px 0; }
.part-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--blue); font-size: 0.75rem; font-weight: 900; }
.part-body dl { margin: 14px 0; }
.part-body dl div { display: grid; grid-template-columns: 7em 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.part-body dt { font-weight: 900; }
.part-body dd { margin: 0; }
.part-actions, .quest-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.coming-soon { grid-template-columns: 220px 1fr; }
.part-number { display: grid; place-items: center; background: #5c625e; color: white; font-size: 4rem; font-weight: 900; }

/* ゲーム画面 */
.game-screen {
  max-width: 820px;
  margin-inline: auto;
  background: var(--paper-2);
}

.roulette-map-shell {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 3px solid var(--line);
  background:
    linear-gradient(rgba(104, 138, 165, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(104, 138, 165, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 20px 20px;
}

.roulette-map { display: block; width: 100%; height: 520px; pointer-events: none; }

.roulette-window {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  min-width: 180px;
  padding: 12px 16px;
  border: 3px solid var(--blue);
  background: rgba(255, 250, 240, 0.96);
  text-align: center;
}

.roulette-window span { color: var(--blue); font-size: 0.72rem; font-weight: 900; }
.roulette-window strong { font-size: 1.65rem; }
.roulette-window.is-spinning { animation: blink 0.13s steps(2) infinite; }

.roulette-bang {
  position: absolute;
  top: 44%;
  left: 52%;
  padding: 9px 15px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  font-size: 1.6rem;
  font-weight: 900;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.2);
}

.roulette-bang.is-visible { animation: bang 0.75s ease-out; }
.roulette-map-shell.is-finished { animation: impact 0.45s ease-out; }

.game-primary {
  width: 100%;
  margin-top: 14px;
  background: var(--blue);
  color: white;
  font-size: 1.1rem;
}

.exclusion-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  font-size: 0.82rem;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #426c8a;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}

#exclusion-summary { color: var(--muted); }
.exclusion-panel { margin-top: 12px; padding: 14px; border: 2px solid var(--line); background: var(--paper); }
.exclusion-panel-heading { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.exclusion-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 220px; overflow-y: auto; }
.exclusion-option { display: flex; gap: 5px; align-items: center; padding: 5px; background: var(--paper-2); font-size: 0.76rem; cursor: pointer; }

.game-result {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border: 3px double var(--line);
  background: var(--paper);
}

.game-result > strong { font-size: 1.15rem; }
.game-result .button { justify-self: start; }

.saved-destination {
  padding: 10px 12px;
  border-left: 5px solid var(--green);
  background: var(--paper);
}

.dice-screen { max-width: 650px; }
.dice-row { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 38px 0; }
.die { display: grid; place-items: center; width: clamp(100px, 25vw, 150px); aspect-ratio: 1; border: 4px solid var(--ink); border-radius: 16px; box-shadow: inset 0 -9px 0 rgba(51, 47, 41, 0.13), 5px 5px 0 rgba(51, 47, 41, 0.2); background: white; font-size: 4rem; font-weight: 900; }
.die.is-rolling { animation: shake 0.1s linear infinite alternate; }
.plus { font-size: 2rem; font-weight: 900; }
.dice-total { display: grid; place-items: center; min-height: 90px; margin-top: 16px; padding: 12px; border: 3px dashed var(--blue); background: var(--paper); }
.dice-total span { color: var(--blue); font-size: 0.75rem; font-weight: 900; }
.dice-total strong { font-size: 1.65rem; }
.dice-total.is-decided { border-style: solid; border-color: var(--green); background: #edf2e9; }

/* 現在の旅 */
.quest-screen {
  max-width: 900px;
  margin-inline: auto;
  background: #202a2d;
  color: #f9f1dc;
  box-shadow: 7px 7px 0 rgba(51, 47, 41, 0.3);
}

.quest-status-bar { display: flex; justify-content: space-between; padding-bottom: 10px; border-bottom: 2px dashed #92aa8a; color: #c7d9be; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.12em; }
.quest-status-bar strong { color: #f2d566; }
.quest-main { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: center; padding: 24px 0; }
.quest-main img { width: 180px; max-height: 220px; object-fit: contain; }
.quest-main h2 { margin: 9px 0; font-size: clamp(1.7rem, 4vw, 2.7rem); }
.quest-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quest-stats div { padding: 13px; border: 2px solid #87928c; background: #2e3a3e; }
.quest-stats span, .quest-stats strong { display: block; }
.quest-stats span { color: #b8c9c1; font-size: 0.7rem; }
.quest-events, .next-preview { margin-top: 16px; padding: 16px; border: 2px solid #87928c; background: #2e3a3e; }
.quest-events h3 { margin-top: 0; color: #f2d566; }
.quest-events ul { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.quest-events li { padding: 4px 8px; border: 1px solid #87928c; }
.next-preview .button.secondary { background: #e8e1d2; }

.scene-jumps { max-width: 900px; margin-inline: auto; }
.scene-jumps h2 { margin-top: 0; }
.scene-jumps a { display: inline-flex; gap: 8px; margin: 4px; padding: 9px 12px; border: 2px solid var(--line); background: var(--paper-2); color: #426c8a; font-weight: 900; text-decoration: none; }
.scene-jumps a span { padding: 0 6px; background: var(--blue); color: white; }

@keyframes blink { to { filter: brightness(1.08); transform: scale(1.02); } }
@keyframes shake { to { transform: translateY(-5px) rotate(4deg); } }
@keyframes impact { 30% { transform: scale(1.02); } 55% { transform: scale(0.99); } }
@keyframes page-out { to { opacity: 0; transform: translateY(3px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes bang {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); }
  30%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1.25) rotate(5deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

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

@media (max-width: 820px) {
  .site-header { flex-wrap: wrap; }
  .menu-toggle { display: grid; place-items: center; }
  .site-nav { display: none; width: 100%; align-items: stretch; flex-direction: column; }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 10px; }
  .home-hero, .latest-feature-grid { grid-template-columns: 1fr; }
  .home-hero { min-height: 0; }
  .home-hero-visual { margin-right: 20px; }
  .quick-menu { grid-template-columns: 1fr; }
  .part-card, .coming-soon { grid-template-columns: 1fr; }
  .part-thumbnail img { min-height: 0; aspect-ratio: 16 / 9; }
  .part-number { min-height: 160px; }
  .quest-main { grid-template-columns: 120px 1fr; }
  .quest-main img { width: 120px; }
  .quest-stats { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { overflow-x: hidden; }
  .site-header { top: 4px; width: calc(100% - 12px); margin-top: 6px; }
  .brand { font-size: 0.86rem; }
  .page { width: calc(100% - 12px); }
  .home-hero { padding: 22px 17px; }
  .home-hero h1 { max-width: 100%; font-size: 2.45rem; overflow-wrap: anywhere; }
  .hero-lead br { display: none; }
  .home-hero-visual { width: 100%; margin-right: 0; transform: none; }
  .hero-mascot { right: -5px; bottom: -30px; width: 100px; }
  .latest-feature, .quick-menu, .page-heading, .game-screen, .quest-screen, .scene-jumps { padding: 18px 14px; }
  .rule-flow article { padding: 78px 16px 20px; }
  .pixel-icon { top: 18px; left: 16px; }
  .step { position: absolute; top: 34px; left: 78px; }
  .part-meta { align-items: flex-start; flex-direction: column; }
  .part-body dl div { grid-template-columns: 1fr; gap: 0; }
  .roulette-map-shell, .roulette-map { width: 100%; min-width: 0; max-width: 100%; min-height: 350px; height: 350px; }
  .roulette-window { right: 8px; bottom: 8px; min-width: 145px; padding: 8px; }
  .roulette-window strong { font-size: 1.25rem; }
  .exclusion-controls { align-items: flex-start; flex-direction: column; }
  .exclusion-options { grid-template-columns: repeat(2, 1fr); }
  .dice-row { gap: 8px; padding: 28px 0; }
  .die { width: 105px; font-size: 3rem; }
  .quest-main { grid-template-columns: 1fr; text-align: center; }
  .quest-main img { margin: 0 auto; }
  .quest-actions, .part-actions { align-items: stretch; flex-direction: column; }
  .quest-actions .button, .part-actions .button { text-align: center; }
}
