/* スパイダーソリティア固有スタイル */

.sp-settings {
  max-width: min(100%, 520px);
  margin: 4px auto 14px;
  text-align: center;
}

.sp-settings .field-label {
  margin-bottom: 8px;
}

.option-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.option-tab {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 8px 6px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.04s ease;
}

.option-tab small {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.75;
}

.option-tab:hover {
  background: var(--md-sys-color-primary-container);
}

.option-tab:active {
  transform: translateY(1px);
}

.option-tab.is-active {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.option-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--md-sys-color-primary) 70%, white);
  outline-offset: 2px;
}

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

.sp-board {
  --sp-card-w: clamp(28px, 8.6vw, 84px);
  --sp-card-h: calc(var(--sp-card-w) * 1.4);
  --sp-gap: clamp(2px, 0.9vw, 10px);
  --sp-radius: clamp(4px, 0.9vw, 8px);
  --sp-board-bg: #0d1730;
  --sp-accent: #3fc4ff;
  --sp-set: #a58bff;
  --sp-target: #ff6fd8;

  position: relative;
  padding: clamp(8px, 2vw, 18px);
  border: 1px solid rgba(96, 154, 214, 0.35);
  border-radius: var(--md-sys-shape-corner-large);
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(63, 196, 255, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 100%, rgba(165, 139, 255, 0.12), transparent 50%),
    var(--sp-board-bg);
  box-shadow: 0 14px 34px rgba(28, 52, 96, 0.24);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sp-top,
.sp-tableau {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  column-gap: var(--sp-gap);
  align-items: start;
}

.sp-top {
  margin-bottom: clamp(12px, 2.4vw, 20px);
}

.sp-set[data-set="0"] {
  grid-column-start: 3;
}

.sp-slot {
  position: relative;
  width: var(--sp-card-w);
  min-height: var(--sp-card-h);
  margin: 0 auto;
  border: 1.5px dashed rgba(96, 154, 214, 0.38);
  border-radius: var(--sp-radius);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.sp-slot:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
}

.sp-slot.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-stock {
  height: var(--sp-card-h);
  border: 1.5px solid rgba(63, 196, 255, 0.5);
  background: rgba(63, 196, 255, 0.06);
  cursor: pointer;
}

.sp-stock:not(.is-empty) {
  border-color: transparent;
  background: transparent;
}

.sp-stock.is-empty {
  cursor: default;
}

.sp-stock > .sp-card {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
}

.sp-stock:not(.is-empty):hover > .sp-card {
  box-shadow:
    0 0 12px rgba(63, 196, 255, 0.35);
}

.sp-stock__count {
  position: relative;
  z-index: 1;
  min-width: 1.6em;
  padding: 2px 4px;
  border-radius: 999px;
  background: rgba(8, 16, 36, 0.78);
  color: #e8f4ff;
  text-align: center;
}

.sp-set {
  height: var(--sp-card-h);
  border: 1.5px solid rgba(165, 139, 255, 0.4);
  background: rgba(165, 139, 255, 0.06);
}

.sp-set > .sp-card {
  position: absolute;
  top: -1.5px;
  left: -1.5px;
}

.sp-set.is-new {
  animation: sp-set-in 700ms ease-out;
}

@keyframes sp-set-in {
  0% { box-shadow: 0 0 0 0 rgba(165, 139, 255, 0); }
  35% { box-shadow: 0 0 16px 4px rgba(165, 139, 255, 0.6); }
  100% { box-shadow: 0 0 0 0 rgba(165, 139, 255, 0); }
}

.sp-column {
  cursor: pointer;
}

.sp-column.is-empty {
  border: 2px dashed rgba(63, 196, 255, 0.6);
  background: rgba(63, 196, 255, 0.08);
}

.sp-column:not(.is-empty) {
  border-color: transparent;
  background: transparent;
}

.sp-slot.is-target {
  border-style: solid;
  border-color: var(--sp-target);
  background: rgba(255, 111, 216, 0.1);
}

.sp-slot.is-target > .sp-card:last-child {
  outline: 2px solid rgba(255, 111, 216, 0.85);
  outline-offset: 1px;
}

.sp-slot.is-invalid {
  animation: sp-shake 280ms ease;
}

@keyframes sp-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.sp-slot__hint {
  color: rgba(160, 210, 245, 0.7);
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: max(10px, calc(var(--sp-card-w) * 0.22));
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  pointer-events: none;
}

.sp-notice {
  position: absolute;
  left: 50%;
  z-index: 15;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 8px 14px;
  border: 1px solid rgba(63, 196, 255, 0.45);
  border-radius: 999px;
  background: rgba(14, 28, 58, 0.95);
  color: #e3f2ff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  transform: translate(-50%, calc(-100% - 4px));
  pointer-events: none;
  animation: sp-fade 180ms ease-out;
}

.sp-notice[hidden] {
  display: none;
}

.sp-column .sp-card {
  position: absolute;
  left: 0;
}

.sp-card {
  position: relative;
  display: block;
  width: var(--sp-card-w);
  height: var(--sp-card-h);
  margin: 0;
  padding: 0;
  border: 1px solid rgba(20, 36, 68, 0.22);
  border-radius: var(--sp-radius);
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fd 100%);
  box-shadow: 0 1px 4px rgba(8, 16, 36, 0.3);
  color: #1b2436;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  touch-action: manipulation;
  overflow: hidden;
}

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

.sp-card.is-done {
  cursor: default;
}

.sp-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 1px 4px rgba(8, 16, 36, 0.35);
}

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

.sp-column .sp-card.is-back {
  cursor: pointer;
}

.sp-card__corner {
  position: absolute;
  display: flex;
  align-items: baseline;
  gap: 1px;
  line-height: 1;
}

.sp-card__corner--tl {
  top: 3%;
  left: 6%;
}

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

.sp-card__rank {
  font-size: max(12px, calc(var(--sp-card-w) * 0.3));
  font-weight: 700;
  letter-spacing: -0.04em;
}

.sp-card__suit {
  font-size: max(10px, calc(var(--sp-card-w) * 0.25));
}

.sp-card__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 14%;
  font-size: calc(var(--sp-card-w) * 0.46);
  opacity: 0.92;
  pointer-events: none;
}

/* 狭い画面では左上の数字とスートを優先し、四隅の重複表示を省く */
.is-compact .sp-card__corner--tl {
  top: 2px;
  left: 2px;
  right: 1px;
  justify-content: space-between;
}

.is-compact .sp-card__corner--br {
  display: none;
}

.is-compact .sp-card__center {
  padding-top: 30%;
  font-size: calc(var(--sp-card-w) * 0.5);
}

.sp-card.is-selected {
  outline: 2px solid var(--sp-accent);
  outline-offset: 1px;
  box-shadow:
    0 0 0 2px rgba(63, 196, 255, 0.3),
    0 0 12px rgba(63, 196, 255, 0.45),
    0 2px 6px rgba(8, 16, 36, 0.28);
}

.sp-card:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 1px;
}

.sp-card.is-dragging-source {
  opacity: 0.35;
}

.sp-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: var(--sp-card-w);
  --sp-radius: 7px;
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(8, 18, 40, 0.45));
  opacity: 0.96;
}

.sp-drag-ghost .sp-card {
  position: absolute;
  left: 0;
}

/* クリア時は場札が空になるため、結果表示が収まる高さを確保する */
.sp-stage.is-finished .sp-board {
  min-height: 280px;
}

.sp-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px;
  border-radius: var(--md-sys-shape-corner-large);
  background: rgba(11, 20, 42, 0.92);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  text-align: center;
  animation: sp-fade 220ms ease-out;
}

@keyframes sp-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sp-overlay__title {
  margin: 0;
  color: #e8f4ff;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sp-overlay.is-win .sp-overlay__title {
  color: #7ee0ff;
  text-shadow: 0 0 18px rgba(63, 196, 255, 0.55);
}

.sp-overlay__message {
  margin: 0;
  color: #e8f4ff;
  font-size: 1rem;
  font-weight: 600;
}

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

.sp-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.sp-overlay__actions .btn {
  min-width: 140px;
}

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

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

.game-controls {
  justify-content: center;
}

@media (max-width: 560px) {
  .sp-board {
    --sp-gap: 2px;
    padding: 8px 3px 12px;
  }

  .option-tab {
    min-height: 44px;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sp-overlay,
  .sp-notice,
  .sp-set.is-new,
  .sp-slot.is-invalid {
    animation: none;
  }
}

/* 外枠は共通画面。10列のカードに必要な盤面寸法だけ個別に調整する。 */
html.gs-playing .game-panel { align-items: center; gap: 12px; }
html.gs-playing .game-panel > .gs-bar { gap: 10px; }
html.gs-playing .game-panel > .gs-bar,
html.gs-playing .sp-status,
html.gs-playing .sp-stage,
html.gs-playing .game-controls {
  flex: none;
  width: 100%;
  max-width: 640px;
  margin: 0;
}
html.gs-playing .sp-settings { flex: 1; max-width: 520px; margin: 0; }
html.gs-playing .sp-settings .field-label { display: none; }
html.gs-playing .option-tabs { gap: 6px; }
html.gs-playing .option-tab { min-height: 44px; padding: 6px 3px; }
html.gs-playing .sp-board { --sp-gap: 3px; padding: 12px 4px; border-color: var(--play-border); }
html.gs-playing .sp-stage { min-height: 0; }
html.gs-playing .sp-board { min-height: 220px; }
html.gs-playing .sp-stage.is-finished .sp-board { min-height: 220px; }
html.gs-playing .game-controls { padding: 0; }
.sp-overlay[hidden] { display: none; }
@media (min-width: 768px) and (min-height: 700px) {
  html.gs-playing .game-panel { padding-top: max(24px, env(safe-area-inset-top)); gap: 20px; }
}
@media (max-width: 560px) {
  html.gs-playing .sp-board { --sp-gap: 2px; padding: 8px 3px 12px; }
  html.gs-playing .option-tab { font-size: 0.75rem; }
}

html.gs-playing .option-tab {
  flex-direction: column;
  gap: 0;
  min-height: 44px;
  padding: 4px 6px;
  border-color: var(--play-border);
  background: var(--play-hud-bg);
  color: var(--play-text);
  font-size: .8125rem;
}

html.gs-playing .option-tab small {
  font-size: .6875rem;
}

@media (hover: hover) {
  html.gs-playing .option-tab:hover {
    border-color: color-mix(in srgb, var(--play-accent) 55%, var(--play-border));
    background: var(--play-btn-hover);
  }
}

html.gs-playing .option-tab.is-active {
  border-color: var(--play-accent);
  background: color-mix(in srgb, var(--play-accent) 18%, var(--play-hud-bg));
  color: var(--play-accent);
}

html.gs-playing .option-tab:focus-visible {
  outline: 2px solid var(--play-accent);
  outline-offset: 2px;
}
