/* クレイジーエイト固有スタイル */

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

.ce-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  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);
}

.ce-status__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  min-width: 0;
}

.ce-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;
}

.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-suit {
  background: color-mix(in srgb, #f59e0b 20%, var(--md-sys-color-surface));
  color: #b45309;
}

.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;
}

.ce-feedback {
  margin: 0 auto 12px;
  padding: 8px 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, #ef4444 10%, var(--md-sys-color-surface));
  color: #b91c1c;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.ce-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;
}

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

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

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

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

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

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

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

.ce-stage {
  --ce-card-w: clamp(44px, 11vw, 68px);
  --ce-card-h: calc(var(--ce-card-w) * 1.4);
  --ce-radius: clamp(5px, 1.2vw, 9px);
  --ce-board-bg: #0d1730;
  --ce-neon: #3fc4ff;
  --ce-neon-2: #a78bfa;

  position: relative;
  width: 100%;
  max-width: min(100%, 760px);
  margin: 0 auto 14px;
  padding: clamp(12px, 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%),
    var(--ce-board-bg);
  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;
}

.ce-seat {
  min-width: 0;
  margin-bottom: clamp(10px, 2vw, 16px);
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-medium);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.ce-stage.is-cpu-turn .ce-seat--cpu,
.ce-stage.is-player-turn .ce-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);
}

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

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

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

.ce-hand {
  --count: 1;
  --ce-overlap-min: 12px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: var(--ce-card-h);
  gap: 0;
}

.ce-hand .ce-card:not(:first-child) {
  margin-left: calc(
    min(
      var(--ce-card-w) - var(--ce-overlap-min),
      max(0px, (100% - var(--ce-card-w)) / max(var(--count) - 1, 1))
    ) - var(--ce-card-w)
  );
}

.ce-hand .ce-card:first-child {
  margin-left: 0;
}

.ce-hand--you {
  max-width: min(100%, 680px);
  margin-inline: auto;
}

.ce-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: clamp(10px, 2.5vw, 20px);
  margin: 4px 0 14px;
  padding: 8px 4px;
}

.ce-pile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ce-pile-wrap--stock {
  justify-self: end;
}

.ce-pile-wrap--discard {
  justify-self: start;
}

.ce-pile-label {
  margin: 0;
  color: rgba(180, 210, 245, 0.9);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

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

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

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

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

.ce-active-suit-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  align-self: center;
}

.ce-active-suit {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(63, 196, 255, 0.4);
  border-radius: var(--md-sys-shape-corner-medium);
  background: rgba(15, 28, 56, 0.85);
  color: #d7e8ff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

.ce-active-suit.is-declared {
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.25);
  color: #fde68a;
}

.ce-suit-picker {
  margin: 0 auto 14px;
  padding: 14px 12px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--md-sys-shape-corner-medium);
  background:
    radial-gradient(ellipse 70% 80% at 50% 0%, rgba(245, 158, 11, 0.12), transparent 60%),
    #121c36;
  text-align: center;
}

.ce-suit-picker__title {
  margin: 0 0 10px;
  color: #fde68a;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.ce-suit-picker__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.ce-suit-btn {
  min-width: 64px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid rgba(120, 180, 240, 0.4);
  border-radius: var(--md-sys-shape-corner-medium);
  background: rgba(255, 255, 255, 0.96);
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.ce-suit-btn[data-suit="hearts"],
.ce-suit-btn[data-suit="diamonds"] {
  color: #c62828;
}

.ce-suit-btn[data-suit="spades"],
.ce-suit-btn[data-suit="clubs"] {
  color: #1b2436;
}

.ce-suit-btn:hover,
.ce-suit-btn:focus-visible {
  transform: translateY(-2px);
  border-color: var(--ce-neon);
  box-shadow: 0 0 12px rgba(63, 196, 255, 0.45);
  outline: none;
}

.ce-card {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: var(--ce-card-w);
  height: var(--ce-card-h);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(20, 36, 68, 0.18);
  border-radius: var(--ce-radius);
  box-shadow: 0 2px 6px rgba(8, 16, 36, 0.28);
  font-family: Outfit, "Noto Sans JP", sans-serif;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  touch-action: manipulation;
}

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

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

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

.ce-card.is-eight.is-face {
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.35),
    0 2px 6px rgba(8, 16, 36, 0.28);
}

.ce-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);
}

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

.ce-card.is-interactive {
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, outline-color 0.12s ease;
}

.ce-card.is-interactive:hover,
.ce-card.is-interactive:focus-visible {
  transform: translateY(-5px);
  outline-color: var(--ce-neon);
  box-shadow:
    0 0 0 2px rgba(63, 196, 255, 0.35),
    0 0 14px rgba(63, 196, 255, 0.5),
    0 4px 10px rgba(8, 16, 36, 0.35);
  z-index: 2;
}

.ce-card.is-playable {
  outline: 1.5px solid rgba(63, 196, 255, 0.45);
  outline-offset: 1px;
}

.ce-card.is-played {
  animation: ce-play 0.35s ease-out;
}

@keyframes ce-play {
  0% { transform: scale(1.08); box-shadow: 0 0 16px rgba(63, 196, 255, 0.55); }
  100% { transform: scale(1); }
}

.ce-card__corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}

.ce-card__corner--tl {
  top: 4%;
  left: 6%;
}

.ce-card__corner--br {
  right: 6%;
  bottom: 4%;
  transform: rotate(180deg);
}

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

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

.ce-card__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--ce-card-w) * 0.42);
  opacity: 0.92;
  pointer-events: none;
}

.ce-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;
}

.ce-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) {
  .ce-stage {
    --ce-card-w: clamp(40px, 10vw, 54px);
    padding: 12px 10px;
  }

  .ce-center {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    justify-items: center;
  }

  .ce-pile-wrap--stock {
    justify-self: center;
  }

  .ce-pile-wrap--discard {
    justify-self: center;
  }

  .ce-active-suit-wrap {
    grid-column: 1 / -1;
  }

  .ce-hand--you {
    max-width: 100%;
  }

  .ce-suit-btn {
    min-width: 56px;
    min-height: 44px;
    font-size: 1.25rem;
  }
}

@media (max-width: 420px) {
  .ce-stage {
    --ce-card-w: clamp(34px, 9vw, 44px);
  }

  .ce-hand {
    --ce-overlap-min: 10px;
  }

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

  .ce-active-suit {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

@media (hover: none) {
  .ce-card.is-interactive:hover {
    transform: none;
    outline-color: transparent;
    box-shadow: 0 2px 6px rgba(8, 16, 36, 0.28);
  }

  .ce-card.is-playable {
    outline: 2px dashed rgba(63, 196, 255, 0.55);
  }
}

/* 外枠・HUD・戻る操作は共通テーマ。手札とスート指定はカードゲーム専用。 */
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 .ce-stage,
html.gs-playing .ce-controls,
html.gs-playing .ce-status__text,
html.gs-playing .ce-feedback,
html.gs-playing .ce-guide { width: 100%; max-width: 640px; flex: none; }
html.gs-playing .status-pill {
  min-height: 0;
  padding: 0;
  background: none;
  color: var(--play-text);
  box-shadow: none;
  border-radius: 0;
  font-size: 1.15rem;
}
html.gs-playing .ce-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 .ce-feedback {
  min-height: 3em;
  margin: 0 0 8px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: #fca5a5;
  line-height: 1.5;
}
html.gs-playing .ce-feedback[hidden] { display: block !important; visibility: hidden; }
html.gs-playing .ce-stage { overflow: hidden; margin-bottom: 10px; }
html.gs-playing .ce-guide { margin: 0 0 10px; color: var(--play-text-muted); font-size: .8rem; }
html.gs-playing .ce-controls { display: flex; flex-wrap: nowrap; gap: 10px; margin: 0; }
html.gs-playing #draw-btn { flex: 1; min-width: 0; }
html.gs-playing #restart-btn { flex: none; min-width: 44px; }
html.gs-playing .ce-result,
html.gs-playing .ce-suit-picker {
  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 .ce-suit-picker__actions { flex-wrap: nowrap; gap: 6px; }
html.gs-playing .ce-suit-btn { min-width: 44px; padding: 8px; color: #172033; }
html.gs-playing .ce-suit-btn[data-suit="hearts"],
html.gs-playing .ce-suit-btn[data-suit="diamonds"] { color: #b91c1c; }
@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 .ce-stage { margin-bottom: 20px; }
}
@media (max-width: 720px) {
  html.gs-playing .ce-center {
    grid-template-areas: "stock discard" "suit suit";
    gap: 8px;
    margin-bottom: 8px;
  }
  html.gs-playing .ce-pile-wrap--stock { grid-area: stock; }
  html.gs-playing .ce-pile-wrap--discard { grid-area: discard; }
  html.gs-playing .ce-active-suit-wrap { grid-area: suit; }
  html.gs-playing .ce-stage { --ce-card-w: 44px; padding: 8px; }
  html.gs-playing .ce-seat { margin-bottom: 4px; padding: 6px; }
  html.gs-playing .ce-status__text { min-height: 3em; }
  html.gs-playing .ce-feedback { min-height: 1.5em; }
}
/* 操作説明は詳細ページに残し、プレイ中は読み上げ用に保持する。 */
html.gs-playing .ce-guide {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
