:root {
  color: #422c1d;
  background: #e9d9bd;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

body {
  background-color: #e9d9bd;
  background-image: radial-gradient(#c7aa7c 0.7px, transparent 0.7px);
  background-size: 8px 8px;
}

.site-header {
  position: relative;
  padding-right: 3rem;
}

.site-header > p { white-space: nowrap; font-size: clamp(0.55rem, 3vw, 0.75rem); }

.site-title {
  white-space: nowrap;
  font-size: clamp(1.08rem, 5.8vw, 1.875rem);
}

.site-title__link {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color 120ms ease, text-shadow 120ms ease;
}

.site-title__link:hover,
.site-title__link:focus-visible {
  color: #8a5733;
  text-shadow: 1px 1px 0 #f1ddb9;
}

@media (min-width: 640px) {
  .site-header { padding-right: 0; }
}

.about-button {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid #70482f;
  border-radius: 50%;
  background: #fff6e5;
  color: #70482f;
  font-family: Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 3px 3px 0 #b98d5e;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.about-button:hover { background: #f1ddb9; }
.about-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #b98d5e; }

.word-card {
  position: relative;
  overflow: hidden;
  border: 3px solid #70482f;
  border-radius: 6px;
  padding: 2.5rem 1.25rem;
  background-color: #FFFFFF;
  box-shadow: 7px 7px 0 #b98d5e, inset 0 0 0 4px #f1ddb9;
}

.word-card::before,
.word-card::after {
  position: absolute;
  color: #ba8650;
  font-family: Georgia, serif;
  font-size: 1.5rem;
  line-height: 1;
  content: "✦";
}

.word-card::before { top: 0.7rem; left: 0.8rem; }
.word-card::after { content: none; }

.word-card__label,
.oracle-result__label {
  display: inline-block;
  border-bottom: 1px dashed #a36e43;
  padding-bottom: 0.2rem;
  color: #8a5733;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.generated-word {
  margin-top: 1.5rem;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
}

.generated-word ruby {
  ruby-position: over;
  color: #422c1d;
}

.generated-word rt {
  color: #a69a84;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 0.32em;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  padding-bottom: 0.12em;
}

.initial-kamisama {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 120px;
  margin: 1rem auto 0;
  object-fit: contain;
}

.initial-kamisama.is-shaking {
  animation: kamisama-shake 100ms linear infinite;
}

.corner-kamisama {
  position: absolute;
  right: 0.8rem;
  bottom: 0.7rem;
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.generated-word.is-appearing {
  animation: word-appear 420ms ease-out both;
}

.oracle-result {
  margin: 1.5rem auto 0;
  max-width: 32rem;
  border-top: 1px dashed #a36e43;
  padding-top: 1rem;
}

.oracle-result.is-visible {
  animation: oracle-appear 420ms ease-out both;
}

.oracle-result.is-loading {
  border-color: #8a5733;
}

.oracle-result.is-loading .oracle-result__label {
  display: none;
}

.oracle-result__label {
  margin-bottom: 0.85rem;
}

.oracle-result__text {
  margin-top: 0;
  padding: 0 1.25rem 4rem;
  color: #623e29;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.8;
  text-align: left;
}

.oracle-result.is-loading .oracle-result__text {
  padding: 0;
  color: #8a5733;
  font-family: "Courier New", "MS Gothic", monospace;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-align: center;
}

.draw-thinking {
  margin: 0.7rem 0 0;
  padding: 0;
  color: #8a5733;
  font-family: "Courier New", "MS Gothic", monospace;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-align: center;
}

.oracle-result.is-loading .oracle-result__text::after,
.draw-thinking::after {
  display: inline-block;
  margin-left: 0.3rem;
  content: "●";
  animation: retro-connection-dot 850ms steps(2, end) infinite;
}

.result-image-download {
  position: absolute;
  z-index: 1;
  bottom: 12px;
  left: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgb(66 44 29 / 35%);
  border-radius: 50%;
  background: rgb(255 255 255 / 78%);
  color: #623e29;
  opacity: 0.72;
  transition: opacity 120ms ease, transform 120ms ease;
}

.result-image-download:hover { opacity: 1; }
.result-image-download:active { transform: translateY(1px); }
.result-image-download:disabled { cursor: wait; opacity: 0.45; }
.result-image-download svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.share-note {
  margin: -0.4rem 0 0;
  color: #7b6250;
  font-size: 0.72rem;
  line-height: 1.55;
  text-align: left;
}

.share-button {
  border: 2px solid #2f241d;
  border-radius: 4px;
  padding: 1rem 1.25rem;
  background: #2f241d;
  color: #fff9eb;
  font-size: 1.12rem;
  font-weight: 700;
  transition: transform 120ms ease, background-color 120ms ease;
}

.share-button:hover { background: #4b382b; }
.share-button:active { transform: translateY(2px); }

@keyframes word-appear {
  from { opacity: 0; transform: translateY(9px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes kamisama-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@keyframes oracle-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes retro-connection-dot {
  0%, 45% { opacity: 0.15; transform: translateY(1px); }
  46%, 100% { opacity: 1; transform: translateY(-1px); }
}

.draw-button,
.oracle-button {
  border: 2px solid #5b321f;
  border-radius: 4px;
  padding: 1rem 1.25rem;
  background: #a94d2e;
  color: #fff9eb;
  font-size: 1.12rem;
  font-weight: 700;
  box-shadow: 4px 4px 0 #5b321f;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.draw-button:hover:not(:disabled),
.oracle-button:hover:not(:disabled) { background: #be5a35; }

.draw-button:active:not(:disabled),
.oracle-button:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #5b321f;
}

.draw-button:disabled,
.oracle-button:disabled { cursor: wait; opacity: 0.6; }

.oracle-button {
  border-color: #80752f;
  background: #c3b14e;
  color: #422c1d;
  box-shadow: 4px 4px 0 #80752f;
}

.oracle-button:hover:not(:disabled) { background: #d3c35b; }

.oracle-button:active:not(:disabled) {
  box-shadow: 1px 1px 0 #80752f;
}

.draw-button:focus-visible,
.oracle-button:focus-visible,
.share-button:focus-visible,
.result-image-download:focus-visible,
.about-button:focus-visible,
.watch-ad-button:focus-visible,
.close-reward-dialog:focus-visible {
  outline: 3px solid #e6ad50;
  outline-offset: 3px;
}

.ad-placeholder {
  width: min(100%, 32rem);
  margin: 1.25rem auto 0;
  border: 1px dashed #ad8965;
  padding: 1rem;
  color: #947454;
  text-align: center;
  font-size: 0.75rem;
}

.ad-placeholder span { letter-spacing: 0.2em; }
.ad-placeholder p { margin-top: 0.25rem; }

.site-footer {
  margin-top: auto;
  padding: 1.5rem 0 0.25rem;
  color: #735a46;
  font-size: 0.75rem;
  line-height: 1.7;
  text-align: center;
}

.site-footer__link {
  margin-top: 0.65rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: #8a4128;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.site-footer__link:focus-visible {
  outline: 3px solid #e6ad50;
  outline-offset: 3px;
}

.reward-dialog {
  width: min(90vw, 28rem);
  border: 0;
  padding: 0;
  background: transparent;
}

.reward-dialog::backdrop { background: rgb(49 30 18 / 55%); }

.about-dialog {
  width: min(92vw, 42rem);
  max-width: none;
  max-height: 85vh;
  border: 0;
  padding: 0;
  background: #ffffff;
  overflow: hidden;
}

.about-dialog[open] {
  display: flex;
  flex-direction: column;
  height: min(85vh, 42rem);
  max-height: 85dvh;
}

.about-dialog::backdrop { background: rgb(49 30 18 / 62%); }

.privacy-dialog {
  width: min(92vw, 38rem);
  max-width: none;
  max-height: 85vh;
  border: 0;
  padding: 0;
  background: #ffffff;
  overflow: hidden;
}

.privacy-dialog[open] {
  display: flex;
  flex-direction: column;
  height: min(85vh, 38rem);
  max-height: 85dvh;
}

.privacy-dialog::backdrop { background: rgb(49 30 18 / 62%); }

.about-dialog__paper {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  height: 100%;
  border: 3px solid #70482f;
  background: #ffffff;
  box-shadow: 7px 7px 0 #b98d5e;
}

.about-dialog__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px dashed #a36e43;
  padding: 1rem 1.1rem 0.85rem;
  background: #ffffff;
}

.about-dialog__heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
}

.about-dialog__kamisama {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
}

.about-dialog__title {
  color: #70482f;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}

.about-dialog__close {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid #70482f;
  border-radius: 50%;
  background: #ffffff;
  color: #623e29;
  font-size: 1.7rem;
  line-height: 1;
}

.privacy-dialog__paper {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  height: 100%;
  border: 3px solid #70482f;
  background: #ffffff;
  box-shadow: 7px 7px 0 #b98d5e;
}

.privacy-dialog__header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px dashed #a36e43;
  padding: 1rem 1.1rem 0.85rem;
}

.privacy-dialog__title {
  color: #70482f;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}

.privacy-dialog__close {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid #70482f;
  border-radius: 50%;
  background: #ffffff;
  color: #623e29;
  font-size: 1.7rem;
  line-height: 1;
}

.about-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 1.1rem 1.75rem;
  color: #623e29;
  font-size: 0.94rem;
  line-height: 1.8;
}

.privacy-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 1.1rem 1.75rem;
  color: #623e29;
  font-size: 0.94rem;
  line-height: 1.8;
}

.about-dialog__section + .about-dialog__section {
  margin-top: 1.75rem;
}

.about-dialog__section h3 {
  color: #70482f;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
}

.about-dialog__section h4 {
  margin-top: 1rem;
  color: #8a5733;
  font-weight: 700;
}

.about-dialog__section p { margin-top: 0.65rem; }
.about-dialog__section a { color: #8a4128; text-decoration: underline; text-underline-offset: 0.18em; }

.privacy-dialog__section + .privacy-dialog__section { margin-top: 1.75rem; }
.privacy-dialog__section h3 {
  color: #70482f;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.5;
}
.privacy-dialog__section p { margin-top: 0.65rem; }
.privacy-dialog__section a { color: #8a4128; text-decoration: underline; text-underline-offset: 0.18em; }

.about-dialog__x-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
}

.about-dialog__x-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.about-dialog__close:focus-visible,
.about-dialog__body:focus-visible,
.privacy-dialog__close:focus-visible,
.privacy-dialog__body:focus-visible {
  outline: 3px solid #e6ad50;
  outline-offset: -3px;
}

.reward-dialog__paper {
  border: 3px solid #70482f;
  padding: 1.5rem;
  background: #fff6e5;
  box-shadow: 6px 6px 0 #b98d5e;
}

.reward-dialog__eyebrow {
  color: #8a5733;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  line-height: 1.5;
  text-align: center;
}

.reward-dialog__description {
  margin-top: 1rem;
  color: #624a38;
  font-size: 0.9rem;
  line-height: 1.8;
  text-align: center;
}

.ad-countdown {
  margin-top: 1rem;
  border: 1px dashed #a36e43;
  padding: 0.75rem;
  background: #f8e9cc;
  color: #70482f;
  font-weight: 700;
  text-align: center;
}

.reward-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
  border: 0;
  outline: 0;
  box-shadow: none;
}

.watch-ad-button,
.close-reward-dialog {
  border-radius: 4px;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.watch-ad-button {
  border: 2px solid #80752f;
  padding: 0.75rem 0.7rem;
  background: #c3b14e;
  color: #422c1d;
  font-size: 0.95rem;
  white-space: nowrap;
  box-shadow: 4px 4px 0 #80752f;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.watch-ad-button:hover:not(:disabled) { background: #d3c35b; }

.watch-ad-button:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #80752f;
  outline: none;
}

.watch-ad-button:focus,
.watch-ad-button:focus-visible {
  outline: none;
  outline-offset: 0;
  -webkit-tap-highlight-color: transparent;
}

.close-reward-dialog {
  border: 1px solid #9c704b;
  background: #f8e9cc;
  color: #623e29;
}

.watch-ad-button:disabled { cursor: wait; opacity: 0.6; }
.close-reward-dialog:disabled { cursor: wait; opacity: 0.65; }

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