:root {
  --page-bg-top: black;
  --page-bg-bottom: black;
  --panel-bg: rgba(255, 212, 246, 0.94);
  --panel-border: yellow;
  --text-color: black;
  --touga-color: #f84e4a;
  --card-bg: rgba(255, 241, 249, 0.9);
  --card-border: #d9318e;
  --modal-overlay: rgba(12, 4, 8, 0.82);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text-color);
  background: linear-gradient(
    180deg,
    var(--page-bg-top) 0%,
    var(--page-bg-bottom) 100%
  );
}

h1 {
  font-size: 3em;
  text-align: center;
}

h2 {
  text-align: center;
}

.scene {
  position: relative;
  width: min(68vw, 760px);
  margin-left: min(24vw, 300px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.textbox {
  width: 100%;
  min-height: 420px;
  max-height: 75vh;
  overflow-y: auto;
  overflow-wrap: break-word;
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel-bg);
  color: inherit;
  font:
    1.05rem/1.55 Georgia,
    "Times New Roman",
    serif;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 16px 38px rgba(40, 20, 20, 0.16);
}

.character-portraits {
  margin-top: 1.1rem;
  display: grid;
  gap: 0.9rem;
}

.character-card {
  display: grid;
  grid-template-columns: minmax(80px, 120px) 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  background: var(--card-bg);
}

.character-card__image {
  width: 100%;
  max-width: 120px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  border: 1px solid rgba(120, 20, 70, 0.35);
}

.character-card__details {
  display: contents;
}

.character-card__name {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-align: center;
}

.character-card__open {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid #651444;
  background: linear-gradient(180deg, #fff6fd 0%, #ffc2e4 100%);
  color: #6d1344;
  font-size: 1.3rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.character-card__open:hover,
.character-card__open:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(82, 12, 50, 0.2);
}

.character-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 30;
}

.character-modal.is-open {
  display: grid;
  place-items: center;
}

.character-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-overlay);
}

.character-modal__panel {
  position: relative;
  width: min(700px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  background: #ffeef9;
  box-shadow: 0 20px 46px rgba(10, 2, 7, 0.5);
  padding: 1rem;
}

.character-modal__close {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid #651444;
  background: linear-gradient(180deg, #fff6fd 0%, #ffc2e4 100%);
  color: #6d1344;
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.character-modal__close:hover,
.character-modal__close:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(82, 12, 50, 0.2);
}

.character-modal__content {
  display: grid;
  grid-template-columns: minmax(130px, 190px) 1fr;
  gap: 0.95rem;
  padding: 1.6rem 0.3rem 0.2rem;
}

.character-modal__image {
  width: 100%;
  max-width: 190px;
  border-radius: 10px;
  border: 2px solid rgba(109, 20, 68, 0.45);
  object-fit: cover;
  aspect-ratio: 1 / 1;
}

.character-modal__text h2 {
  margin: 0 0 0.55rem;
}

.character-modal__text p {
  margin: 0;
}

.utena-image {
  position: fixed;
  left: -2vw;
  bottom: 0;
  transform: translateY(-40px);
  width: clamp(420px, 58vw, 900px);
  max-height: 92vh;
  height: auto;
  object-fit: contain;
  display: block;
  z-index: 5;
  pointer-events: none;
}

@media (max-width: 700px) {
  body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0.75rem 1.25rem;
  }

  .scene {
    width: min(94vw, 760px);
    margin-left: 0;
    padding: 0;
  }

  .textbox {
    min-height: 280px;
    font-size: 1rem;
    padding: 1rem;
  }

  .character-card {
    grid-template-columns: minmax(72px, 96px) 1fr auto;
  }

  .character-modal__content {
    grid-template-columns: 1fr;
    padding-top: 2rem;
  }

  .character-modal__image {
    max-width: 180px;
    margin-inline: auto;
  }

  .utena-image {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: min(44vw, 240px);
    max-height: none;
    order: -1;
    margin: 0 0 0.2rem;
    z-index: 1;
  }
}
