:root {
  color-scheme: light;
  --paper: #fff9f0;
  --ink: #25201f;
  --muted: #736966;
  --line: #2b2524;
  --accent: #d84f4f;
  --accent-soft: #ffe1da;
  --panel: rgba(255, 255, 255, 0.86);
  --shadow: 0 18px 60px rgba(54, 42, 37, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(216, 79, 79, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(44, 127, 104, 0.06) 1px, transparent 1px),
    #f4efe7;
  background-size: 34px 34px;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 108px;
  padding-bottom: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

.brand-logo {
  display: block;
  width: clamp(130px, 15vw, 190px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(3px 4px 0 rgba(43, 37, 36, 0.12));
}

.brand-logo-link {
  display: block;
  flex: 0 0 auto;
}

.brand-home {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-home:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.brand-home:focus-visible,
.brand-logo-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand-subtitle {
  margin: 0;
  font-size: clamp(1.28rem, 3vw, 2.3rem);
  font-weight: 900;
  line-height: 1.18;
}

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.34rem, 4vw, 2.4rem);
  line-height: 1.18;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 4px 4px 0 var(--line);
  cursor: pointer;
}

.icon-button:hover {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 var(--line);
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  min-height: 620px;
  padding: 20px;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.95), transparent 22rem),
    linear-gradient(135deg, #faf4e9, #f6ded8 45%, #dbeadf);
  box-shadow: var(--shadow);
}

.background-sign {
  position: absolute;
  top: 22px;
  right: 24px;
  display: grid;
  gap: 4px;
  width: min(320px, 42vw);
  padding: 14px 18px;
  border: 2px solid rgba(43, 37, 36, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  transform: rotate(1.5deg);
}

.background-sign span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.background-sign strong {
  font-size: clamp(1.1rem, 3vw, 1.8rem);
}

.character-card {
  position: relative;
  z-index: 1;
  align-self: end;
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 8px 8px 0 rgba(43, 37, 36, 0.16);
}

.portrait {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 310px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(transparent 66%, rgba(37, 32, 31, 0.08) 66%),
    var(--accent-soft);
  overflow: hidden;
}

.portrait::before {
  content: "";
  position: absolute;
  bottom: 32px;
  width: 168px;
  height: 190px;
  border: 3px solid var(--line);
  border-bottom: 0;
  border-radius: 72px 72px 18px 18px;
  background: var(--accent);
}

.portrait::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 250px;
  height: 92px;
  border-top: 3px solid var(--line);
  background: #fff;
}

.portrait.has-portrait-art {
  --portrait-art-left: -56.5674%;
  --portrait-art-top: 0%;
  place-items: center;
  width: 100%;
  aspect-ratio: 571 / 454;
}

.portrait.has-portrait-art::before,
.portrait.has-portrait-art::after,
.portrait.has-portrait-art .face {
  display: none;
}

.portrait-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.portrait-art[hidden] {
  display: none;
}

.portrait-teshigawara.has-portrait-art {
  --portrait-art-left: -58.6%;
  --portrait-art-top: -6.6%;
}

.portrait-ado.has-portrait-art {
  --portrait-art-left: -48%;
  --portrait-art-top: 4.4%;
}

/* Frame the face and shoulders while retaining the full 1240px-wide image. */
.portrait.has-portrait-art .portrait-art {
  position: absolute;
  top: var(--portrait-art-top);
  left: var(--portrait-art-left);
  width: 217.163%;
  height: auto;
}

.face {
  position: relative;
  z-index: 1;
  width: 138px;
  height: 138px;
  margin-bottom: 118px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #fff5e7;
}

.eye {
  position: absolute;
  top: 54px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
}

.eye.left {
  left: 40px;
}

.eye.right {
  right: 40px;
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 36px;
  width: 34px;
  height: 14px;
  border-bottom: 3px solid var(--line);
  border-radius: 0 0 30px 30px;
  transform: translateX(-50%);
}

.portrait-sato::before {
  border-radius: 80px 80px 20px 20px;
}

.portrait-teshigawara::before {
  width: 188px;
  background:
    linear-gradient(145deg, transparent 0 58%, rgba(255, 255, 255, 0.26) 58% 62%, transparent 62%),
    var(--accent);
}

.portrait-teshigawara .face {
  border-radius: 48% 52% 45% 55%;
}

.portrait-ado {
  background:
    linear-gradient(transparent 66%, rgba(37, 32, 31, 0.08) 66%),
    #ece7ff;
}

.portrait-ado::before {
  width: 196px;
  border-radius: 42px 42px 18px 18px;
  background: #262236;
}

.portrait-ado .face {
  background: #fff1eb;
}

.profile-label {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile h2 {
  margin-bottom: 6px;
  font-size: 1.55rem;
}

.profile p {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.6;
}

#statsList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

#statsList li {
  padding: 5px 9px;
  border: 1px solid rgba(43, 37, 36, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.dialogue-panel {
  position: relative;
  z-index: 1;
  align-self: end;
  display: grid;
  gap: 14px;
  min-height: 392px;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.message-box {
  min-height: 176px;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 8px 8px 0 rgba(43, 37, 36, 0.12);
}

.speaker {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  font-weight: 900;
}

.message {
  margin-bottom: 0;
  font-size: clamp(1.02rem, 2.4vw, 1.24rem);
  line-height: 1.9;
  white-space: pre-line;
}

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

.choice-button,
.primary-button {
  min-height: 72px;
  padding: 14px 16px;
  border: 3px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 5px 5px 0 var(--line);
  font-weight: 900;
  line-height: 1.5;
  cursor: pointer;
}

.choice-button:hover,
.primary-button:hover {
  color: #fff;
  background: var(--accent);
  transform: translate(1px, 1px);
  box-shadow: 4px 4px 0 var(--line);
}

.primary-button {
  justify-self: start;
  min-height: 52px;
}

.character-select {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.character-select .choice-button {
  min-height: 118px;
  text-align: left;
}

.choice-title {
  display: block;
  margin-bottom: 6px;
  font-size: 1.18rem;
}

.choice-meta {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.choice-button:hover .choice-meta {
  color: rgba(255, 255, 255, 0.82);
}

.customize-panel {
  margin-top: 16px;
  padding: 14px 18px;
  border: 2px dashed rgba(43, 37, 36, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.customize-panel h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.customize-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(43, 37, 36, 0.09);
}

.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;
}

@media (max-width: 920px) {
  .top-bar {
    align-items: center;
    gap: 10px;
    min-height: auto;
    padding: 6px 0 12px;
  }

  .brand-lockup {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 4px 10px;
    flex: 1;
  }

  .brand-copy {
    display: contents;
  }

  .brand-logo-link {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .brand-logo {
    width: 72px;
  }

  .kicker {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0;
  }

  .brand-home {
    grid-column: 2;
    grid-row: 2;
    font-size: 1.25rem;
    word-break: keep-all;
  }
}

@media (max-width: 820px) {
  .game-shell {
    width: min(100% - 18px, 640px);
    padding-top: 10px;
  }

  .stage {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 12px;
  }

  .background-sign {
    position: relative;
    inset: auto;
    width: 100%;
    margin-bottom: 2px;
    transform: none;
  }

  .character-card {
    align-self: stretch;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }

  .portrait {
    min-height: 140px;
  }

  .portrait::before {
    bottom: 20px;
    width: 86px;
    height: 92px;
    border-width: 2px;
  }

  .portrait::after {
    width: 140px;
    height: 34px;
    border-top-width: 2px;
  }

  .face {
    width: 72px;
    height: 72px;
    margin-bottom: 52px;
    border-width: 2px;
  }

  .eye {
    top: 29px;
    width: 7px;
    height: 7px;
  }

  .eye.left {
    left: 21px;
  }

  .eye.right {
    right: 21px;
  }

  .mouth {
    bottom: 18px;
    width: 18px;
    height: 8px;
    border-bottom-width: 2px;
  }

  .dialogue-panel {
    min-height: auto;
  }

  .message-box {
    min-height: 168px;
    padding: 16px;
  }

  .choices,
  .character-select {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: 62px;
  }
}

@media (max-width: 440px) {
  .character-card {
    grid-template-columns: 1fr;
  }

  .portrait {
    min-height: 190px;
  }
}
