/* ---- 使い方(ヘルプ)ページ ---- */
.help-section {
  margin-bottom: 40px;
}

.help-mockup {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}

.help-mockup__replica {
  border: 1px dashed #e8d3ae;
  border-radius: 8px;
  user-select: none;
}

.help-mockup__replica .site-header {
  border-bottom: none;
}

.help-mockup__replica .site-header .container {
  height: auto;
  flex-wrap: wrap;
  row-gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.help-mockup__replica nav {
  flex-wrap: wrap;
  row-gap: 8px;
  white-space: normal;
}

.help-mockup__replica nav span:not(.help-badge) {
  color: var(--text);
  text-decoration: none;
}

.help-callouts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}

.help-callout {
  flex: 1 1 160px;
  background: #fff8ef;
  border: 1px solid #e8d3ae;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}

.help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #c0392b;
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  line-height: 1;
  margin-right: 4px;
  flex-shrink: 0;
}

.help-mockup__replica .help-badge {
  vertical-align: middle;
}

.help-callout__title {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  font-size: 0.95rem;
}

.help-callout__desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}
/*


 */

:root {
  --primary: #e07a3f;
  --border: #ddd;
  --text: #333;
  --muted: #777;
  --bg: #fafafa;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--text);
  background: var(--bg);
  margin: 0;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.site-header .logo {
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header nav a, .link-button {
  color: var(--text);
  text-decoration: none;
}

.link-button {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.current-user {
  color: var(--muted);
}

.user-menu-header {
  display: inline-flex;
  align-items: center;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.user-menu-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  min-width: 120px;
  padding: 4px;
  z-index: 10;
}

.user-menu-list .link-button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 4px;
  background: #c0392b;
  color: #fff;
}

.user-menu-list .link-button:hover {
  background: #a53223;
}

main {
  padding: 24px 16px 64px;
}

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.flash.notice { background: #e6f4ea; color: #1e7b34; }
.flash.alert { background: #fdecea; color: #b3261e; }

h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }

.form-group {
  margin-bottom: 16px;
}

.app-rainbow-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #ff0080, #ff8c00, #ffe000, #00d2ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-form {
  max-width: 360px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.required-mark {
  color: #d32f2f;
  margin-left: 2px;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

textarea { min-height: 120px; }

.form-group:has(.password-toggle) {
  position: relative;
}

.form-group:has(.password-toggle) input[type=password],
.form-group:has(.password-toggle) input[type=text] {
  padding-right: 60px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  text-decoration: none;
}

.btn.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn.btn-danger {
  background: #c0392b;
}

.btn.btn-add {
  background: #3f9e6e;
}

.btn.btn-x-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #000;
}

.btn-x-share__icon {
  width: 14px;
  height: 14px;
}

.btn:disabled {
  background: transparent;
  border-color: #ccc;
  color: #999;
  cursor: not-allowed;
}

/* button_toはform(ブロック要素)でボタンを包むため、隣り合うと隙間なく
   接してしまい、同系色だと角丸の継ぎ目だけがおかしく見えてしまう。
   縦に並んだ時にきちんと間隔が空くようにする。 */
form.button_to {
  margin-bottom: 8px;
}

.error-messages {
  background: #fdecea;
  color: #b3261e;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.filter-bar select, .filter-bar input {
  width: auto;
}

.filter-bar .field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-bar .field-group label {
  font-size: 0.75rem;
  color: var(--muted);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.recipe-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}

.recipe-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #eee;
}

.recipe-card .no-image {
  width: 100%;
  height: 140px;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.recipe-card-body {
  padding: 12px;
}

.recipe-card-body h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.recipe-card-body .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 8px 0;
}

.tag-list li, .tag-pill {
  background: #f0e4dc;
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
}

.recipe-header img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
}

.ingredient-fields {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.ingredient-fields .fields-remove {
  color: #c0392b;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.recipe-meta-list {
  display: flex;
  gap: 20px;
  color: var(--muted);
  margin-bottom: 16px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

/* Favorite */
.recipe-card-wrapper {
  position: relative;
}

.favorite-button {
  position: absolute;
  top: 8px;
  right: 8px;
}

.favorite-toggle {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.favorite-toggle .heart-icon {
  font-size: 1.3rem;
  color: var(--border);
}

.favorite-toggle.favorited .heart-icon {
  color: var(--primary);
}

.favorite-toggle.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.recipe-engagement {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

/* Rating */
.average-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stars .star,
.star-select .star {
  color: var(--border);
  font-size: 1.1rem;
}

.stars .star.filled,
.star-select .star.filled {
  color: var(--primary);
}

.rating-form .star-select {
  display: flex;
  gap: 2px;
}

.star-radio {
  cursor: pointer;
}

.star-radio input {
  display: none;
}

/* Comments */
.comments-section {
  margin-top: 32px;
}

.comment {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.comment-meta {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.comment-author {
  font-weight: bold;
  color: var(--text);
}

.comment-body {
  margin: 6px 0;
}

.comment-actions {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
}

.comment-actions .link-edit,
.comment-actions .link-delete {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.comment-form textarea {
  width: 100%;
  min-height: 80px;
}

/* ---- モンスター図鑑 ---- */
.page-lead {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: -8px;
}

.zukan-entry {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff8ef;
  border: 1px solid #e8d3ae;
  border-radius: 14px;
  padding: 16px 20px;
  margin: 16px 0 24px;
  max-width: 420px;
  color: inherit;
  text-decoration: none;
}

.zukan-entry .book-btn {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zukan-entry .book-btn img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 0.18s ease;
  filter: drop-shadow(0 4px 6px rgba(224, 122, 63, 0.18));
}

.zukan-entry:hover .book-btn img {
  transform: translateY(-4px) rotate(-3deg);
}

.zukan-entry .copy {
  display: flex;
  flex-direction: column;
}

.zukan-entry .copy strong {
  font-size: 15px;
  margin-bottom: 2px;
}

.zukan-entry .copy span {
  font-size: 12.5px;
  color: var(--muted);
}

.zukan-counter {
  display: inline-block;
  font-size: 13px;
  font-weight: bold;
  color: #c05f28;
  background: #fcefdb;
  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 22px;
}

.zukan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.mon-tile {
  display: block;
  background: #fff8ef;
  border: 1px solid #e8d3ae;
  border-radius: 14px;
  padding: 14px 10px 12px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: inherit;
  text-decoration: none;
}

.mon-tile.release-tile {
  cursor: pointer;
  position: relative;
}

.mon-tile.release-tile:has(.release-tile__checkbox:checked) {
  border-color: #c0392b;
  background: #fdeceb;
}

.release-tile__checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
}

.mon-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 18px -10px rgba(224, 122, 63, 0.18);
}

.mon-tile .tile-stage {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.mon-tile img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
}

.mon-tile.locked img {
  filter: brightness(0) opacity(0.32);
}

.mon-tile .tile-no {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.mon-tile .tile-name {
  font-size: 13px;
  font-weight: bold;
  margin-top: 2px;
  color: var(--text);
}

.mon-tile.locked .tile-name {
  color: var(--muted);
}

.detail-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.nav-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 20px;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.15);
}

span.nav-btn {
  visibility: hidden;
  box-shadow: none;
  border-color: transparent;
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mon-card {
  width: 100%;
  max-width: 380px;
  background: #fff8ef;
  border: 1px solid #e8d3ae;
  border-radius: 18px;
  padding: 24px 22px 26px;
}

.mon-card .card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.mon-card .no-tag {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: bold;
  color: var(--muted);
  border: 1px solid #e8d3ae;
  border-radius: 999px;
  padding: 3px 9px;
}

.mon-card .type-tag {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 3px 10px;
}

.mon-card .stage {
  position: relative;
  height: 170px;
  margin: 8px 0 12px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mon-card .stage::after {
  content: "";
  position: absolute;
  bottom: 18px;
  left: 50%;
  width: 78px;
  height: 16px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.16) 0%, transparent 72%);
  transform: translateX(-50%);
}

.mon-card .stage img {
  width: 132px;
  height: 132px;
  object-fit: contain;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
  /* 回転アニメーション時に対角線分ふくらむ分の余白を、名前テキストとの間に確保する */
  margin-bottom: 28px;
}

.mon-card.locked .stage img {
  filter: brightness(0) opacity(0.3);
}

.mon-card .name {
  font-size: 21px;
  font-weight: 900;
  text-align: center;
  margin: 0 0 2px;
}

.mon-card.locked .name {
  color: var(--muted);
}

.mon-card .desc {
  font-size: 13.5px;
  line-height: 1.85;
  text-align: center;
  padding-top: 12px;
  border-top: 1px dashed #e8d3ae;
  color: var(--text);
}

.mon-card.locked .desc {
  color: var(--muted);
}

.mon-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}

.mon-stats th,
.mon-stats td {
  padding: 5px 8px;
  border-bottom: 1px dashed #e8d3ae;
  text-align: left;
}

.mon-stats th {
  color: var(--muted);
  white-space: nowrap;
  width: 1%;
}

.mon-stats td {
  color: var(--text);
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary);
}

.anim-bounce {
  animation: monster-bounce 1.9s cubic-bezier(0.36, 0, 0.66, -0.15) infinite;
}
.anim-sway {
  animation: monster-sway 2.6s ease-in-out infinite;
}
.anim-hop {
  animation: monster-hop 2.1s cubic-bezier(0.3, 0, 0.6, 1) infinite;
}
.anim-jiggle {
  animation: monster-jiggle 1.6s ease-in-out infinite;
}
.anim-spinhop {
  animation: monster-spinhop 2.4s ease-in-out infinite;
}
/* .mon-card .stage img の transform-origin:50% 100% より詳細度を上げて上書きする。
   回転を伴うため、足元(下端)ではなく中心を軸にしないと名前テキストにはみ出す。 */
.mon-card .stage img.anim-spinhop {
  transform-origin: 50% 50%;
}
.anim-float {
  animation: monster-floaty 3s ease-in-out infinite;
}

@keyframes monster-bounce {
  0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
  30% { transform: translateY(-34px) scaleX(0.96) scaleY(1.05); }
  50% { transform: translateY(-38px) scaleX(0.94) scaleY(1.08); }
  72% { transform: translateY(0) scaleX(1.08) scaleY(0.9); }
  86% { transform: translateY(-6px) scaleX(1) scaleY(1); }
}
@keyframes monster-sway {
  0%, 100% { transform: rotate(-9deg) translateX(-4px); }
  50% { transform: rotate(9deg) translateX(4px); }
}
@keyframes monster-hop {
  0%, 20%, 100% { transform: translateY(0) rotate(0deg); }
  10% { transform: translateY(-26px) rotate(-6deg); }
  30% { transform: translateY(0) rotate(4deg); }
  50%, 70% { transform: translateY(0) rotate(0deg); }
  60% { transform: translateY(-26px) rotate(6deg); }
  80% { transform: translateY(0) rotate(-4deg); }
}
@keyframes monster-jiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(-5deg) scale(1.02, 0.97); }
  40% { transform: rotate(4deg) scale(0.98, 1.03); }
  60% { transform: rotate(-3deg) scale(1.02, 0.97); }
  80% { transform: rotate(3deg) scale(1); }
}
@keyframes monster-spinhop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-30px) rotate(90deg); }
  50% { transform: translateY(0) rotate(180deg); }
  75% { transform: translateY(-18px) rotate(270deg); }
}
@keyframes monster-floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-16px) rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .stage img,
  .tile-stage img {
    animation: none !important;
  }
}

/* 対戦ミニゲーム(Web版) */
.battle-mode-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.battle-monster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.battle-monster-tile {
  background: #f4f4f4;
  border: 3px solid transparent;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 0.85rem;
}

.battle-monster-tile img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
}

.battle-monster-tile.battle-selected-player {
  border-color: #59bf59;
  background: #eaf7ea;
}

.battle-monster-tile.battle-selected-enemy {
  border-color: #d94033;
  background: #fbeceb;
}

.battle-arena {
  position: relative;
  height: 280px;
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
}

/* 朝 (5〜8時): 暖かい朝焼け→青空→緑の地面 */
.battle-arena--morning {
  background: linear-gradient(to bottom,
    #f9a84d 0%,
    #ffd0a0 25%,
    #87ceeb 50%,
    #6ba8d4 62%,
    #5a9e42 62%,
    #4a8a34 100%
  );
}

/* 昼 (9〜17時): 青空→緑の地面 (元の背景) */
.battle-arena--day {
  background: linear-gradient(to bottom, #8cbfeb 0%, #8cbfeb 62%, #6ba354 62%, #6ba354 100%);
}

/* 夕暮れ (18〜20時): 紫→橙→暗い地面 */
.battle-arena--evening {
  background: linear-gradient(to bottom,
    #1e0a3c 0%,
    #4a1060 20%,
    #8b2252 42%,
    #d4472a 58%,
    #e87a30 63%,
    #1e1030 63%,
    #0e0820 100%
  );
}

/* 夜 (21〜4時): 深い紺→黒い地面 */
.battle-arena--night {
  background: linear-gradient(to bottom,
    #04040f 0%,
    #0a0a2e 30%,
    #12103a 55%,
    #0e0c28 62%,
    #060410 62%,
    #020208 100%
  );
}

.battle-platform {
  position: absolute;
  width: 80px;
  height: 90px;
}

.battle-platform img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
}

.battle-shadow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 14px;
  border-radius: 50%;
  background: rgba(32, 50, 26, 0.45);
}

.battle-platform-player {
  left: 20px;
  bottom: 14px;
  width: 70px;
  height: 80px;
}

.battle-platform-enemy {
  right: 30px;
  bottom: 14px;
  width: 70px;
  height: 80px;
}

/* ボス戦のみ敵を大きく表示 */
.battle-is-boss .battle-platform-enemy {
  width: 115px;
  height: 125px;
}

/* 位置(top/left)はCSSのkeyframesではなく battle_controller.js が攻撃側/防御側の
   プラットフォームの実際の座標から計算してWeb Animations APIで動かす。
   ここでは4種類(炎/氷/衝撃波/光線)の形と模様だけ決めておく。色は
   battle_controller.jsがモンスターのtype_labelごとに--projectile-colorとして
   セットする(炎/氷/衝撃波/光線というカテゴリ内でも、モンスターによって色味を変える)。*/
.battle-projectile {
  position: absolute;
  top: 0;
  left: 0;
  --projectile-color: #cccccc;
}

.battle-projectile-img {
  display: block;
  pointer-events: none;
  transform-origin: center;
}

.battle-projectile--fire .battle-projectile-img,
.battle-projectile--shockwave .battle-projectile-img,
.battle-projectile--wind .battle-projectile-img {
  height: 48px;
  width: auto;
}

.battle-projectile--ice .battle-projectile-img {
  height: 40px;
  width: auto;
}

.battle-projectile--lightning .battle-projectile-img {
  height: 52px;
  width: auto;
}

.battle-projectile--beam .battle-projectile-img {
  height: 28px;
  width: 80px;
  transform: rotate(var(--projectile-angle, 0deg));
}

.battle-hud-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  z-index: 20;
  pointer-events: none;
}

.battle-hud-overlay .battle-hud {
  flex: 1;
  min-width: 0;
}

.battle-hud-overlay .battle-hud p {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battle-hp-bar-wrap {
  position: relative;
}

.battle-hp-bar {
  position: relative;
  background: rgba(0,0,0,0.45);
  border-radius: 6px;
  height: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.25);
}

.battle-hp-bar-fill {
  background: linear-gradient(to right, #2d9e2d, #59bf59);
  height: 100%;
  width: 100%;
  transition: width 0.3s ease-out;
}

.battle-hp-num-inside {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 1px 2px rgba(0,0,0,0.8);
  z-index: 1;
  pointer-events: none;
  white-space: nowrap;
}

.battle-attack-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.battle-attack-choices {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.battle-choice-btn {
  font-size: 13px;
  padding: 4px 10px;
}

.battle-controls-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.battle-weakness-flash {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: bold;
  color: #ff3333;
  text-shadow: 0 0 8px #fff, 0 2px 4px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 20;
}

/* ガチャ結果の演出(Godot版のカプセルが開いてモンスターが飛び出す表現を、
   ポップイン+フェードインの1回きりのアニメーションで再現する) */
.gacha-reveal {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
}

/* 獲得したモンスターが1体だけのときは中央に表示する */
.gacha-reveal:has(.gacha-reveal-item:only-child) {
  justify-content: center;
}

.gacha-reveal-item {
  text-align: center;
  font-size: 0.85rem;
}

.gacha-reveal-item img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
  animation: gacha-reveal-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes gacha-reveal-pop {
  from { transform: scale(0.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ガチャマシンの演出(コインが落ちる→マシンが揺れる) */
.gacha-machine-area {
  position: relative;
  width: 160px;
  height: 190px;
  margin: 12px 0;
}

.gacha-coin-sprite {
  position: absolute;
  width: 28px;
  height: 28px;
  top: 0;
  left: 66px;
  opacity: 0;
}

.gacha-coin-sprite.dropping {
  animation: gacha-coin-drop 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes gacha-coin-drop {
  0% { top: 0; opacity: 1; }
  99% { opacity: 1; }
  100% { top: 130px; opacity: 0; }
}

.gacha-machine-sprite {
  position: absolute;
  top: 30px;
  left: 0;
  width: 160px;
  height: 160px;
  object-fit: contain;
  transform-origin: 50% 100%;
}

.gacha-machine-sprite.shaking {
  animation: gacha-machine-shake 0.4s ease-in-out;
}

@keyframes gacha-machine-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(4deg); }
  40% { transform: rotate(-4deg); }
  60% { transform: rotate(4deg); }
  80% { transform: rotate(-4deg); }
}

.gacha-knob-sprite {
  position: absolute;
  width: 26px;
  height: 26px;
  top: 127px;
  left: 65px;
  opacity: 0;
  z-index: 2;
}

.gacha-knob-sprite.visible {
  opacity: 1;
}

.gacha-capsule-sprite {
  position: absolute;
  width: 28px;
  height: 28px;
  top: 95px;
  left: 64px;
  opacity: 0;
  z-index: 2;
}

.gacha-capsule-sprite.visible {
  opacity: 1;
}

.gacha-capsule-sprite.dropped {
  animation: gacha-capsule-drop 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes gacha-capsule-drop {
  0% { top: 95px; }
  100% { top: 145px; }
}

.gacha-capsule-sprite.opened {
  animation: gacha-capsule-open-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes gacha-capsule-open-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ガチャマシンのドーム内カプセルは、レバーを回している間だけくるくる回る */
.gacha-dome-swirl {
  position: absolute;
  top: 50px;
  left: 48px;
  width: 64px;
  height: 64px;
}

.gacha-dome-swirl.spinning {
  animation: gacha-dome-spin 0.6s linear;
}

@keyframes gacha-dome-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.gacha-dome-capsule {
  position: absolute;
  width: 12px;
  height: 12px;
  top: 50%;
  left: 50%;
  margin: -6px 0 0 -6px;
}

.gacha-dome-capsule--1 { transform: rotate(0deg) translate(22px) rotate(0deg); }
.gacha-dome-capsule--2 { transform: rotate(60deg) translate(22px) rotate(-60deg); }
.gacha-dome-capsule--3 { transform: rotate(120deg) translate(22px) rotate(-120deg); }
.gacha-dome-capsule--4 { transform: rotate(180deg) translate(22px) rotate(-180deg); }
.gacha-dome-capsule--5 { transform: rotate(240deg) translate(22px) rotate(-240deg); }
.gacha-dome-capsule--6 { transform: rotate(300deg) translate(22px) rotate(-300deg); }

.gacha-result-text {
  min-height: 1.2em;
}

/* ---- ユーザーアイコン(アップロード画像) ---- */
.avatar-icon {
  vertical-align: middle;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-icon--small {
  width: 24px;
  height: 24px;
  margin-right: 4px;
}

.avatar-icon--medium {
  width: 64px;
  height: 64px;
  display: block;
  margin-bottom: 8px;
}

.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: bold;
  vertical-align: middle;
}

.avatar-placeholder--small {
  width: 24px;
  height: 24px;
  margin-right: 4px;
  font-size: 0.75em;
}

.avatar-placeholder--medium {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  font-size: 1.5em;
}

/* ── Contribution Graph ─────────────────────────────────────── */

.contribution-graph-section {
  margin-bottom: 32px;
}

.cg-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cg-day-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 40px;
  flex-shrink: 0;
}

.cg-year-spacer {
  height: 18px;
  display: block;
}

.cg-day-labels span {
  height: 12px;
  line-height: 12px;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  width: 14px;
}

.cg-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cg-year-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  margin-bottom: 2px;
}

.cg-year-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text);
  min-width: 56px;
  text-align: center;
}

.cg-year-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
}

.cg-year-btn:hover:not(:disabled) {
  color: var(--text);
}

.cg-year-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cg-month-labels {
  position: relative;
  height: 18px;
  flex-shrink: 0;
}

.cg-month-labels span {
  position: absolute;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  line-height: 18px;
}

.cg-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-columns: 12px;
  grid-auto-flow: column;
  gap: 2px;
}

.cg-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: default;
}

.cg-cell--empty   { background: transparent; }
.cg-cell--future  { background: #ebedf0; opacity: 0.4; }
.cg-cell--level-0 { background: #ebedf0; }
.cg-cell--level-1 { background: #9be9a8; }
.cg-cell--level-2 { background: #40c463; }
.cg-cell--level-3 { background: #30a14e; }
.cg-cell--level-4 { background: #216e39; }

.cg-cell:not(.cg-cell--empty):hover {
  outline: 1px solid rgba(0, 0, 0, 0.25);
  outline-offset: 1px;
}

.cg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
}

.cg-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.cg-legend-key {
  margin-right: 2px;
}

.cg-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.cg-legend-cell {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.cg-total {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.cg-total strong {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
}

.cg-tooltip {
  position: fixed;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

/* ── Battle Ambient Animations ──────────────────────────────── */

.battle-bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.battle-cloud {
  position: absolute;
  left: 0;
  height: 28px;
  width: auto;
  opacity: 0.9;
  animation: battle-cloud-drift linear infinite;
}
.battle-cloud--1 { animation-duration: 18s; top:  8px; animation-delay:    0s; }
.battle-cloud--2 { animation-duration: 26s; top: 22px; animation-delay:   -8s; }
.battle-cloud--3 { animation-duration: 34s; top:  4px; animation-delay: -15s; }

@keyframes battle-cloud-drift {
  from { transform: translateX(800px); }
  to   { transform: translateX(-200px); }
}

.battle-ground-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  pointer-events: none;
}

.battle-grass-tuft {
  position: absolute;
  bottom: 0;
  width: 32px;
  height: 32px;
}
.battle-grass-tuft--1 { left:  60px; }
.battle-grass-tuft--2 { left: 130px; }
.battle-grass-tuft--3 { left: 210px; }
.battle-grass-tuft--4 { left: 310px; }
.battle-grass-tuft--5 { left: 400px; }

.grass-frame {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 32px;
  height: auto;
}
.grass-frame--a { animation: battle-grass-a 0.8s steps(1) infinite; }
.grass-frame--b { animation: battle-grass-b 0.8s steps(1) infinite; }
.battle-grass-tuft--2 .grass-frame--a,
.battle-grass-tuft--2 .grass-frame--b { animation-delay: -0.2s; }
.battle-grass-tuft--3 .grass-frame--a,
.battle-grass-tuft--3 .grass-frame--b { animation-delay: -0.4s; }
.battle-grass-tuft--4 .grass-frame--a,
.battle-grass-tuft--4 .grass-frame--b { animation-delay: -0.6s; }
.battle-grass-tuft--5 .grass-frame--a,
.battle-grass-tuft--5 .grass-frame--b { animation-delay: -0.1s; }

@keyframes battle-grass-a {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes battle-grass-b {
  0%, 49% { opacity: 0; }
  50%, 100% { opacity: 1; }
}

.battle-flower {
  position: absolute;
  bottom: 2px;
  height: 24px;
  width: auto;
}
.battle-flower--1 { left: 180px; }
.battle-flower--2 { left: 360px; }

@media (prefers-reduced-motion: reduce) {
  .battle-cloud,
  .grass-frame--a,
  .grass-frame--b {
    animation: none;
  }
  .grass-frame--b { opacity: 0; }
}

/* ---- House Section ---- */
.house-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #fff8f0;
  border: 1px solid #f0d9b5;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.house-image-wrap {
  flex-shrink: 0;
}

.house-img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

.house-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.house-name {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}

.house-streak {
  margin: 0;
  color: #555;
}

.house-next {
  margin: 0;
  font-size: 0.9rem;
  color: #888;
}

.house-next--max {
  color: #e07a3f;
  font-weight: bold;
}

.house-freeze {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.freeze-icon {
  font-size: 1.1rem;
}

.freeze-icon--empty {
  opacity: 0.2;
}

.freeze-label {
  font-size: 0.8rem;
  color: #888;
  margin-left: 0.25rem;
}

@media (max-width: 480px) {
  .house-section {
    flex-direction: column;
    align-items: flex-start;
  }
}
