/* 15パズル固有スタイル */

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

.p15-status {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  max-width: min(100%, 420px);
  margin: 0 auto 14px;
  padding: 12px 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
}

.p15-status__item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 6px 4px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: color-mix(in srgb, var(--md-sys-color-primary) 8%, var(--md-sys-color-surface));
}

.p15-status__label {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.p15-status__value {
  color: var(--md-sys-color-on-surface);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.p15-result {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--success) 38%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, var(--success) 10%, var(--md-sys-color-surface));
  animation: p15-result-in 200ms ease-out;
}

.p15-result__title {
  margin: 0;
  font-family: "Outfit", "Noto Sans JP", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--success);
}

.p15-result__detail {
  margin: 4px 0 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.875rem;
  line-height: 1.6;
}

.p15-result__actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.p15-result__actions .btn {
  min-width: 9rem;
}

@keyframes p15-result-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.p15-board-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 10px;
  overflow: hidden;
}

.p15-board {
  --p15-gap: clamp(6px, 2vw, 10px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--p15-gap);
  width: 100%;
  max-width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  padding: var(--p15-gap);
  border: 1px solid rgba(96, 154, 214, 0.35);
  border-radius: var(--md-sys-shape-corner-large);
  background:
    radial-gradient(circle at 18% 0%, rgba(63, 196, 255, 0.14), transparent 62%),
    radial-gradient(circle at 86% 100%, rgba(122, 157, 255, 0.14), transparent 60%),
    linear-gradient(160deg, #16264a 0%, #101c38 55%, #0d1730 100%);
  box-shadow: 0 14px 34px rgba(28, 52, 96, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  user-select: none;
  -webkit-user-select: none;
}

.p15-tile {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(215, 230, 255, 0.35);
  border-radius: 12px;
  background: linear-gradient(165deg, #f7fbff 0%, #e8f0fb 100%);
  color: #1a2a4a;
  font-family: "Outfit", "Noto Sans JP", sans-serif;
  font-size: clamp(1.35rem, 7vw, 2.1rem);
  font-weight: 700;
  line-height: 1;
  cursor: default;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.p15-tile.is-movable {
  cursor: pointer;
  border-color: rgba(64, 180, 255, 0.55);
  box-shadow: 0 2px 0 rgba(26, 42, 74, 0.12);
}

.p15-tile.is-movable:hover {
  background: linear-gradient(165deg, #ffffff 0%, #edf5ff 100%);
  border-color: rgba(64, 200, 255, 0.85);
}

.p15-tile.is-movable:active {
  transform: scale(0.96);
}

.p15-tile:focus-visible {
  outline: 3px solid rgba(64, 200, 255, 0.85);
  outline-offset: 2px;
}

.p15-tile:disabled {
  cursor: default;
  opacity: 0.92;
}

.p15-tile--empty {
  border: 1px dashed rgba(180, 210, 245, 0.28);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

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

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

@media (max-width: 480px) {
  .p15-status {
    padding: 10px 8px;
  }

  .p15-tile {
    border-radius: 10px;
    font-size: clamp(1.25rem, 8.5vw, 1.75rem);
  }
}

/* ——— プレイ画面（/css/game-screen.css の全画面表示中・ダークテーマ） ——— */
/* 背景・戻るボタン・アイコンボタンの配色は共通テーマ（gs-theme-dark）を使い、ここでは配置と HUD だけを決める */
/* 盤面は「画面の高さ − 盤面以外の高さ（--p15-chrome）」と幅に収まる正方形とし、大画面でも 560px までにとどめる */
/* 情報は上部に置き、盤面と操作ボタンは間を空けずにひとまとまりにして残りの領域の中央に置く */
html.gs-playing .game-panel {
  --p15-chrome: 212px;
}

html.gs-playing .game-panel:has(.p15-result:not([hidden])) {
  --p15-chrome: 360px;
}

html.gs-playing .p15-status,
html.gs-playing .p15-result,
html.gs-playing .game-panel .game-controls {
  flex: none;
  width: 100%;
  max-width: min(100%, 560px);
  margin-left: auto;
  margin-right: auto;
}

html.gs-playing .p15-status {
  gap: 0;
  margin-bottom: 10px;
  padding: 6px 4px;
  border-color: var(--play-border);
  background: color-mix(in srgb, var(--play-hud-bg) 88%, transparent);
}

html.gs-playing .p15-status__item {
  padding: 2px 8px;
  border-radius: 0;
  background: none;
}

html.gs-playing .p15-status__item + .p15-status__item {
  border-left: 1px solid var(--play-border);
}

html.gs-playing .p15-status__label {
  color: var(--play-text-muted);
}

html.gs-playing .p15-status__value {
  color: var(--play-text);
}

html.gs-playing .p15-result {
  margin-bottom: 10px;
  border-color: color-mix(in srgb, var(--success) 45%, var(--play-border));
  background: var(--play-hud-bg);
}

html.gs-playing .p15-result__title {
  color: color-mix(in srgb, var(--success) 55%, var(--play-text));
}

html.gs-playing .p15-result__detail {
  color: var(--play-text);
}

html.gs-playing .p15-board-wrap {
  flex: none;
  margin-top: auto;
  margin-bottom: 10px;
  container-type: inline-size;
}

html.gs-playing .p15-board {
  --p15-size: min(100cqw, max(160px, min(100vh - var(--p15-chrome), 560px)));
  --p15-size: min(100cqw, max(160px, min(100dvh - var(--p15-chrome), 560px)));
  width: var(--p15-size);
  max-width: none;
  border-color: var(--play-border);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

html.gs-playing .p15-tile {
  font-size: clamp(1.1rem, var(--p15-size) * .09, 3rem);
}

/* 操作説明はプレイ中は画面に出さず、盤面の説明（aria-describedby）として読み上げだけに残す */
html.gs-playing .p15-guide {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html.gs-playing .game-panel .game-controls {
  gap: 12px;
  margin-top: 0;
  margin-bottom: auto;
}

/* スマートフォン横向きなど高さが足りない画面では、情報と操作を左、盤面を右に並べる */
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel {
    display: grid;
    grid-template-columns: minmax(170px, 260px) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "bar board"
      "status board"
      "result board"
      "controls board";
    column-gap: 16px;
  }

  html.gs-playing .game-panel > .gs-bar { grid-area: bar; }
  html.gs-playing .p15-status { grid-area: status; }
  html.gs-playing .p15-result { grid-area: result; padding: 10px 12px; }
  html.gs-playing .game-panel .game-controls { grid-area: controls; justify-content: flex-start; margin-bottom: 0; }

  html.gs-playing .p15-board-wrap {
    grid-area: board;
    align-items: center;
    min-height: 0;
    margin: 0;
    container-type: size;
  }

  html.gs-playing .p15-board {
    --p15-size: min(100cqw, 100cqh, 560px);
  }
}
