/* ババ抜き固有スタイル */

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

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

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

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

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

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

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

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

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

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

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

.om-stage {
  position: relative;
  width: 100%;
  max-width: min(100%, 760px);
  margin: 0 auto 14px;
}

.om-table {
  --om-card-w: clamp(42px, 11vw, 64px);
  --om-card-h: calc(var(--om-card-w) * 1.4);
  --om-overlap: calc(var(--om-card-w) * 0.42);
  --om-radius: clamp(5px, 1.2vw, 9px);
  --om-board-bg: #0d1730;
  --om-neon: #3fc4ff;
  --om-neon-2: #a78bfa;

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "top top top"
    "left center right"
    "bottom bottom bottom";
  gap: clamp(8px, 1.8vw, 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(--om-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;
}

.om-seat--cpu2 { grid-area: top; }
.om-seat--cpu1 { grid-area: left; align-self: center; }
.om-seat--cpu3 { grid-area: right; align-self: center; }
.om-seat--you { grid-area: bottom; }
.om-center { grid-area: center; align-self: center; justify-self: center; }

.om-seat {
  min-width: 0;
  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;
}

.om-seat.is-turn {
  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);
}

.om-seat.is-target {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.1);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.2);
}

.om-seat.is-out {
  opacity: 0.55;
}

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

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

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

.om-seat__badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(63, 196, 255, 0.22);
  color: #7ee0ff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.om-center__label {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(63, 196, 255, 0.2);
  color: #9be8ff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px rgba(63, 196, 255, 0.5);
  animation: om-pair-pop 0.45s ease-out;
}

@keyframes om-pair-pop {
  0% { opacity: 0; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

.om-hand {
  --count: 1;
  --om-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(--om-card-h);
  gap: 0;
}

/* 余白があるときは軽く重ね、狭いときは席幅に収まるようさらに重ねる */
.om-hand .om-card:not(:first-child) {
  margin-left: calc(
    min(
      var(--om-card-w) - var(--om-overlap-min),
      max(0px, (100% - var(--om-card-w)) / max(var(--count) - 1, 1))
    ) - var(--om-card-w)
  );
}

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

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

.om-card {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: var(--om-card-w);
  height: var(--om-card-h);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(20, 36, 68, 0.18);
  border-radius: var(--om-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;
}

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

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

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

.om-card.is-joker.is-face {
  color: #5b21b6;
  background: linear-gradient(180deg, #f8f5ff 0%, #efe8ff 100%);
  border-color: rgba(124, 58, 237, 0.35);
}

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

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

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

.om-card.is-selectable:hover,
.om-card.is-selectable:focus-visible {
  transform: translateY(-4px);
  outline-color: var(--om-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;
}

.om-card.is-drawn {
  animation: om-draw 0.35s ease-out;
}

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

.om-card.is-pairing {
  animation: om-pair-out 0.4s ease-in forwards;
}

@keyframes om-pair-out {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7) translateY(-8px); }
}

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

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

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

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

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

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

.om-card.is-joker .om-card__center {
  font-size: calc(var(--om-card-w) * 0.18);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-align: center;
  padding: 0 4px;
}

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

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

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

@media (max-width: 720px) {
  .om-table {
    --om-card-w: clamp(36px, 9.5vw, 48px);
    --om-overlap: calc(var(--om-card-w) * 0.48);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "top top"
      "left right"
      "center center"
      "bottom bottom";
    gap: 10px;
    padding: 12px 10px;
  }

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

  .om-seat__header {
    gap: 2px 6px;
  }

  .om-center {
    min-height: 1.5rem;
  }
}

@media (max-width: 420px) {
  .om-table {
    --om-card-w: clamp(30px, 8.5vw, 40px);
    --om-overlap: calc(var(--om-card-w) * 0.52);
  }

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

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

  .om-card.is-joker .om-card__center {
    font-size: calc(var(--om-card-w) * 0.16);
  }
}

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

  .om-seat.is-target .om-card.is-selectable {
    outline: 2px dashed rgba(63, 196, 255, 0.55);
    outline-offset: 1px;
  }
}

/* 共通の外枠・HUD・操作を再利用し、4人用のカードテーブルだけ固有配置にする。 */
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 .om-stage,
html.gs-playing .om-status__text,
html.gs-playing .om-guide,
html.gs-playing .game-controls {
  width: 100%;
  max-width: 640px;
  flex: none;
}
html.gs-playing .gs-hud__value { font-size: 1.15rem; }
html.gs-playing .om-status__text {
  min-height: 3em;
  margin: 0 0 10px;
  color: var(--play-text-muted);
  text-align: center;
  line-height: 1.5;
}
html.gs-playing .om-stage { margin-bottom: 12px; }
html.gs-playing .om-center { min-height: 36px; }
html.gs-playing .om-result {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: rgba(11, 20, 42, .94);
  backdrop-filter: blur(5px);
}
html.gs-playing .om-guide { color: var(--play-text-muted); }
html.gs-playing .game-controls { justify-content: center; margin: 0; }
@media (min-width: 768px) and (min-height: 600px) {
  html.gs-playing .game-panel {
    padding-top: max(clamp(24px, 5vh, 56px), env(safe-area-inset-top));
  }
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 28px; }
  html.gs-playing .om-stage { margin-bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .om-card, .om-center__label { animation: none !important; transition: none; }
}
/* 上がりバッジは空いた手札領域に重ね、席の高さを変えない。 */
.om-seat { position: relative; }
.om-seat__header { min-height: 24px; align-content: center; }
.om-seat__badge {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
/* 詳しい操作説明は盤面の読み上げに残し、画面上はターン案内に集約。 */
html.gs-playing .om-guide {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
