/* ゴーフィッシュ固有スタイル */

.game-panel {
  margin-top: 20px;
}

.gf-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 0 auto 14px;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
}

.gf-status__text {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.95rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-sys-color-primary) 14%, var(--md-sys-color-surface));
  color: var(--md-sys-color-on-surface);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.status-pill.is-player {
  background: color-mix(in srgb, #22d3ee 22%, var(--md-sys-color-surface));
  color: #0e7490;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.28);
}

.status-pill.is-cpu {
  background: color-mix(in srgb, #c084fc 20%, var(--md-sys-color-surface));
  color: #7e22ce;
}

.status-pill.is-win {
  background: color-mix(in srgb, var(--success, #16a34a) 18%, var(--md-sys-color-surface));
  color: var(--success, #15803d);
}

.status-pill.is-lose {
  background: color-mix(in srgb, #ef4444 16%, var(--md-sys-color-surface));
  color: #b91c1c;
}

.gf-result {
  margin: 0 auto 14px;
  padding: 14px 16px;
  border: 1px solid rgba(63, 196, 255, 0.35);
  border-radius: var(--md-sys-shape-corner-medium);
  background:
    radial-gradient(ellipse 80% 120% at 10% 0%, rgba(63, 196, 255, 0.12), transparent 55%),
    #0f1a34;
  text-align: center;
  animation: gf-pop 0.35s ease-out;
}

.gf-result.is-win {
  border-color: rgba(63, 196, 255, 0.55);
  box-shadow: 0 0 20px rgba(63, 196, 255, 0.22);
}

.gf-result.is-lose {
  border-color: rgba(232, 121, 249, 0.4);
}

.gf-result.is-draw {
  border-color: rgba(148, 163, 184, 0.45);
}

.gf-result__title {
  margin: 0 0 4px;
  color: #e8f4ff;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.gf-result.is-win .gf-result__title {
  color: #7ee0ff;
  text-shadow: 0 0 14px rgba(63, 196, 255, 0.45);
}

.gf-result__detail {
  margin: 0 0 12px;
  color: rgba(220, 236, 255, 0.9);
  font-size: 0.92rem;
  line-height: 1.5;
}

.gf-result__actions {
  display: flex;
  justify-content: center;
}

.gf-stage {
  --gf-card-w: clamp(46px, 9vw, 60px);
  --gf-card-h: calc(var(--gf-card-w) * 1.4);
  --gf-back-w: calc(var(--gf-card-w) * 0.72);
  --gf-radius: clamp(5px, 1.2vw, 8px);
  --gf-neon: #3fc4ff;

  position: relative;
  width: 100%;
  max-width: min(100%, 760px);
  margin: 0 auto 14px;
  padding: clamp(10px, 2.4vw, 20px);
  border: 1px solid rgba(96, 154, 214, 0.35);
  border-radius: var(--md-sys-shape-corner-large);
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(63, 196, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(167, 139, 250, 0.12), transparent 50%),
    #0d1730;
  box-shadow: 0 14px 34px rgba(28, 52, 96, 0.24);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gf-seat {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-medium);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.gf-stage.is-cpu-turn .gf-seat--cpu,
.gf-stage.is-player-turn .gf-seat--you {
  border-color: rgba(63, 196, 255, 0.55);
  background: rgba(63, 196, 255, 0.08);
  box-shadow: 0 0 16px rgba(63, 196, 255, 0.18);
}

.gf-seat__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  margin-bottom: 8px;
}

.gf-seat__name {
  color: #d7e8ff;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.gf-seat__count {
  color: rgba(180, 210, 245, 0.85);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gf-seat__score {
  padding: 2px 10px;
  border: 1px solid rgba(63, 196, 255, 0.45);
  border-radius: 999px;
  background: rgba(15, 28, 56, 0.85);
  color: #bfeaff;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gf-seat__score.is-bumped {
  animation: gf-score 0.6s ease-out;
}

@keyframes gf-score {
  0% { transform: scale(1.25); box-shadow: 0 0 18px rgba(63, 196, 255, 0.7); }
  100% { transform: scale(1); box-shadow: none; }
}

.gf-books {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  min-height: 24px;
  margin: 0 0 8px;
}

.gf-seat--cpu .gf-books {
  margin: 8px 0 0;
}

.gf-books__empty {
  color: rgba(180, 210, 245, 0.5);
  font-size: 0.75rem;
  line-height: 24px;
}

.gf-book {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 6px;
  background: rgba(30, 27, 75, 0.7);
  color: #e0d7ff;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
}

.gf-book.is-new {
  animation: gf-book 0.8s ease-out;
}

@keyframes gf-book {
  0% { transform: scale(1.4); border-color: #3fc4ff; box-shadow: 0 0 16px rgba(63, 196, 255, 0.8); }
  100% { transform: scale(1); }
}

/* CPU手札（裏向き・重ね表示） */
.gf-backs {
  --count: 1;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: min(100%, 520px);
  min-height: calc(var(--gf-back-w) * 1.4);
  margin: 0 auto;
}

.gf-backs .gf-card:not(:first-child) {
  margin-left: calc(
    min(
      var(--gf-back-w) - 10px,
      max(0px, (100% - var(--gf-back-w)) / max(var(--count) - 1, 1))
    ) - var(--gf-back-w)
  );
}

.gf-backs .gf-card {
  width: var(--gf-back-w);
  height: calc(var(--gf-back-w) * 1.4);
}

.gf-backs__empty {
  align-self: center;
  color: rgba(180, 210, 245, 0.55);
  font-size: 0.8rem;
}

/* 中央：メッセージと山札 */
.gf-center {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
  margin: clamp(10px, 2vw, 14px) 0;
}

.gf-message {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 84px;
  padding: 8px 12px;
  border: 1px solid rgba(96, 154, 214, 0.35);
  border-radius: var(--md-sys-shape-corner-medium);
  background: rgba(10, 19, 40, 0.75);
}

.gf-message__line {
  margin: 0;
  color: rgba(190, 214, 245, 0.7);
  font-size: 0.8rem;
  line-height: 1.5;
}

.gf-message__line:first-child {
  color: #eaf5ff;
  font-size: 0.95rem;
  font-weight: 700;
  animation: gf-fade 0.25s ease-out;
}

.gf-message__line.is-fish:first-child {
  color: #fbcfe8;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(244, 114, 182, 0.5);
}

.gf-message__line.is-book:first-child {
  color: #a5f3fc;
  text-shadow: 0 0 10px rgba(63, 196, 255, 0.45);
}

@keyframes gf-fade {
  0% { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 1; transform: none; }
}

.gf-stock {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gf-pile {
  position: relative;
  width: var(--gf-card-w);
  height: var(--gf-card-h);
}

.gf-pile .gf-card {
  position: absolute;
  inset: 0;
}

.gf-pile .gf-card.is-under {
  transform: translate(3px, 3px);
  opacity: 0.75;
}

.gf-pile.is-drawing .gf-card:last-child {
  animation: gf-draw 0.35s ease-out;
}

@keyframes gf-draw {
  0% { transform: translateY(0); box-shadow: 0 0 16px rgba(63, 196, 255, 0.6); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

.gf-pile-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgba(120, 170, 220, 0.4);
  border-radius: var(--gf-radius);
  color: rgba(180, 210, 245, 0.55);
  font-size: 0.8rem;
  font-weight: 700;
}

.gf-pile-label {
  margin: 0;
  color: rgba(180, 210, 245, 0.9);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* カード共通 */
.gf-card {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: var(--gf-card-w);
  height: var(--gf-card-h);
  border: 1px solid rgba(20, 36, 68, 0.18);
  border-radius: var(--gf-radius);
  box-shadow: 0 2px 6px rgba(8, 16, 36, 0.28);
  font-family: Outfit, "Noto Sans JP", sans-serif;
  overflow: hidden;
}

.gf-card.is-face {
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fd 100%);
}

.gf-card[data-color="red"] {
  color: #c62828;
}

.gf-card[data-color="black"] {
  color: #1b2436;
}

.gf-card.is-back {
  border-color: rgba(90, 170, 255, 0.45);
  background-color: #050b24;
  background-image: url('/images/card-back.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow:
    0 2px 6px rgba(8, 16, 36, 0.35);
}

.gf-card.is-back::after {
  content: none;
}

.gf-card.is-new {
  animation: gf-pop 0.45s ease-out;
}

@keyframes gf-pop {
  0% { transform: translateY(-10px) scale(1.06); opacity: 0.4; }
  100% { transform: none; opacity: 1; }
}

.gf-card__corner {
  position: absolute;
  top: 4%;
  left: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.gf-card__rank {
  font-size: calc(var(--gf-card-w) * 0.3);
  font-weight: 700;
}

.gf-card__suit {
  font-size: calc(var(--gf-card-w) * 0.24);
  line-height: 1;
}

.gf-card__center {
  position: absolute;
  right: 8%;
  bottom: 6%;
  font-size: calc(var(--gf-card-w) * 0.4);
  line-height: 1;
  pointer-events: none;
}

/* あなたの手札（数字ごとのグループ＝1つの要求ボタン） */
.gf-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 8px;
  min-height: calc(var(--gf-card-h) + 8px);
  padding-top: 6px;
}

.gf-hand__empty {
  align-self: center;
  color: rgba(180, 210, 245, 0.6);
  font-size: 0.85rem;
}

.gf-group {
  --n: 1;
  position: relative;
  display: flex;
  width: calc(var(--gf-card-w) + (var(--n) - 1) * var(--gf-card-w) * 0.36);
  min-width: 44px;
  height: var(--gf-card-h);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--gf-radius);
  background: none;
  font: inherit;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.gf-group .gf-card:not(:first-child) {
  margin-left: calc(var(--gf-card-w) * -0.64);
}

.gf-group:disabled {
  opacity: 1;
}

.gf-group.is-interactive {
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 3px;
  transition: transform 0.12s ease, outline-color 0.12s ease, filter 0.12s ease;
}

.gf-group.is-interactive:hover,
.gf-group.is-interactive:focus-visible {
  transform: translateY(-5px);
  outline-color: var(--gf-neon);
  filter: drop-shadow(0 0 8px rgba(63, 196, 255, 0.55));
}

.gf-group.is-asked {
  transform: translateY(-6px);
  outline: 2px solid var(--gf-neon);
  outline-offset: 3px;
  filter: drop-shadow(0 0 10px rgba(63, 196, 255, 0.6));
}

.gf-group.is-asked::before,
.gf-group.is-targeted::before {
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 3;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.gf-group.is-asked::before {
  content: "要求中";
  background: #0e7490;
  color: #ffffff;
}

.gf-group.is-targeted {
  outline: 2px dashed #e879f9;
  outline-offset: 3px;
}

.gf-group.is-targeted::before {
  content: "CPUが要求";
  background: #86198f;
  color: #ffffff;
}

.gf-guide {
  max-width: min(100%, 760px);
  margin: 0 auto 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.gf-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.how-to-list--ordered {
  list-style: decimal;
  padding-left: 1.35em;
}

.how-to-list--ordered li {
  margin: 0.35em 0;
}

@media (max-width: 720px) {
  .gf-stage {
    --gf-card-w: clamp(44px, 12vw, 54px);
    padding: 12px 8px;
  }

  .gf-message {
    min-height: 92px;
  }
}

@media (max-width: 420px) {
  .gf-hand {
    gap: 12px 6px;
  }

  .gf-message {
    padding: 6px 8px;
  }

  .gf-message__line:first-child {
    font-size: 0.88rem;
  }

  .gf-message__line.is-fish:first-child {
    font-size: 1.1rem;
  }
}

@media (hover: none) {
  .gf-group.is-interactive:hover {
    transform: none;
    outline-color: transparent;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gf-card.is-new,
  .gf-book.is-new,
  .gf-seat__score.is-bumped,
  .gf-pile.is-drawing .gf-card:last-child,
  .gf-message__line:first-child,
  .gf-result {
    animation: none;
  }
}

/* 外枠と操作は共通テーマ。手札・山札・要求履歴はゲーム固有。 */
html.gs-playing .game-panel { align-items: center; }
html.gs-playing .game-panel > .gs-bar,
html.gs-playing .game-panel > .gs-hud,
html.gs-playing .gf-stage,
html.gs-playing .gf-controls,
html.gs-playing .gf-status__text { width: 100%; max-width: 640px; flex: none; }
html.gs-playing .status-pill {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--play-text);
  box-shadow: none;
  font-size: 1.15rem;
}
html.gs-playing .gf-status__text {
  min-height: 3em;
  margin: 0;
  color: var(--play-text-muted);
  font-size: .85rem;
  line-height: 1.5;
  text-align: center;
}
html.gs-playing .gf-stage { border-color: var(--play-border); }
/* 履歴の折り返しとセット増加で操作位置が動かないよう領域を確保する。 */
html.gs-playing .gf-message { height: 9em; overflow-y: auto; font-size: .8rem; }
html.gs-playing .gf-books { min-height: 52px; }
html.gs-playing .gf-controls { margin: 0; gap: 12px; }
html.gs-playing .gf-result {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 16px;
  background: rgba(11, 20, 42, .96);
}
html.gs-playing .gf-guide {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (min-width: 768px) and (min-height: 700px) {
  html.gs-playing .game-panel { padding-top: max(28px, env(safe-area-inset-top)); }
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 24px; }
  html.gs-playing .gf-stage { margin-bottom: 20px; }
}
@media (max-width: 720px) {
  html.gs-playing .gf-stage { --gf-card-w: 44px; padding: 8px; }
  html.gs-playing .gf-seat { padding: 6px; }
}
