* {
  box-sizing: border-box;
}

:root {
  --paper: #fffaf1;
  --paper-deep: #f4ead8;
  --paper-soft: #fbf4e8;
  --ink: #44372f;
  --muted: #78685e;
  --accent: #8a5a44;
  --accent-dark: #69402f;
  --accent-light: #b88970;
  --gold: #c79a4b;
  --gold-soft: #e7c98d;
  --line: #dccbb5;
  --line-strong: #cbb69b;
  --white: #ffffff;
  --shadow: 0 14px 36px rgba(77, 54, 40, 0.14);
  --shadow-soft: 0 8px 20px rgba(77, 54, 40, 0.10);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 34%),
    linear-gradient(145deg, #efe3d1, #d8c4ac);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    Meiryo,
    sans-serif;
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 38px 0 60px;
}


/* ========================================
   HERO
======================================== */

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

h1,
h2,
h3 {
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "Hiragino Mincho Pro",
    serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 4.2rem);
  line-height: 1.2;
  letter-spacing: 0.08em;
}

.lead {
  max-width: 720px;
  margin: 18px auto 0;
  color: var(--muted);
  line-height: 1.95;
}


/* ========================================
   CARD COMMON
======================================== */

.alchemy-card,
.history-card,
.info-card,
.notice-card {
  background: rgba(255, 250, 241, 0.96);
  border: 1px solid rgba(138, 90, 68, 0.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.alchemy-card {
  padding: clamp(22px, 5vw, 42px);
}

.history-card,
.info-card,
.notice-card {
  margin-top: 22px;
  padding: 24px;
}

.alchemy-card h2,
.history-card h2,
.info-card h2,
.notice-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.maker-description,
.history-description {
  margin-top: 0;
  color: var(--muted);
  line-height: 1.8;
}


/* ========================================
   SELECTORS
======================================== */

.selectors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
  margin: 28px 0;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 54px;
  padding: 0 44px 0 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background-color: #fff;
  font-size: 1rem;
  box-shadow: inset 0 1px 2px rgba(77, 54, 40, 0.04);
}

select:focus {
  outline: 3px solid rgba(199, 154, 75, 0.22);
  border-color: var(--gold);
}

.plus {
  padding-bottom: 13px;
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 700;
}


/* ========================================
   MAIN BUTTON
======================================== */

.generate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(360px, 100%);
  min-height: 60px;
  margin: 0 auto;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 18px rgba(105, 64, 47, 0.28);
  font-size: 1.12rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.generate-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 22px rgba(105, 64, 47, 0.32);
}

.generate-button:active {
  transform: translateY(1px);
}

.generate-button:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
  box-shadow: 0 6px 14px rgba(105, 64, 47, 0.18);
}

.button-icon {
  font-size: 1.1em;
}


/* ========================================
   ALCHEMY STAGE
======================================== */

.alchemy-stage {
  position: relative;
  min-height: 240px;
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.95), transparent 38%),
    linear-gradient(180deg, #fffdf8, #f5ead9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.stage-scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 22px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
}

.stage-scene.stage-scene-active {
  position: absolute;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: sceneFadeIn 0.35s ease both;
}

.stage-image {
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(84, 57, 42, 0.14));
}

.stage-koppe-image {
  width: min(150px, 34vw);
  max-height: 170px;
  object-fit: contain;
}

.stage-book-image {
  width: min(190px, 54vw);
  max-height: 210px;
}
.waiting-book-image {
  width: 140px;
  max-width: 140px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(84, 57, 42, 0.15));
}
.stage-open-book-image {
  width: min(260px, 72vw);
  max-height: 205px;
}

.stage-message {
  margin: 0;
  color: var(--accent-dark);
  font-size: clamp(1rem, 3.8vw, 1.18rem);
  font-weight: 700;
  line-height: 1.7;
}

.stage-success-message {
  color: var(--accent-dark);
  font-size: clamp(1.2rem, 4vw, 1.4rem);
}


/* scene animations */

.searching-koppe {
  animation: walkingBounce 0.7s ease-in-out infinite alternate;
}

.book-found-image {
  animation: bookFound 0.5s ease both;
}

.book-ready-image {
  animation: bookReady 0.5s ease both;
}

.book-open-effect,
.mixing-effect,
.success-effect {
  position: relative;
  display: grid;
  place-items: center;
}

.stage-open-book-image {
  animation: bookOpen 0.6s ease both;
}

.chemical-koppe {
  transform-origin: 55% 70%;
  animation: flaskMix 0.8s ease-in-out infinite alternate;
}

.success-koppe {
  animation: successPop 0.55s cubic-bezier(0.2, 0.8, 0.25, 1.25) both;
}


/* sparkles */

.book-sparkle,
.mixing-sparkle,
.success-sparkle {
  position: absolute;
  z-index: 2;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(199, 154, 75, 0.55);
  pointer-events: none;
}

.book-sparkle {
  font-size: 1.5rem;
  animation: twinkle 1s ease-in-out infinite alternate;
}

.book-sparkle-one {
  top: 4%;
  left: 8%;
}

.book-sparkle-two {
  top: 18%;
  right: 5%;
  animation-delay: 0.2s;
}

.book-sparkle-three {
  bottom: 8%;
  right: 16%;
  animation-delay: 0.4s;
}

.mixing-sparkle {
  font-size: 1.4rem;
  animation: floatSparkle 1.2s ease-in-out infinite;
}

.mixing-sparkle-one {
  top: 8%;
  left: 8%;
}

.mixing-sparkle-two {
  top: 20%;
  right: 5%;
  animation-delay: 0.25s;
}

.mixing-sparkle-three {
  bottom: 10%;
  right: 16%;
  animation-delay: 0.5s;
}

.success-sparkle {
  font-size: 1.7rem;
  animation: successSparkle 0.8s ease-in-out infinite alternate;
}

.success-sparkle-one {
  top: 0;
  left: 4%;
}

.success-sparkle-two {
  top: 10%;
  right: 8%;
  animation-delay: 0.2s;
}

.success-sparkle-three {
  bottom: 2%;
  right: 14%;
  animation-delay: 0.4s;
}


/* ========================================
   RESULT
======================================== */

.result-area {
  margin-top: 22px;
  padding: 26px 16px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 237, 221, 0.95));
  border: 1px solid var(--line);
  border-radius: 18px;
}

.result-area.result-ready {
  animation: resultReveal 0.55s ease both;
}

.result-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.result-decoration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto 10px;
  color: var(--gold);
}

.result-line {
  width: 90px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}

.result-symbol {
  font-size: 1.15rem;
}

.result-word {
  min-height: 1.45em;
  margin: 0;
  overflow-wrap: anywhere;
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "Hiragino Mincho Pro",
    serif;
  font-size: clamp(1.85rem, 7vw, 3.35rem);
  font-weight: 700;
  line-height: 1.35;
}

.result-word.is-mixing {
  animation: pulse 0.45s ease;
}

.result-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}


/* ========================================
   RESULT ACTIONS
======================================== */

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.sub-button {
  min-width: 150px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.sub-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent-light);
  background: #fffdf9;
}

.sub-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.copy-message {
  min-height: 1.4em;
  margin: 10px 0 0;
  text-align: center;
  color: var(--accent-dark);
  font-weight: 700;
}


/* ========================================
   HISTORY
======================================== */

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.text-button {
  border: 0;
  color: var(--accent);
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

.history-list {
  margin: 14px 0 0;
  padding-left: 1.7em;
}

.history-list li {
  padding: 9px 4px;
  border-bottom: 1px dashed var(--line);
}

.history-list li:last-child {
  border-bottom: 0;
}

.history-list button {
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.empty-history {
  color: var(--muted);
}


/* ========================================
   INFO
======================================== */

.info-card > p,
.notice-card p {
  line-height: 1.9;
}

.use-examples {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.use-example {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-soft);
}

.use-example h3 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 1.05rem;
}

.use-example p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.word-count-box {
  margin-top: 22px;
  padding: 18px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, var(--paper-deep));
}

.word-count-title {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-weight: 700;
}

.word-count {
  margin: 0;
  line-height: 1.8;
}

.word-count strong,
.combination-count strong {
  color: var(--accent-dark);
  font-size: 1.15em;
}

.word-count-divider {
  margin: 0 8px;
  color: var(--line-strong);
}

.combination-count {
  margin: 8px 0 0;
  color: var(--muted);
}


/* ========================================
   NOTICE
======================================== */

.notice-card {
  background: rgba(255, 250, 241, 0.92);
}


/* ========================================
   KEYFRAMES
======================================== */

@keyframes sceneFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes walkingBounce {
  from {
    transform: translateX(-4px) translateY(0) rotate(-1deg);
  }

  to {
    transform: translateX(4px) translateY(-4px) rotate(1deg);
  }
}

@keyframes bookFound {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(-8deg) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@keyframes bookReady {
  from {
    opacity: 0;
    transform: rotateY(18deg) scale(0.94);
  }

  to {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
  }
}

@keyframes bookOpen {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  55% {
    opacity: 1;
    transform: scale(1.035);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flaskMix {
  from {
    transform: rotate(-2deg) translateY(0);
  }

  to {
    transform: rotate(2deg) translateY(-3px);
  }
}

@keyframes successPop {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(18px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes twinkle {
  from {
    opacity: 0.35;
    transform: scale(0.8) rotate(0deg);
  }

  to {
    opacity: 1;
    transform: scale(1.15) rotate(12deg);
  }
}

@keyframes floatSparkle {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(4px) scale(0.9);
  }

  50% {
    opacity: 1;
    transform: translateY(-5px) scale(1.1);
  }
}

@keyframes successSparkle {
  from {
    opacity: 0.4;
    transform: scale(0.8) rotate(-8deg);
  }

  to {
    opacity: 1;
    transform: scale(1.15) rotate(8deg);
  }
}

@keyframes resultReveal {
  from {
    opacity: 0.25;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.98);
  }
}


/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 760px) {
  .use-examples {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 920px);
    padding-top: 24px;
  }

  .alchemy-card {
    padding: 20px 16px 24px;
  }

  .history-card,
  .info-card,
  .notice-card {
    padding: 20px 16px;
  }

  .selectors {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .plus {
    padding: 0;
    text-align: center;
  }

  .alchemy-stage {
    min-height: 300px;
  }

  .stage-koppe-image {
  width: min(140px, 38vw);
  max-height: 160px;
}

  .stage-book-image {
    width: min(165px, 58vw);
  }

  .stage-open-book-image {
    width: min(230px, 78vw);
  }

  .result-actions {
    flex-direction: column;
  }

  .sub-button {
    width: 100%;
  }

  .section-heading {
    align-items: flex-start;
  }

  .word-count-divider {
    display: block;
    height: 4px;
    overflow: hidden;
    color: transparent;
  }
}


/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
/* ========================================
   画像サイズの最終固定
======================================== */

.alchemy-stage .stage-koppe-image {
  width: 150px !important;
  height: auto !important;
  max-width: 150px !important;
  max-height: 170px !important;
  object-fit: contain !important;
}

.alchemy-stage .stage-book-image {
  width: 180px !important;
  height: auto !important;
  max-width: 180px !important;
  max-height: 200px !important;
  object-fit: contain !important;
}

.alchemy-stage .stage-open-book-image {
  width: 250px !important;
  height: auto !important;
  max-width: 250px !important;
  max-height: 200px !important;
  object-fit: contain !important;
}

@media (max-width: 620px) {
  .alchemy-stage .stage-koppe-image {
    width: 130px !important;
    max-width: 130px !important;
    max-height: 150px !important;
  }

  .alchemy-stage .stage-book-image {
    width: 150px !important;
    max-width: 150px !important;
  }

  .alchemy-stage .stage-open-book-image {
    width: 210px !important;
    max-width: 210px !important;
  }
}
.waiting-book-image {
  width: 110px;
  max-width: 110px;
}
#stageWaiting .waiting-book-image {
  width: 140px !important;
  height: auto !important;
  max-width: 140px !important;
  max-height: 170px !important;
  object-fit: contain !important;
}