/* ASTRA RAID固有スタイル */

.gs-stage {
  position: relative;
  width: 100%;
  max-width: min(100%, 480px);
  margin: 0 auto 12px;
}

.gs-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 480 / 560;
  border: 1px solid rgba(96, 154, 214, 0.35);
  border-radius: var(--md-sys-shape-corner-large);
  background: #0b1530;
  box-shadow: 0 14px 34px rgba(28, 52, 96, 0.24);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.gs-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  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(10, 18, 40, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  text-align: center;
  animation: gs-fade 180ms ease-out;
}

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

.gs-overlay__title {
  margin: 0;
  color: #ffffff;
  font-family: "Outfit", "Noto Sans JP", sans-serif;
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.gs-overlay.is-ready .gs-overlay__title {
  color: #a8f0ff;
  text-shadow: 0 0 18px rgba(96, 220, 255, 0.7), 0 0 34px rgba(150, 106, 255, 0.45);
}

.gs-overlay.is-over .gs-overlay__title {
  color: #ffc7d3;
  text-shadow: 0 0 18px rgba(255, 107, 138, 0.55);
}

.gs-overlay__detail {
  margin: 0;
  color: rgba(230, 240, 255, 0.86);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.gs-result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 320px);
  margin: 8px 0 0;
}

.gs-result[hidden] {
  display: none;
}

.gs-result__item {
  padding: 8px 4px;
  border: 1px solid rgba(125, 226, 255, 0.28);
  border-radius: var(--md-sys-shape-corner-medium);
  background: rgba(20, 36, 74, 0.7);
}

.gs-result dt {
  color: rgba(200, 225, 255, 0.8);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.gs-result dd {
  margin: 2px 0 0;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gs-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.gs-overlay__actions .btn {
  min-width: 8.5rem;
  justify-content: center;
}

/* タッチ操作ボタンはタッチ主体の端末だけに表示する */
.gs-pad {
  display: none;
  grid-template-columns: 1fr 1fr 1.6fr;
  gap: 8px;
  max-width: min(100%, 480px);
  margin: 0 auto 12px;
}

.gs-pad__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 60px;
  padding: 0 8px;
  overflow: hidden;
  border: 1px solid rgba(96, 154, 214, 0.45);
  border-radius: var(--md-sys-shape-corner-medium);
  background: #13224a;
  color: #cfefff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.gs-pad__icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.gs-pad__btn--fire {
  background: linear-gradient(180deg, #1d4fa0, #173a7a);
  color: #e8fbff;
}

.gs-pad__btn.is-pressed {
  background: #1f3d7c;
  box-shadow: 0 0 0 2px rgba(63, 215, 255, 0.6), 0 0 16px rgba(63, 215, 255, 0.35);
}

.gs-pad__btn--fire.is-pressed {
  background: linear-gradient(180deg, #2a68c8, #1f4e9e);
}

@media (hover: none) and (pointer: coarse) {
  .gs-pad {
    display: grid;
  }
}

.gs-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  max-width: min(100%, 480px);
  margin: 0 auto 8px;
  padding: 0;
  list-style: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
}

.gs-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gs-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(11, 21, 48, 0.25);
}

.gs-legend__swatch--normal { background: #3fd7ff; }
.gs-legend__swatch--fast { background: #ff6fbf; }
.gs-legend__swatch--tough { background: linear-gradient(90deg, #9a86ff 50%, #ffb45e 50%); }

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

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

.game-controls {
  justify-content: center;
  max-width: min(100%, 480px);
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 480px) {
  /* 狭い画面ではカードの内側余白ぶんだけゲーム領域を広げる */
  .gs-stage,
  .gs-pad {
    width: calc(100% + 20px);
    max-width: calc(100% + 20px);
    margin-left: -10px;
    margin-right: -10px;
  }

  .gs-overlay__actions .btn {
    min-width: 7.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gs-overlay {
    animation: none;
  }
}

/* 共通の背景・余白・HUD・ボタンは game-screen.css を使う。
   縦長キャンバスと同時押しパッドだけ、ゲーム固有の寸法で収める。 */
html.gs-playing .game-panel {
  --ar-chrome: 212px;
  display: grid;
  grid-template-columns: minmax(0, 560px);
  grid-template-rows: auto auto auto auto auto;
  grid-template-areas: "bar" "status" "stage" "pad" "controls";
  justify-content: center;
  align-content: start;
}

html.gs-playing .game-panel > .gs-bar { grid-area: bar; }
html.gs-playing .gs-hud { grid-area: status; }
html.gs-playing .ar-stage-area {
  grid-area: stage;
  display: flex;
  justify-content: center;
  width: 100%;
  min-width: 0;
  margin: 0 0 10px;
  container-type: inline-size;
}

html.gs-playing .gs-stage {
  flex: none;
  width: min(100cqw, max(160px, min((100vh - var(--ar-chrome)) * 480 / 560, 480px)));
  width: min(100cqw, max(160px, min((100dvh - var(--ar-chrome)) * 480 / 560, 480px)));
  max-width: none;
  margin: 0;
}

html.gs-playing .gs-pad {
  grid-area: pad;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 10px;
}

html.gs-playing .game-panel .game-controls {
  grid-area: controls;
  justify-self: center;
  width: 100%;
  max-width: 560px;
  justify-content: center;
  gap: 12px;
  margin: 0;
}

@media (hover: none) and (pointer: coarse) {
  html.gs-playing .game-panel { --ar-chrome: 300px; }
}

/* 外側はブロック崩しと同じ最大640px。盤面は縦横比と画面の高さに合わせる。 */
@media (min-width: 768px) and (min-height: 600px) {
  html.gs-playing .game-panel {
    --ar-chrome: 280px;
    grid-template-columns: minmax(0, 640px);
    padding-top: max(clamp(24px, 5vh, 56px), env(safe-area-inset-top));
  }

  html.gs-playing .game-panel > .gs-bar,
  html.gs-playing .gs-hud,
  html.gs-playing .ar-stage-area {
    margin-bottom: 24px;
  }

  html.gs-playing .gs-hud,
  html.gs-playing .game-panel .game-controls {
    max-width: 640px;
  }

  html.gs-playing .gs-stage {
    width: min(100cqw, max(160px, (100dvh - var(--ar-chrome)) * 480 / 560), 640px);
  }

  @media (hover: none) and (pointer: coarse) {
    html.gs-playing .game-panel { --ar-chrome: 370px; }
  }
}

/* パイプパズル同様、低い横画面では戻る・操作を左上、盤面を右へ置く */
@media (orientation: landscape) and (max-height: 500px) {
  html.gs-playing .game-panel {
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "bar stage" "status stage" "pad stage" ". stage";
    column-gap: 16px;
  }
  html.gs-playing .game-panel > .gs-bar { justify-self: start; }
  html.gs-playing .game-panel .game-controls {
    grid-area: bar;
    justify-self: end;
    width: auto;
    margin-bottom: 10px;
  }
  html.gs-playing .ar-stage-area {
    align-items: center;
    min-height: 0;
    margin: 0;
    container-type: size;
  }
  html.gs-playing .gs-stage { width: min(100cqw, 100cqh * 480 / 560, 480px); }
}

/* 縮小したキャンバスでも、結果の数値と再挑戦ボタンを重ねずに読めるようにする */
html.gs-playing .gs-stage { container-type: inline-size; }

@container (max-width: 300px) {
  .gs-overlay { gap: 4px; padding: 12px; }
  .gs-overlay__title { font-size: 1.4rem; }
  .gs-overlay__detail { font-size: .8125rem; line-height: 1.4; }
  .gs-result { gap: 4px; margin-top: 4px; }
  .gs-result__item { padding: 6px 2px; min-width: 0; }
  .gs-result dt { font-size: .625rem; line-height: 1.3; white-space: normal; }
  .gs-result dd { font-size: .8125rem; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
  .gs-overlay__actions { margin-top: 6px; }
}
