/* Hex（ヘックス）固有スタイル */

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

.hx-settings {
  max-width: min(100%, 560px);
  margin: 0 auto 14px;
}

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

.hx-field {
  margin: 0;
}

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

.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: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.hx-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  max-width: min(100%, 560px);
  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);
}

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

.hx-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-p1 {
  background: color-mix(in srgb, #22d3ee 22%, var(--md-sys-color-surface));
  color: #0e7490;
}

.status-pill.is-p2 {
  background: color-mix(in srgb, #e879f9 20%, var(--md-sys-color-surface));
  color: #a21caf;
}

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

.hx-result {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  text-align: center;
  animation: hx-result-in 200ms ease-out;
}

.hx-result.is-win {
  border: 1px solid color-mix(in srgb, var(--success, #16a34a) 38%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, var(--success, #16a34a) 10%, var(--md-sys-color-surface));
}

.hx-result.is-lose {
  border: 1px solid color-mix(in srgb, #ef4444 34%, var(--md-sys-color-outline-variant));
  background: color-mix(in srgb, #ef4444 10%, var(--md-sys-color-surface));
}

.hx-result__title {
  margin: 0 0 4px;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hx-result__detail {
  margin: 0 0 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.95rem;
  font-weight: 600;
}

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

@keyframes hx-result-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hx-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  max-width: min(100%, 560px);
  margin: 0 auto 12px;
  padding: 0;
  list-style: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8rem;
  font-weight: 600;
}

.hx-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hx-legend__swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.hx-legend__swatch--p1 {
  background: linear-gradient(160deg, #67e8f9, #0891b2);
}

.hx-legend__swatch--p2 {
  background: linear-gradient(160deg, #f0abfc, #a21caf);
}

.hx-legend__edge {
  width: 18px;
  height: 8px;
  border-radius: 2px;
}

.hx-legend__edge--lr {
  background: color-mix(in srgb, #22d3ee 70%, #0891b2);
  box-shadow: 0 0 6px color-mix(in srgb, #22d3ee 40%, transparent);
}

.hx-legend__edge--tb {
  background: color-mix(in srgb, #e879f9 70%, #a21caf);
  box-shadow: 0 0 6px color-mix(in srgb, #e879f9 40%, transparent);
}

.hx-board-wrap {
  --hx-p1: #22d3ee;
  --hx-p1-deep: #0891b2;
  --hx-p2: #e879f9;
  --hx-p2-deep: #a21caf;
  --hx-frame: #38bdf8;
  --hx-cell: #1a3358;
  --hx-cell-line: color-mix(in srgb, #67e8f9 28%, #0d1a36);
  --hx-board-bg: linear-gradient(160deg, #14284f 0%, #0d1a36 55%, #0a1428 100%);
  /* 11列 + 奇数行オフセット0.5 + 余白。320pxでもタップ可能なサイズを確保 */
  --hx-size: clamp(18px, calc((100vw - 48px) / 12.2), 36px);
  --hx-w: var(--hx-size);
  --hx-h: calc(var(--hx-size) * 1.1547);
  --hx-row-gap: calc(var(--hx-h) * -0.25);
  display: flex;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: min(100%, 560px);
  overflow: hidden;
}

.hx-board-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 14px 12px 16px;
  border: 2px solid color-mix(in srgb, var(--hx-frame) 70%, #0ea5e9);
  border-radius: 16px;
  background: var(--hx-board-bg);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.18),
    0 10px 28px rgba(8, 20, 48, 0.28);
}

.hx-edge-bar {
  position: absolute;
  pointer-events: none;
  border-radius: 3px;
  z-index: 0;
}

.hx-edge-bar--top,
.hx-edge-bar--bottom {
  left: 18px;
  right: 18px;
  height: 5px;
  background: linear-gradient(90deg, transparent, var(--hx-p2), transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--hx-p2) 55%, transparent);
}

.hx-edge-bar--top {
  top: 6px;
}

.hx-edge-bar--bottom {
  bottom: 6px;
}

.hx-edge-bar--left,
.hx-edge-bar--right {
  top: 18px;
  bottom: 18px;
  width: 5px;
  background: linear-gradient(180deg, transparent, var(--hx-p1), transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--hx-p1) 55%, transparent);
}

.hx-edge-bar--left {
  left: 5px;
}

.hx-edge-bar--right {
  right: 5px;
}

.hx-board {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: calc(var(--hx-w) * 11.5);
  max-width: 100%;
}

.hx-row {
  display: flex;
  margin-top: var(--hx-row-gap);
}

.hx-row:first-child {
  margin-top: 0;
}

.hx-row:nth-child(even) {
  margin-left: calc(var(--hx-w) * 0.5);
}

.hx-cell {
  position: relative;
  appearance: none;
  flex: 0 0 var(--hx-w);
  width: var(--hx-w);
  height: var(--hx-h);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hx-cell::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--hx-cell);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: inset 0 0 0 1px var(--hx-cell-line);
  transition: box-shadow 120ms ease, background 120ms ease;
}

.hx-cell.is-playable {
  cursor: pointer;
}

.hx-cell.is-playable::before {
  background: color-mix(in srgb, #22d3ee 10%, var(--hx-cell));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, #67e8f9 45%, transparent),
    0 0 8px color-mix(in srgb, #22d3ee 18%, transparent);
}

.hx-cell.is-playable:hover::before,
.hx-cell.is-playable:focus-visible::before {
  background: color-mix(in srgb, #22d3ee 18%, var(--hx-cell));
  box-shadow:
    inset 0 0 0 1.5px color-mix(in srgb, #67e8f9 70%, white),
    0 0 12px color-mix(in srgb, #22d3ee 32%, transparent);
}

.hx-cell:focus-visible {
  outline: none;
  z-index: 2;
}

.hx-cell.is-last::before {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, #fbbf24 80%, white),
    0 0 10px color-mix(in srgb, #fbbf24 35%, transparent);
}

.hx-cell.is-win-path::before {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, #f8fafc 75%, #67e8f9),
    0 0 14px color-mix(in srgb, #67e8f9 45%, transparent);
}

.hx-cell.is-p1.is-win-path::before {
  box-shadow:
    inset 0 0 0 2px #ecfeff,
    0 0 16px color-mix(in srgb, #22d3ee 55%, transparent);
}

.hx-cell.is-p2.is-win-path::before {
  box-shadow:
    inset 0 0 0 2px #fdf4ff,
    0 0 16px color-mix(in srgb, #e879f9 55%, transparent);
}

.hx-cell.is-last.is-win-path::before {
  box-shadow:
    inset 0 0 0 2px #fbbf24,
    0 0 14px color-mix(in srgb, #67e8f9 40%, transparent);
}

.hx-stone {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 58%;
  height: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.hx-stone--p1,
.hx-stone--p2 {
  opacity: 1;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.35);
}

.hx-stone--p1 {
  background: linear-gradient(160deg, #67e8f9 0%, #22d3ee 45%, #0891b2 100%);
}

.hx-stone--p2 {
  background: linear-gradient(160deg, #f0abfc 0%, #e879f9 45%, #a21caf 100%);
}

.hx-cell.is-win-path .hx-stone--p1,
.hx-cell.is-win-path .hx-stone--p2 {
  box-shadow:
    0 0 10px color-mix(in srgb, currentColor 35%, transparent),
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.45);
  filter: brightness(1.08);
}

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

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

@media (max-width: 380px) {
  .hx-board-wrap {
    --hx-size: clamp(16px, calc((100vw - 36px) / 12), 28px);
  }

  .hx-board-frame {
    padding: 12px 8px 14px;
    border-radius: 12px;
  }

  .hx-status {
    padding: 10px 12px;
  }

  .hx-guide {
    font-size: 0.82rem;
  }

  .hx-legend {
    font-size: 0.74rem;
    gap: 8px 12px;
  }
}

@media (min-width: 720px) {
  .hx-board-wrap {
    --hx-size: clamp(28px, 3.2vw, 36px);
  }
}

/* 共通プレイ画面。六角形の寸法だけ盤面の幅・高さに合わせる。 */
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 .game-controls { width: 100%; max-width: 640px; flex: none; }
html.gs-playing .gs-bar { gap: 10px; }
html.gs-playing .hx-settings { flex: 1; max-width: none; margin: 0; }
html.gs-playing .hx-settings .field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html.gs-playing .option-tabs { max-width: none; }
html.gs-playing .option-tabs {
  gap: 6px;
}

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;
}
html.gs-playing .status-pill { padding: 0; background: none; color: var(--play-accent); font-size: 1rem; }
html.gs-playing .status-pill.is-p2,
html.gs-playing .status-pill.is-lose { color: #f0abfc; }
html.gs-playing .hx-status__text { flex: none; height: 3em; line-height: 1.5; margin: 0 0 10px; color: var(--play-text); text-align: center; font-size: .8125rem; }
html.gs-playing .hx-legend { flex: none; max-width: 640px; margin: 0 auto 12px; gap: 4px 12px; color: var(--play-text-muted); font-size: .75rem; }
html.gs-playing .hx-board-wrap {
  position: relative;
  flex: none;
  width: min(100%, max(250px, calc((100dvh - 390px) * 1.15)));
  max-width: 460px;
  container-type: inline-size;
  margin: 0;
}
html.gs-playing .hx-board-frame {
  --hx-size: min(36px, calc((100cqw - 28px) / 11.5));
  --hx-w: var(--hx-size);
  --hx-h: calc(var(--hx-size) * 1.1547);
  --hx-row-gap: calc(var(--hx-h) * -0.25);
  padding: 14px 12px 16px;
}
html.gs-playing .hx-guide { flex: none; max-width: 640px; min-height: 3em; margin: 10px 0; color: var(--play-text-muted); font-size: .75rem; }
html.gs-playing .game-controls { justify-content: center; margin: 0; }
html.gs-playing .hx-result { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; justify-content: center; align-items: center; margin: 0; border: 1px solid var(--play-border); background: rgba(8, 15, 31, .95); color: var(--play-text); }
html.gs-playing .hx-result__detail { color: var(--play-text-muted); }
@media (min-width: 720px) and (min-height: 650px) {
  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: 24px; }
  html.gs-playing .game-panel > .gs-hud { margin-bottom: 18px; }
  html.gs-playing .hx-legend { margin-bottom: 16px; }
  html.gs-playing .hx-board-wrap { width: min(100%, max(230px, calc((100dvh - 380px) * 1.15))); }
  html.gs-playing .hx-guide { margin: 16px 0; }
}
@media (max-height: 500px) and (min-width: 640px) {
  html.gs-playing .game-panel { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 300px); grid-template-areas: "bar board" "hud board" "status board" "legend board" "guide controls"; gap: 4px 16px; align-content: start; justify-content: center; }
  html.gs-playing .gs-bar { grid-area: bar; }
  html.gs-playing .gs-hud { grid-area: hud; }
  html.gs-playing .hx-status__text { grid-area: status; }
  html.gs-playing .hx-legend { grid-area: legend; }
  html.gs-playing .hx-board-wrap { grid-area: board; width: min(100%, calc((100dvh - 90px) * 1.15)); }
  html.gs-playing .hx-guide { grid-area: guide; margin: 0; }
  html.gs-playing .game-controls { grid-area: controls; }
}

html.gs-playing .hx-error { position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 4; width: min(90%, 480px); margin: 0; text-align: center; }

@media (max-width: 480px) {
  html.gs-playing .hx-status__text { margin-bottom: 4px; }
  html.gs-playing .hx-legend { margin-bottom: 6px; }
  html.gs-playing .hx-guide { min-height: 3em; margin: 6px 0; }
}
