:root {
  color-scheme: dark;
  --bg: #171616;
  --panel: #242120;
  --panel-soft: #302b28;
  --ink: #f7efe4;
  --muted: #c9b9a7;
  --line: rgba(247, 239, 228, 0.16);
  --back-a: #1f4140;
  --back-b: #2a766d;
  --known: #dff8fb;
  --known-ink: #173134;
  --known-line: #80d7e3;
  --card-white: #fff9ed;
  --card-white-line: #d8b86c;
  --selected: #ffcf5a;
  --solved: #8f8b82;
  --solved-dark: #5f5b55;
  --danger: #e86b5e;
  --good: #74d6a5;
  --heart: #c33e4b;
  --spade: #23201e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 184, 108, 0.11), transparent 34rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 18px),
    var(--bg);
  color: var(--ink);
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    system-ui,
    sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 440px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 8px;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding-top: 4px;
}

.brand-block {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.brand-line {
  min-width: 0;
  display: flex;
  align-items: center;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 5.4vw, 29px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  font-weight: 950;
  white-space: nowrap;
}

.top-meta-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-pill {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 4px 8px 3px;
  border: 1px solid rgba(247, 239, 228, 0.18);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(36, 33, 32, 0.64);
  color: var(--muted);
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.life-hearts {
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 1px;
  padding-left: 1px;
  line-height: 1;
}

.life-heart {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 17px;
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35));
}

.life-heart.is-filled {
  color: #ff7676;
  text-shadow: 0 0 12px rgba(255, 118, 118, 0.34);
}

.life-heart.is-empty {
  color: rgba(247, 239, 228, 0.34);
  text-shadow: none;
}

.life-heart.is-group-start {
  margin-left: 6px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(247, 239, 228, 0.18);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(36, 33, 32, 0.62);
  color: var(--ink);
  font-size: 23px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

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

.upgrade-strip {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.upgrade-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.upgrade-chip {
  min-width: 0;
  min-height: 34px;
  padding: 6px 5px;
  border: 1px solid rgba(128, 215, 227, 0.22);
  border-radius: 999px;
  background: rgba(31, 65, 64, 0.38);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.upgrade-chip:hover,
.upgrade-chip:focus-visible {
  border-color: rgba(255, 207, 90, 0.65);
  background: rgba(48, 43, 40, 0.88);
  outline: none;
}

.upgrade-chip:active {
  transform: translateY(1px);
}

.upgrade-chip span {
  display: block;
}

.upgrade-chip-title {
  font-size: 10px;
  font-weight: 900;
  line-height: 1.05;
}

.upgrade-chip-detail {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.compact-upgrade-chip {
  min-height: 34px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.compact-upgrade-chip:nth-child(1) {
  border-color: rgba(255, 207, 90, 0.32);
}

.compact-upgrade-chip:nth-child(2) {
  border-color: rgba(87, 221, 213, 0.28);
}

.compact-upgrade-chip:nth-child(3) {
  border-color: rgba(205, 145, 255, 0.28);
}

.compact-upgrade-chip:nth-child(4) {
  border-color: rgba(255, 249, 237, 0.28);
}


.relic-list {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 7px;
  min-height: 34px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 1px 2px 3px;
  scrollbar-width: none;
}

.relic-list[hidden] {
  display: none;
}

.relic-list::-webkit-scrollbar {
  display: none;
}

.relic-chip {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(247, 239, 228, 0.2);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(247, 239, 228, 0.08);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.relic-chip:focus-visible,
.relic-chip:hover {
  border-color: rgba(255, 207, 90, 0.72);
  outline: none;
}


.relic-chip.relic-active {
  animation: relic-soft-glow 560ms ease-out both;
}

@keyframes relic-soft-glow {
  0% {
    transform: scale(1);
    background: rgba(247, 239, 228, 0.08);
    box-shadow: 0 0 0 rgba(255, 207, 90, 0);
  }

  45% {
    transform: scale(1.08);
    background: rgba(255, 249, 237, 0.24);
    box-shadow:
      0 0 0 3px rgba(255, 207, 90, 0.18),
      0 0 18px rgba(255, 207, 90, 0.36);
  }

  100% {
    transform: scale(1);
    background: rgba(247, 239, 228, 0.08);
    box-shadow: 0 0 0 rgba(255, 207, 90, 0);
  }
}

.reward-relic.rarity-common,
.relic-chip.rarity-common {
  border-color: rgba(128, 215, 227, 0.48);
}

.reward-relic.rarity-rare,
.relic-chip.rarity-rare {
  border-color: rgba(116, 214, 165, 0.58);
  background: rgba(116, 214, 165, 0.12);
}

.reward-relic.rarity-legend,
.relic-chip.rarity-legend {
  border-color: rgba(255, 207, 90, 0.78);
  background: rgba(255, 207, 90, 0.12);
  box-shadow: 0 0 20px rgba(255, 207, 90, 0.14);
}

.message-panel {
  height: 54px;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 33, 32, 0.74);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.32;
  white-space: pre-line;
  overflow: hidden;
}

.message-panel.win {
  border-color: rgba(116, 214, 165, 0.7);
}

.message-panel.lose {
  border-color: rgba(232, 107, 94, 0.75);
}

.reward-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  background: rgba(8, 9, 9, 0.68);
  backdrop-filter: blur(3px);
}

.reward-overlay[hidden] {
  display: none;
}

.reward-panel {
  width: min(100%, 620px);
  padding: 16px;
  border: 1px solid rgba(255, 207, 90, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(48, 43, 40, 0.98), rgba(36, 33, 32, 0.98)),
    var(--panel);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
}

.reward-kicker {
  margin: 0 0 3px;
  color: var(--selected);
  font-size: 11px;
  font-weight: 900;
}

.reward-panel h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.reward-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.reward-choices.is-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.reward-choice {
  width: 100%;
  min-height: 158px;
  border: 1px solid rgba(255, 207, 90, 0.28);
  border-radius: 8px;
  padding: 12px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 34%),
    rgba(247, 239, 228, 0.08);
  color: var(--ink);
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.reward-choice:hover,
.reward-choice:focus-visible {
  border-color: rgba(255, 207, 90, 0.75);
  outline: none;
}

.reward-choice:active {
  transform: translateY(1px);
}

.reward-title {
  display: block;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
}

.reward-rarity {
  display: inline-grid;
  place-items: center;
  min-height: 20px;
  margin-top: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--ink);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
}

.reward-rarity-upgrade {
  color: var(--selected);
}

.reward-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reward-plus {
  color: var(--selected);
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
}

.board {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(var(--board-rows, 4), minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 9px);
  justify-self: center;
  width: min(100%, max(var(--board-min, 0px), calc((100svh - 300px) * 4 / var(--board-rows, 4))));
  aspect-ratio: 4 / var(--board-rows, 4);
  min-height: 0;
  padding: 2px 0 0;
}

.card {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.25);
  container-type: inline-size;
}

.card-inner {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
  border-radius: inherit;
}

.card.back .card-inner {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13) 0 1px, transparent 1px 12px),
    radial-gradient(circle at 50% 50%, rgba(255, 207, 90, 0.2), transparent 33%),
    linear-gradient(150deg, var(--back-b), var(--back-a));
}

.card.back .card-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(38px, 44%);
  aspect-ratio: 1;
  border: 1px solid rgba(247, 239, 228, 0.38);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(247, 239, 228, 0.82);
  font-size: clamp(15px, 5cqw, 23px);
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.card.known .card-inner {
  border: 2px solid var(--known-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent 36%),
    var(--known);
  color: var(--known-ink);
}

.card.known.known-rank .card-inner {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent 36%),
    linear-gradient(180deg, #dff8fb, #d2eef4);
}

.card.known.known-suit .card-inner {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), transparent 36%),
    linear-gradient(180deg, #e5f7ef, #d4eee1);
}

.card.selected .card-inner {
  border: 2px solid var(--card-white-line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), transparent 38%),
    var(--card-white);
  color: var(--known-ink);
}

.card.selected {
  z-index: 2;
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px rgba(255, 207, 90, 0.42),
    0 15px 24px rgba(0, 0, 0, 0.36);
}

.card.solved .card-inner {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 14px),
    linear-gradient(180deg, var(--solved), var(--solved-dark));
  color: #eeece5;
  filter: grayscale(0.35);
}

.card.solved::after {
  content: "";
  position: absolute;
  inset: clamp(4px, 8%, 7px);
  border: 1px solid rgba(247, 239, 228, 0.28);
  border-radius: 6px;
  pointer-events: none;
}

.card.solved::before {
  content: "✓";
  position: absolute;
  right: clamp(4px, 8%, 7px);
  bottom: clamp(3px, 6%, 6px);
  z-index: 3;
  color: rgba(255, 249, 237, 0.9);
  font-size: clamp(10px, 13cqw, 15px);
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}



.card.card-relic-glow {
  animation: card-relic-soft-glow 420ms ease-out both;
}

.card.card-source-glow {
  animation: card-source-soft-glow 420ms ease-out both;
}

@keyframes card-relic-soft-glow {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 9px 18px rgba(0, 0, 0, 0.25);
  }

  48% {
    transform: translateY(-1px) scale(1.025);
    box-shadow:
      0 0 0 3px rgba(255, 207, 90, 0.36),
      0 0 22px rgba(255, 207, 90, 0.38),
      0 11px 20px rgba(0, 0, 0, 0.24);
  }

  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 9px 18px rgba(0, 0, 0, 0.25);
  }
}

@keyframes card-source-soft-glow {
  0% {
    box-shadow: 0 9px 18px rgba(0, 0, 0, 0.25);
  }

  48% {
    box-shadow:
      0 0 0 3px rgba(128, 215, 227, 0.36),
      0 0 20px rgba(128, 215, 227, 0.34),
      0 9px 18px rgba(0, 0, 0, 0.25);
  }

  100% {
    box-shadow: 0 9px 18px rgba(0, 0, 0, 0.25);
  }
}

.card.pair-ready {
  box-shadow:
    0 0 0 2px rgba(255, 207, 90, 0.38),
    0 0 18px rgba(255, 207, 90, 0.34),
    0 9px 18px rgba(0, 0, 0, 0.25);
}

.card.pair-ready .card-inner {
  border-color: rgba(255, 207, 90, 0.92);
}

.card[disabled] {
  cursor: default;
}

.card-rank {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 76%;
  min-width: 0;
  min-height: 0;
  font-size: clamp(17px, 33cqw, 30px);
  font-weight: 950;
  line-height: 0.9;
  transform: translate(-50%, -50%);
}

.card-suit {
  position: absolute;
  left: 50%;
  bottom: clamp(5px, 9%, 9px);
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  font-size: clamp(12px, 21cqw, 21px);
  line-height: 0.95;
  transform: translateX(-50%);
}

.card-rank.is-hidden-line,
.card-suit.is-hidden-line {
  width: 48%;
  height: clamp(4px, 8cqw, 7px);
  border-radius: 99px;
  background: rgba(23, 49, 52, 0.24);
  color: transparent;
}

.card-suit.is-hidden-line {
  width: 36%;
}

.card-top {
  position: absolute;
  inset: 0;
  z-index: 3;
  min-height: 0;
  pointer-events: none;
}

.red-suit {
  color: var(--heart);
}

.black-suit {
  color: var(--spade);
}


.ability-badge,
.direction-badge {
  position: absolute;
  top: clamp(4px, 7%, 7px);
  right: clamp(4px, 7%, 7px);
  min-width: clamp(17px, 25cqw, 24px);
  height: clamp(15px, 20cqw, 20px);
  padding: 0 clamp(3px, 5cqw, 5px);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #2b2219;
  background: var(--selected);
  font-size: clamp(8px, 13cqw, 11px);
  font-weight: 900;
  line-height: 1;
}

.direction-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 0;
  transform: rotate(var(--arrow-angle, 0deg));
  transform-origin: center;
}

.direction-overlay::before {
  content: "";
  width: clamp(9px, 15cqw, 18px);
  height: clamp(36px, 58cqw, 72px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 244, 190, 0.18), rgba(255, 148, 201, 0.5));
  box-shadow:
    0 0 12px rgba(255, 148, 201, 0.22),
    0 0 24px rgba(255, 112, 181, 0.2);
}

.direction-overlay::after {
  content: "";
  position: absolute;
  top: clamp(6px, 10cqw, 12px);
  width: clamp(24px, 39cqw, 42px);
  height: clamp(24px, 39cqw, 42px);
  border-top: clamp(8px, 14cqw, 14px) solid rgba(255, 244, 190, 0.45);
  border-left: clamp(8px, 14cqw, 14px) solid rgba(255, 244, 190, 0.45);
  transform: rotate(45deg);
  filter: drop-shadow(0 0 10px rgba(255, 112, 181, 0.25));
}


.direction-range {
  position: absolute;
  left: 50%;
  top: clamp(4px, 7%, 7px);
  z-index: 2;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 249, 237, 0.86);
  color: #2b2219;
  font-size: clamp(8px, 11cqw, 10px);
  font-weight: 950;
  line-height: 1.2;
  white-space: nowrap;
}


@media (max-height: 690px) {
  .app-shell {
    gap: 8px;
  }

  h1 {
    font-size: 28px;
  }

  .message-panel {
    height: 46px;
    min-height: 46px;
    padding-block: 7px;
    font-size: 12px;
  }

  .board {
    gap: 7px;
  }

}

@media (max-width: 560px) {
  .reward-choices.is-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .reward-panel {
    padding: 13px;
  }

  .reward-choices {
    gap: 6px;
  }

  .reward-choices.is-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reward-choice {
    min-height: 132px;
    padding: 10px 6px;
  }

  .reward-title {
    font-size: 13px;
  }

  .reward-detail {
    font-size: 11px;
  }
}

/* --- Balance / clarity update --- */
.message-panel {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-dolphin {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(128, 215, 227, 0.28);
  border-radius: 999px;
  background: rgba(128, 215, 227, 0.1);
  line-height: 1;
  overflow: hidden;
}

.message-dolphin-svg {
  width: 24px;
  height: 24px;
  display: block;
}

.dolphin-body {
  fill: rgba(134, 223, 238, 0.96);
}

.dolphin-fin,
.dolphin-tail {
  fill: rgba(89, 181, 205, 0.96);
}

.dolphin-eye {
  fill: #173134;
}

.message-text {
  min-width: 0;
  white-space: pre-line;
}

.card.pair-ready {
  animation: pair-ready-breathe 1450ms ease-in-out infinite;
}

.card.pair-ready .card-inner {
  border-color: rgba(255, 207, 90, 0.96);
}

@keyframes pair-ready-breathe {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow:
      0 0 0 2px rgba(255, 207, 90, 0.28),
      0 0 12px rgba(255, 207, 90, 0.22),
      0 9px 18px rgba(0, 0, 0, 0.25);
  }
  50% {
    transform: translateY(-1px) scale(1.018);
    box-shadow:
      0 0 0 3px rgba(255, 207, 90, 0.55),
      0 0 28px rgba(255, 207, 90, 0.52),
      0 12px 22px rgba(0, 0, 0, 0.3);
  }
}

.card.card-ability-source-glow {
  animation: ability-source-glow 520ms ease-out both;
}

.card.card-relic-glow.ability-effect-a,
.card.card-ability-source-glow.ability-effect-a {
  --ability-glow: rgba(255, 184, 66, 0.66);
  --ability-ring: rgba(255, 207, 90, 0.52);
}

.card.card-relic-glow.ability-effect-j,
.card.card-ability-source-glow.ability-effect-j {
  --ability-glow: rgba(69, 221, 218, 0.6);
  --ability-ring: rgba(128, 215, 227, 0.56);
}

.card.card-relic-glow.ability-effect-q,
.card.card-ability-source-glow.ability-effect-q {
  --ability-glow: rgba(213, 108, 255, 0.58);
  --ability-ring: rgba(255, 148, 236, 0.5);
}

.card.card-relic-glow.ability-effect-k,
.card.card-ability-source-glow.ability-effect-k {
  --ability-glow: rgba(255, 249, 237, 0.7);
  --ability-ring: rgba(255, 223, 150, 0.58);
}

.card.card-relic-glow.ability-effect-a,
.card.card-relic-glow.ability-effect-j,
.card.card-relic-glow.ability-effect-q,
.card.card-relic-glow.ability-effect-k {
  animation: ability-target-glow 700ms ease-out both;
}

@keyframes ability-source-glow {
  0% { transform: translateY(0) scale(1); }
  50% {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
      0 0 0 4px var(--ability-ring, rgba(255, 207, 90, 0.42)),
      0 0 30px var(--ability-glow, rgba(255, 207, 90, 0.36)),
      0 15px 24px rgba(0, 0, 0, 0.34);
  }
  100% { transform: translateY(0) scale(1); }
}

@keyframes ability-target-glow {
  0% { transform: translateY(0) scale(1); }
  45% {
    transform: translateY(-1px) scale(1.035);
    box-shadow:
      0 0 0 4px var(--ability-ring, rgba(255, 207, 90, 0.38)),
      0 0 28px var(--ability-glow, rgba(255, 207, 90, 0.34)),
      0 11px 20px rgba(0, 0, 0, 0.24);
  }
  100% { transform: translateY(0) scale(1); }
}

.card.rank-reveal-glow .card-rank,
.card.suit-reveal-glow .card-suit {
  animation: info-slot-pop 760ms ease-out both;
}

.card.rank-reveal-glow.ability-effect-q .card-rank {
  --slot-glow: rgba(213, 108, 255, 0.82);
}

.card.suit-reveal-glow.ability-effect-j .card-suit {
  --slot-glow: rgba(69, 221, 218, 0.86);
}

.card.rank-reveal-glow.ability-effect-k .card-rank,
.card.suit-reveal-glow.ability-effect-k .card-suit {
  --slot-glow: rgba(255, 223, 150, 0.86);
}

@keyframes info-slot-pop {
  0% { filter: drop-shadow(0 0 0 transparent); transform: translate(-50%, -50%) scale(1); }
  42% { filter: drop-shadow(0 0 10px var(--slot-glow, rgba(255, 207, 90, 0.75))); transform: translate(-50%, -50%) scale(1.18); }
  100% { filter: drop-shadow(0 0 0 transparent); transform: translate(-50%, -50%) scale(1); }
}

.card.suit-reveal-glow .card-suit {
  transform: translateX(-50%);
}

.card.suit-reveal-glow .card-suit {
  animation-name: suit-slot-pop;
}

@keyframes suit-slot-pop {
  0% { filter: drop-shadow(0 0 0 transparent); transform: translateX(-50%) scale(1); }
  42% { filter: drop-shadow(0 0 10px var(--slot-glow, rgba(255, 207, 90, 0.75))); transform: translateX(-50%) scale(1.22); }
  100% { filter: drop-shadow(0 0 0 transparent); transform: translateX(-50%) scale(1); }
}

.upgrade-chip.reward-boost,
.relic-chip.reward-boost {
  animation: reward-confirm-glow 1000ms ease-out both;
}

@keyframes reward-confirm-glow {
  0% { transform: scale(1); }
  45% {
    transform: scale(1.08);
    border-color: rgba(255, 207, 90, 0.95);
    box-shadow:
      0 0 0 3px rgba(255, 207, 90, 0.22),
      0 0 24px rgba(255, 207, 90, 0.45);
  }
  100% { transform: scale(1); }
}

/* --- Cute floating dolphin guide update --- */
.message-panel {
  overflow: visible;
}

.message-dolphin {
  position: relative;
  width: 36px;
  height: 36px;
  border-color: rgba(128, 215, 227, 0.42);
  background:
    radial-gradient(circle at 42% 30%, rgba(255, 255, 255, 0.32), transparent 30%),
    rgba(128, 215, 227, 0.13);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 6px 14px rgba(0, 0, 0, 0.18),
    0 0 16px rgba(128, 215, 227, 0.12);
  overflow: visible;
  animation: dolphin-bob 2.8s ease-in-out infinite;
}

.message-dolphin::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 1px solid rgba(128, 215, 227, 0.15);
  opacity: 0.75;
  animation: dolphin-ring 2.8s ease-in-out infinite;
  pointer-events: none;
}

.message-dolphin-svg {
  width: 31px;
  height: 31px;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.22));
}

.dolphin-float-body {
  transform-origin: 32px 34px;
  animation: dolphin-swim 2.8s ease-in-out infinite;
}

.dolphin-shadow {
  fill: rgba(0, 0, 0, 0.18);
  animation: dolphin-shadow-pulse 2.8s ease-in-out infinite;
}

.dolphin-body,
.dolphin-nose {
  fill: #82def0;
}

.dolphin-belly {
  fill: #dffbff;
  opacity: 0.92;
}

.dolphin-fin,
.dolphin-tail {
  fill: #49abc5;
}

.dolphin-eye {
  fill: #10252a;
}

.dolphin-smile {
  fill: none;
  stroke: #10252a;
  stroke-width: 1.8;
  stroke-linecap: round;
  opacity: 0.72;
}

.dolphin-cheek {
  fill: rgba(255, 164, 188, 0.72);
}

.dolphin-bubble {
  fill: rgba(223, 251, 255, 0.9);
  stroke: rgba(130, 222, 240, 0.42);
  stroke-width: 1;
}

.dolphin-bubble-one {
  animation: dolphin-bubble-rise 2.8s ease-in-out infinite;
}

.dolphin-bubble-two {
  animation: dolphin-bubble-rise 2.8s ease-in-out infinite 0.35s;
}

@keyframes dolphin-bob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes dolphin-swim {
  0%, 100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-2px) rotate(3deg);
  }
}

@keyframes dolphin-ring {
  0%, 100% {
    transform: scale(0.96);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.82;
  }
}

@keyframes dolphin-shadow-pulse {
  0%, 100% {
    transform: scaleX(1);
    opacity: 0.18;
  }
  50% {
    transform: scaleX(0.78);
    opacity: 0.1;
  }
}

@keyframes dolphin-bubble-rise {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.48;
  }
  50% {
    transform: translateY(-3px);
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  .message-dolphin,
  .message-dolphin::after,
  .dolphin-float-body,
  .dolphin-shadow,
  .dolphin-bubble-one,
  .dolphin-bubble-two {
    animation: none;
  }
}

/* --- iPhone-safe dolphin / direction arrow update --- */
.message-panel {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-height: 62px;
  height: auto;
  overflow: visible;
}

.message-dolphin {
  flex: 0 0 42px !important;
  width: 42px !important;
  height: 42px !important;
  display: grid !important;
  place-items: center !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateZ(0);
  z-index: 1;
}

.message-dolphin-svg {
  width: 36px !important;
  height: 36px !important;
  display: block !important;
}

.message-text {
  flex: 1 1 auto;
  min-width: 0;
}

.direction-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
  transform: rotate(var(--arrow-angle, 0deg));
  transform-origin: center;
}

.direction-overlay::before,
.direction-overlay::after {
  content: none !important;
  display: none !important;
}

.direction-arrow-svg {
  width: clamp(44px, 72cqw, 86px);
  height: clamp(44px, 72cqw, 86px);
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(255, 207, 90, 0.72));
}

.direction-arrow-glow,
.direction-arrow-stem,
.direction-arrow-head {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.direction-arrow-glow {
  stroke: rgba(255, 207, 90, 0.28);
  stroke-width: 20;
}

.direction-arrow-stem,
.direction-arrow-head {
  stroke: rgba(255, 244, 190, 0.92);
  stroke-width: 12;
}

@media (max-width: 420px) {
  .message-panel {
    min-height: 58px;
  }

  .message-dolphin {
    flex-basis: 38px !important;
    width: 38px !important;
    height: 38px !important;
  }

  .message-dolphin-svg {
    width: 33px !important;
    height: 33px !important;
  }
}

/* --- Pixel dolphin guide / selectable-card cancel update --- */
.message-dolphin {
  flex: 0 0 52px !important;
  width: 52px !important;
  height: 52px !important;
  display: grid !important;
  place-items: center !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  animation: dolphin-pixel-float 3.2s ease-in-out infinite !important;
}

.message-dolphin::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  filter: blur(2px);
  animation: dolphin-pixel-shadow 3.2s ease-in-out infinite;
}

.message-dolphin-img {
  width: 52px !important;
  height: 52px !important;
  display: block !important;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.22)) drop-shadow(0 0 10px rgba(152, 198, 255, 0.22));
  animation: dolphin-pixel-sway 3.2s ease-in-out infinite;
  transform-origin: 50% 60%;
}

@keyframes dolphin-pixel-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes dolphin-pixel-sway {
  0%, 100% { transform: rotate(-2deg) translateX(0); }
  50% { transform: rotate(2deg) translateX(1px); }
}

@keyframes dolphin-pixel-shadow {
  0%, 100% { opacity: 0.26; transform: scaleX(1); }
  50% { opacity: 0.15; transform: scaleX(0.74); }
}

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

/* v9: keep relic icons visually centered in their square chips. */
.relic-chip {
  padding: 0;
  text-align: center;
  align-items: center;
  justify-items: center;
}

.relic-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-align: center;
  transform: translateX(-0.5px);
}

/* 方位磁針: Aの矢印だけ、近さに応じて長さを変える。 */
.direction-overlay.direction-range-near .direction-arrow-svg {
  transform: scale(0.78);
}

.direction-overlay.direction-range-mid .direction-arrow-svg {
  transform: scale(1);
}

.direction-overlay.direction-range-far .direction-arrow-svg {
  transform: scale(1.24);
}


/* v10: guide cursor mascot and hint relic */
.message-guide-cursor {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: visible;
  animation: guide-cursor-float 5.8s cubic-bezier(0.42, 0, 0.28, 1) infinite;
}

.message-guide-cursor.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.message-guide-cursor::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: -1px;
  height: 4px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.24);
  filter: blur(2px);
  animation: guide-cursor-shadow 5.8s cubic-bezier(0.42, 0, 0.28, 1) infinite;
  pointer-events: none;
}

.message-guide-cursor-img {
  width: 31px;
  height: 31px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter:
    drop-shadow(0 3px 0 rgba(0, 0, 0, 0.25))
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.12));
  animation: guide-cursor-sway 4.7s ease-in-out infinite;
  transform-origin: 30% 15%;
}

@keyframes guide-cursor-float {
  0% { transform: translate3d(0, 0, 0); }
  18% { transform: translate3d(1px, -2px, 0); }
  37% { transform: translate3d(-1px, -5px, 0); }
  56% { transform: translate3d(2px, -3px, 0); }
  74% { transform: translate3d(-1px, -1px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@keyframes guide-cursor-shadow {
  0% { transform: scaleX(1); opacity: 0.52; }
  22% { transform: scaleX(0.9); opacity: 0.42; }
  43% { transform: scaleX(0.72); opacity: 0.28; }
  61% { transform: scaleX(0.82); opacity: 0.36; }
  82% { transform: scaleX(0.96); opacity: 0.48; }
  100% { transform: scaleX(1); opacity: 0.52; }
}

@keyframes guide-cursor-sway {
  0% { transform: rotate(-3deg) scale(1); }
  16% { transform: rotate(-1deg) scale(1.02); }
  31% { transform: rotate(2deg) scale(0.99); }
  49% { transform: rotate(0deg) scale(1.03); }
  67% { transform: rotate(3deg) scale(1); }
  84% { transform: rotate(-1deg) scale(1.02); }
  100% { transform: rotate(-3deg) scale(1); }
}

.card.guide-cursor-target {
  z-index: 5;
}

.guide-cursor-tap {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 12;
  width: clamp(34px, 44cqw, 52px);
  height: clamp(34px, 44cqw, 52px);
  pointer-events: none;
  transform: translate(-18%, -58%);
  animation: guide-cursor-card-tap 3.8s ease-in-out both;
}

.guide-cursor-tap-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter:
    drop-shadow(0 4px 0 rgba(0, 0, 0, 0.28))
    drop-shadow(0 0 12px rgba(255, 255, 255, 0.22));
}

.guide-cursor-tap::after {
  content: "";
  position: absolute;
  left: 17%;
  top: 9%;
  width: 24%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 207, 90, 0.78);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  animation: guide-cursor-tap-ripple 3.8s ease-out both;
}

@keyframes guide-cursor-card-tap {
  0% {
    opacity: 0;
    transform: translate(-18%, -104%) scale(0.9);
  }
  14% {
    opacity: 1;
    transform: translate(-18%, -72%) scale(0.98);
  }
  27% {
    opacity: 1;
    transform: translate(-18%, -58%) scale(1);
  }
  39% {
    transform: translate(-18%, -42%) scale(0.95);
  }
  51% {
    transform: translate(-18%, -58%) scale(1);
  }
  63% {
    transform: translate(-18%, -42%) scale(0.95);
  }
  75% {
    transform: translate(-18%, -58%) scale(1);
  }
  88% {
    opacity: 1;
    transform: translate(-18%, -58%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-18%, -96%) scale(0.94);
  }
}

@keyframes guide-cursor-tap-ripple {
  0%, 33% {
    opacity: 0;
    transform: scale(0.4);
  }
  39% {
    opacity: 0.95;
    transform: scale(0.55);
  }
  50% {
    opacity: 0;
    transform: scale(1.75);
  }
  57% {
    opacity: 0;
    transform: scale(0.4);
  }
  63% {
    opacity: 0.95;
    transform: scale(0.55);
  }
  76% {
    opacity: 0;
    transform: scale(1.75);
  }
  100% {
    opacity: 0;
    transform: scale(1.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  .message-guide-cursor,
  .message-guide-cursor::after,
  .message-guide-cursor-img,
  .guide-cursor-tap,
  .guide-cursor-tap::after {
    animation: none !important;
  }
}


@media (max-width: 360px) {
  h1 {
    font-size: clamp(20px, 7.4vw, 25px);
    letter-spacing: 0.01em;
  }

  .top-meta-row {
    gap: 7px;
  }

  .stage-pill {
    padding-inline: 7px;
    font-size: 8.5px;
  }

  .life-heart {
    width: 13px;
    height: 15px;
    font-size: 13px;
  }
}


/* v15: richer idle cursor motion + separate pair-ready color from selected yellow */
.card.pair-ready {
  animation: pair-ready-breathe-mint 1550ms ease-in-out infinite;
  box-shadow:
    0 0 0 2px rgba(116, 255, 207, 0.36),
    0 0 20px rgba(116, 255, 207, 0.30),
    0 9px 18px rgba(0, 0, 0, 0.25);
}

.card.pair-ready .card-inner {
  border-color: rgba(116, 255, 207, 0.94);
}

@keyframes pair-ready-breathe-mint {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow:
      0 0 0 2px rgba(116, 255, 207, 0.26),
      0 0 12px rgba(116, 255, 207, 0.20),
      0 9px 18px rgba(0, 0, 0, 0.25);
  }
  50% {
    transform: translateY(-1px) scale(1.018);
    box-shadow:
      0 0 0 3px rgba(116, 255, 207, 0.58),
      0 0 28px rgba(116, 255, 207, 0.48),
      0 12px 22px rgba(0, 0, 0, 0.3);
  }
}

.message-guide-cursor {
  animation:
    guide-cursor-float 5.8s cubic-bezier(0.42, 0, 0.28, 1) infinite,
    guide-cursor-idle-hop 18s ease-in-out infinite;
}

.message-guide-cursor-img {
  animation:
    guide-cursor-sway 4.7s ease-in-out infinite,
    guide-cursor-idle-click 18s ease-in-out infinite;
}

.message-guide-cursor::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 5px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 249, 237, 0.72);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  animation: guide-cursor-idle-ripple 18s ease-out infinite;
}

@keyframes guide-cursor-idle-hop {
  0%, 68%, 100% { translate: 0 0; }
  70% { translate: 0 0; }
  71.5% { translate: 0 -5px; }
  73% { translate: 0 0; }
  74.2% { translate: 0 -2px; }
  75.4% { translate: 0 0; }
}

@keyframes guide-cursor-idle-click {
  0%, 69%, 100% { scale: 1; }
  70.8% { scale: 0.96; }
  72.2% { scale: 1.07; }
  73.6% { scale: 1; }
  74.3% { scale: 0.98; }
  75.2% { scale: 1.04; }
  76.2% { scale: 1; }
}

@keyframes guide-cursor-idle-ripple {
  0%, 70%, 100% { opacity: 0; transform: scale(0.35); }
  70.8% { opacity: 0.42; transform: scale(0.55); }
  73.2% { opacity: 0; transform: scale(1.45); }
  74.4% { opacity: 0.32; transform: scale(0.5); }
  76.5% { opacity: 0; transform: scale(1.25); }
}

@media (prefers-reduced-motion: reduce) {
  .message-guide-cursor,
  .message-guide-cursor-img,
  .message-guide-cursor::before,
  .card.pair-ready {
    animation: none;
  }
}


/* v18: restore board tension, critical life warning, and stronger relic messages */
.life-hearts.is-critical .life-heart.is-filled {
  color: #ff4f64;
  animation: critical-heart-pulse 980ms ease-in-out infinite;
  text-shadow:
    0 0 8px rgba(255, 79, 100, 0.75),
    0 0 18px rgba(255, 79, 100, 0.34);
}

.life-hearts.is-critical .life-heart.is-empty {
  color: rgba(255, 120, 135, 0.28);
}

@keyframes critical-heart-pulse {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35)); }
  50% { transform: translateY(-1px) scale(1.18); filter: drop-shadow(0 0 9px rgba(255, 79, 100, 0.72)); }
}

.message-panel.is-critical {
  border-color: rgba(255, 79, 100, 0.72);
  background:
    linear-gradient(90deg, rgba(255, 79, 100, 0.16), rgba(36, 33, 32, 0.78) 42%),
    rgba(36, 33, 32, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 79, 100, 0.12),
    0 0 18px rgba(255, 79, 100, 0.12);
}

.message-panel.is-relic-message {
  border-color: rgba(255, 207, 90, 0.76);
  background:
    linear-gradient(90deg, rgba(255, 207, 90, 0.2), rgba(36, 33, 32, 0.82) 46%),
    rgba(36, 33, 32, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255, 207, 90, 0.13),
    0 0 22px rgba(255, 207, 90, 0.16);
}

.message-panel.is-relic-message .message-text {
  color: #fff6d8;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-shadow: 0 0 12px rgba(255, 207, 90, 0.24);
}

.message-panel.is-relic-message .message-guide-cursor {
  filter: drop-shadow(0 0 9px rgba(255, 207, 90, 0.38));
}

.message-panel.is-critical.is-relic-message {
  border-color: rgba(255, 184, 66, 0.85);
  box-shadow:
    inset 0 0 0 1px rgba(255, 184, 66, 0.16),
    0 0 24px rgba(255, 79, 100, 0.13),
    0 0 18px rgba(255, 207, 90, 0.14);
}

@media (prefers-reduced-motion: reduce) {
  .life-hearts.is-critical .life-heart.is-filled {
    animation: none;
  }
}
