:root {
  --ink: #31463c;
  --muted: #6d7c72;
  --paper: #f8f4e8;
  --paper-deep: #eee6d2;
  --leaf: #607e45;
  --leaf-dark: #405d37;
  --clay: #aa6044;
  --line: rgba(64, 82, 68, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 3%, rgba(255, 255, 255, 0.95), transparent 23rem),
    repeating-linear-gradient(92deg, rgba(100, 83, 54, 0.018) 0 1px, transparent 1px 5px),
    var(--paper-deep);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

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

/* まずスマートフォン向けの1カラムを基本にします。 */
.page-shell {
  width: min(100% - 20px, 1180px);
  margin: 0 auto;
  padding: 16px 0 24px;
}

.brand-header {
  display: flex;
  align-items: center;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(117, 88, 48, 0.35);
  border-radius: 50% 45% 52% 46%;
  color: #735c34;
  background: rgba(255, 252, 240, 0.58);
  font-size: 18px;
  transform: rotate(-3deg);
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.07em;
}

.season-note {
  display: none;
}

.intro {
  padding: 26px 3px 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #a06449;
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(29px, 9vw, 42px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.06em;
}

.intro > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.experience-grid {
  display: grid;
  gap: 14px;
}

.field-card,
.visit-panel {
  border: 1px solid rgba(72, 85, 70, 0.13);
  background: rgba(250, 247, 237, 0.74);
  box-shadow: 0 12px 32px rgba(74, 74, 53, 0.09);
}

.field-card {
  position: relative;
  overflow: hidden;
  padding: 6px;
  border-radius: 4px 12px 5px 10px;
}

.scene-meta {
  position: absolute;
  z-index: 4;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 4px;
  line-height: 1.4;
}

.weather-chip {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: #385146;
  background: rgba(250, 248, 235, 0.76);
  box-shadow: 0 2px 8px rgba(48, 64, 56, 0.08);
  backdrop-filter: blur(4px);
  font-family: "Yu Gothic", sans-serif;
  font-size: 9px;
  font-weight: 600;
}

.stage-chip {
  color: #5f6f35;
}

#canvas-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 2px 9px 2px 8px;
  background: #b7d2d1;
  line-height: 0;
}

/* 内部は800×600px、スマホでは比率を保って縮小表示します。 */
#canvas-container canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100% !important;
  height: auto !important;
}

/* 雨は軽いCSSの移動だけにして、p5の連続再描画を避けます。 */
#weather-overlay {
  position: absolute;
  z-index: 2;
  inset: -35% 0 0;
  display: none;
  pointer-events: none;
}

#weather-overlay.rainy {
  display: block;
  opacity: 0.38;
  background-image: repeating-linear-gradient(
    103deg,
    transparent 0 17px,
    rgba(197, 224, 231, 0.8) 18px 19px,
    transparent 20px 37px
  );
  background-size: 41px 58px;
  animation: gentle-rain 1.1s linear infinite;
}

#weather-overlay.rainy::after {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.55;
  background-image: repeating-linear-gradient(
    102deg,
    transparent 0 31px,
    rgba(220, 238, 241, 0.8) 32px 33px,
    transparent 34px 63px
  );
  background-size: 67px 83px;
  animation: gentle-rain 1.55s linear infinite;
}

@keyframes gentle-rain {
  from { transform: translate3d(0, -58px, 0); }
  to { transform: translate3d(-14px, 58px, 0); }
}

.canvas-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 6px 1px;
  color: #718078;
  font-size: 9px;
  line-height: 1.6;
  letter-spacing: 0.03em;
}

.canvas-caption > span:first-child {
  color: #779a91;
  font-size: 17px;
}

.visit-panel {
  padding: 21px 17px 18px;
  border-radius: 11px 3px 12px 4px;
}

.visit-heading h2 {
  margin-bottom: 16px;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.count-card {
  padding: 15px 16px;
  border: 1px solid rgba(96, 126, 69, 0.18);
  border-radius: 2px 9px 3px 8px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.55), rgba(226, 234, 207, 0.35)),
    rgba(239, 237, 214, 0.7);
}

.count-label {
  color: var(--muted);
  font-size: 10px;
}

#login-count-display {
  margin: 4px 0 3px;
  font-size: 14px;
}

#login-count-display strong {
  margin-right: 5px;
  color: var(--leaf-dark);
  font-family: Georgia, serif;
  font-size: 34px;
  font-weight: 400;
}

.stage-message {
  color: #687452;
  font-size: 10px;
}

.visit-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 15px;
  border: 0;
  border-radius: 3px 11px 4px 9px;
  color: #fffdf3;
  background: var(--leaf-dark);
  box-shadow: 0 6px 16px rgba(54, 83, 48, 0.18);
  font: 600 14px/1.4 "Yu Gothic", sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease, background 160ms ease;
}

.visit-button:active:not(:disabled) {
  transform: scale(0.985);
}

.visit-button:disabled {
  color: #6e7866;
  background: #d9dccb;
  box-shadow: none;
  cursor: default;
}

.visit-button:focus-visible {
  outline: 3px solid rgba(170, 96, 68, 0.35);
  outline-offset: 3px;
}

.visit-status {
  min-height: 17px;
  margin: 7px 2px 17px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
}

.auth-panel {
  margin-bottom: 14px;
  padding: 14px 13px;
  border: 1px solid rgba(96, 126, 69, 0.2);
  border-radius: 10px 4px 11px 3px;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.54), rgba(232,239,214,0.36)),
    rgba(250, 247, 237, 0.62);
}

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

.auth-heading h3 {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.auth-heading span {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: #6b7350;
  background: rgba(255, 255, 255, 0.62);
  font-size: 9px;
}

.auth-status,
.auth-user {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.7;
}

.auth-user {
  color: #687452;
  overflow-wrap: anywhere;
}

.auth-actions {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.auth-button {
  min-height: 40px;
  padding: 10px 12px;
  border: 0;
  border-radius: 999px;
  color: #fffdf3;
  background: #6d7c72;
  box-shadow: 0 6px 14px rgba(65, 82, 71, 0.13);
  font: 600 12px/1.4 "Yu Gothic", sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease, background 160ms ease;
}

.google-auth-button {
  color: #3f4b45;
  background: #fffdf8;
  border: 1px solid rgba(78, 89, 82, 0.18);
}

.auth-button-subtle {
  color: #536159;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
  border: 1px solid rgba(96, 126, 69, 0.18);
}

.auth-policy-note {
  margin: 2px 0 0;
  color: #71675a;
  font-size: 0.72rem;
  line-height: 1.7;
}

.auth-policy-note a,
.footer-legal-links a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-button:active:not(:disabled) {
  transform: scale(0.985);
}

.auth-button:disabled {
  color: #78766a;
  background: #dad5c5;
  box-shadow: none;
  cursor: default;
}

.auth-button:focus-visible,
.email-login-form input:focus-visible {
  outline: 3px solid rgba(170, 96, 68, 0.35);
  outline-offset: 3px;
}

.email-login-form {
  display: grid;
  gap: 6px;
}

.email-login-form label {
  color: #6d7c72;
  font: 600 10px/1.5 "Yu Gothic", sans-serif;
}

.email-login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.email-login-form input {
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid rgba(96, 126, 69, 0.2);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
  font: 12px/1.4 "Yu Gothic", sans-serif;
}

.creature-panel {
  padding: 14px 13px;
  border: 1px dashed rgba(96, 126, 69, 0.28);
  border-radius: 9px 3px 10px 4px;
  background:
    radial-gradient(circle at 12% 14%, rgba(255,255,255,0.72), transparent 8rem),
    rgba(232, 239, 214, 0.48);
}

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

.creature-heading h3 {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.creature-message {
  min-height: 34px;
  margin: 9px 0 10px;
  color: #687452;
  font-size: 10px;
  line-height: 1.7;
}

.creature-find-button {
  display: flex;
  width: 100%;
  min-height: 42px;
  justify-content: center;
  align-items: center;
  margin: 0 0 13px;
  padding: 10px 12px;
  border: 0;
  border-radius: 999px;
  color: #fffdf3;
  background: #9a775d;
  box-shadow: 0 6px 14px rgba(106, 83, 58, 0.16);
  font: 600 12px/1.4 "Yu Gothic", sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms ease, background 160ms ease;
}

.creature-find-button:active:not(:disabled) {
  transform: scale(0.985);
}

.creature-find-button:disabled {
  color: #78766a;
  background: #dad5c5;
  box-shadow: none;
  cursor: default;
}

.creature-find-button:focus-visible {
  outline: 3px solid rgba(170, 96, 68, 0.35);
  outline-offset: 3px;
}

.creature-history {
  padding-top: 10px;
  border-top: 1px solid rgba(62, 84, 67, 0.12);
}

.creature-history-title {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 9px;
}

.creature-history-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.creature-history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: #536159;
  font-size: 10px;
}

.creature-history-list b {
  font-weight: 500;
}

.creature-history-list span {
  flex: 0 0 auto;
  color: #9a775d;
  font-family: Georgia, serif;
}

.rewards {
  padding-top: 16px;
  border-top: 1px dashed rgba(62, 84, 67, 0.22);
}

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

.rewards-heading h3 {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 600;
}

.rewards-heading > span {
  padding: 2px 7px;
  border-radius: 999px;
  color: #8e705b;
  background: rgba(170, 96, 68, 0.09);
  font-size: 9px;
}

.rewards-intro {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.7;
}

.reward-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reward-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #536159;
  font-size: 10px;
}

.reward-count {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(84, 107, 72, 0.2);
  border-radius: 50%;
  color: var(--leaf-dark);
  background: rgba(255, 255, 255, 0.38);
  font: 12px Georgia, serif;
}

.reward-copy b,
.reward-copy small {
  display: block;
}

.reward-copy b {
  overflow-wrap: anywhere;
  margin-bottom: 2px;
  font-weight: 500;
}

.reward-copy small {
  color: #8a948d;
  font-size: 9px;
}

.reward-progress {
  min-width: 48px;
  color: #9a775d;
  text-align: right;
  white-space: nowrap;
}

.reward-item.achieved .reward-count {
  color: #fffdf3;
  border-color: var(--leaf);
  background: var(--leaf);
}

.reward-item.achieved .reward-progress {
  color: var(--leaf);
  font-weight: 600;
}

.storage-note {
  margin: 17px 0 0;
  color: #929b93;
  font-size: 9px;
  text-align: center;
}

footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
  padding: 18px 3px 0;
  border-top: 1px solid var(--line);
  color: #7c877f;
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 0.05em;
}

footer p {
  margin-bottom: 0;
}

.footer-logo {
  width: min(220px, 66vw);
  aspect-ratio: 3.04 / 1;
  position: relative;
  align-self: flex-end;
  overflow: hidden;
  transition: opacity 160ms ease, transform 160ms ease;
}

.footer-logo img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 112.34%;
  max-width: none;
  height: auto;
  transform: translate(-5.47%, -29.1%);
}

.footer-legal-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 4px;
  font-size: 0.78rem;
}

.footer-logo:active {
  opacity: 0.78;
  transform: scale(0.985);
}

.footer-logo:focus-visible {
  outline: 3px solid rgba(96, 126, 69, 0.35);
  outline-offset: 3px;
}

/* タブレットでは見守り情報を2列にして縦長を抑えます。 */
@media (min-width: 700px) {
  .page-shell {
    width: min(100% - 36px, 1180px);
    padding-top: 24px;
  }

  .brand-header {
    justify-content: space-between;
    padding-bottom: 20px;
  }

  .season-note {
    display: block;
    margin: 0;
    color: #7b705f;
    font-size: 11px;
    letter-spacing: 0.12em;
  }

  .intro {
    padding: 34px 4px 22px;
  }

  .intro > p:last-child {
    max-width: 650px;
    font-size: 13px;
  }

  .field-card {
    padding: 10px;
  }

  .scene-meta {
    top: 22px;
    left: 22px;
    gap: 6px;
  }

  .weather-chip {
    padding: 5px 9px;
    font-size: 10px;
  }

  .visit-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    padding: 24px 22px 20px;
  }

  .visit-heading,
  .auth-panel,
  .creature-panel,
  .rewards,
  .storage-note {
    grid-column: 1 / -1;
  }

  .visit-status {
    align-self: center;
    margin: 14px 0;
  }

  footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }

  .footer-logo {
    width: 240px;
  }
}

/* デスクトップだけ、田んぼと見守り帳を横並びにします。 */
@media (min-width: 1020px) {
  .page-shell {
    padding-top: 28px;
  }

  .experience-grid {
    grid-template-columns: minmax(0, 800px) minmax(280px, 1fr);
    gap: 24px;
    align-items: start;
  }

  .visit-panel {
    display: block;
    padding: 25px 23px 21px;
  }

  .visit-status {
    margin: 8px 2px 20px;
  }

  .visit-button:hover:not(:disabled) {
    background: #526f3f;
    transform: translateY(-2px);
  }

  .footer-logo:hover {
    opacity: 0.82;
    transform: translateY(-2px);
  }
}

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