/* すべての要素でサイズ計算を扱いやすくし、タップ時の強調表示を消します。 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* ページ全体の高さを画面いっぱいに使えるようにします。 */
html {
  margin: 0;
  height: 100%;
}

/* ゲーム画面をブラウザ中央に配置します。 */
body {
  margin: 0;
  height: 100vh;
  font-family: sans-serif;
  background: #101426;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ゲーム全体の外枠です。 */
.container {
  margin: 0 auto;
  background: #060817;
  border: 2px solid #252a58;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* 上部のタイトルバーです。 */
.game-header {
  height: 50px;
  padding: 0 14px;
  background: #0b1024;
  border-bottom: 1px solid #252a58;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
}

/* ヘッダー内の情報を中央に寄せます。 */
.info {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-weight: bold;
}

/* ヘッダーに表示する説明文です。 */
.header-title {
  color: #f6e7ff;
  font-size: 18px;
  text-align: center;
  white-space: nowrap;
}

/* ゲームのメイン領域です。背景に星空を描いています。 */
.game-main {
  position: relative;
  background:
    radial-gradient(1px 1px at 8% 16%, #fff 99%, transparent),
    radial-gradient(1px 1px at 18% 62%, rgba(255, 255, 255, .7) 99%, transparent),
    radial-gradient(1px 1px at 33% 24%, rgba(255, 255, 255, .8) 99%, transparent),
    radial-gradient(1px 1px at 48% 76%, rgba(255, 255, 255, .6) 99%, transparent),
    radial-gradient(1px 1px at 66% 18%, #fff 99%, transparent),
    radial-gradient(1px 1px at 82% 48%, rgba(255, 255, 255, .7) 99%, transparent),
    radial-gradient(1px 1px at 94% 82%, #fff 99%, transparent),
    linear-gradient(180deg, #070a19 0%, #111836 100%);
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
}

/* ゲーム内で共通して使うボタンの基本デザインです。 */
.btn {
  padding: 12px 28px;
  font-size: 18px;
  font-weight: bold;
  border: 0;
  border-radius: 999px;
  background: #fbbf24;
  color: #1f1600;
  cursor: pointer;
  box-shadow: 0 4px 0 #a65312;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}

/* マウスを重ねたときにボタンを少し明るくします。 */
.btn:hover {
  background: #fcd34d;
}

/* ボタンを押したときに少し沈むように見せます。 */
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a65312;
}

/* ゲーム開始後に表示する操作パネルです。 */
.game-panel {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px 28px;
  position: relative;
}

/* まだ置いていない惑星カードを並べる場所です。 */
.source-area {
  width: fit-content;
  max-width: 100%;
  min-height: 100px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  background: rgba(255, 255, 255, .04);
  border: 2px dashed #313b78;
  border-radius: 8px;
  flex: 0 0 auto;
}

/* すべての惑星を置いた後は、空の破線枠だけが見えないようにします。 */
.source-area:empty {
  visibility: hidden;
}

/* 並べる方向を示す「ちいさい」「おおきい」のラベルです。 */
.label-row {
  width: min(100%, 1060px);
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  color: #8395d4;
  font-size: 12px;
  font-weight: bold;
  flex: 0 0 0;
  line-height: 1;
  position: relative;
  transform: translateY(70px);
  z-index: 2;
  pointer-events: none;
}

/* 右側の「おおきい」ラベルを少し大きくします。 */
.label-row span:last-child {
  font-size: 15px;
}

/* 惑星カードを置くスロット全体の並びです。 */
.slots-area {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  flex: 0 0 auto;
}

/* 1つ分の答え枠です。 */
.slot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 104px;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #34428a;
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

/* ドラッグ中のカードが重なった答え枠を強調します。 */
.slot.drag-over {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, .12);
}

/* 正解だった答え枠の見た目です。 */
.slot.correct-slot {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, .22);
  box-shadow: inset 0 0 0 2px rgba(251, 191, 36, .55), 0 0 18px rgba(251, 191, 36, .45);
}

/* 不正解だった答え枠の見た目です。 */
.slot.wrong-slot {
  border-color: #f87171;
  background: rgba(248, 113, 113, .18);
  box-shadow: inset 0 0 0 2px rgba(248, 113, 113, .5), 0 0 18px rgba(248, 113, 113, .3);
}

/* 答え枠の右下に表示する番号です。 */
.slot-num {
  position: absolute;
  bottom: 4px;
  right: 6px;
  color: #8395d4;
  font-size: 11px;
  font-weight: bold;
}

/* 惑星1つ分のカードです。 */
.planet-card {
  width: 88px;
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  cursor: grab;
  touch-action: none;
  transition: transform .12s ease, opacity .12s ease;
}

/* カードにマウスを重ねたときに少し浮かせます。 */
.planet-card:hover {
  transform: translateY(-2px);
}

/* ドラッグしている元のカードを薄くします。 */
.planet-card.dragging {
  opacity: .25;
  cursor: grabbing;
}

/* 惑星を描くSVGの大きさをカード内に収めます。 */
.planet-card svg {
  display: block;
  max-width: 76px;
  height: auto;
  overflow: visible;
}

/* 惑星名の文字です。 */
.p-name {
  color: #edf2ff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

/* 答え合わせ前後のメッセージ表示欄です。 */
.judge-msg {
  min-height: 24px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  flex: 0 0 auto;
}

/* 正解メッセージの色です。 */
.judge-msg.correct {
  color: #fbbf24;
}

/* 不正解や未配置メッセージの色です。 */
.judge-msg.wrong {
  color: #f87171;
}

/* 答えるボタン専用の大きさ調整です。 */
.answer-btn {
  margin-top: 6px;
  padding: 10px 36px;
  font-size: 18px;
  flex: 0 0 auto;
}

/* 判定後に「もういちど」ボタンになったときの色です。 */
.answer-btn.restart-mode {
  background: #34d399;
  color: #062013;
  box-shadow: 0 4px 0 #047857;
}

/* 「もういちど」ボタンにマウスを重ねたときの色です。 */
.answer-btn.restart-mode:hover {
  background: #6ee7b7;
}

/* 「もういちど」ボタンを押したときの影です。 */
.answer-btn.restart-mode:active {
  box-shadow: 0 1px 0 #047857;
}

/* 画面幅が狭いときの調整です。 */
@media (max-width: 768px) {
  /* ヘッダー左右の余白を小さくします。 */
  .game-header {
    padding: 0 10px;
  }

  /* 小さい画面ではタイトル文字を少し小さくします。 */
  .header-title {
    font-size: 14px;
  }

  /* 操作パネルの余白を小さくします。 */
  .game-panel {
    padding: 8px 8px;
    gap: 5px;
  }

  /* 惑星カード置き場を小さい画面向けに詰めます。 */
  .source-area {
    min-height: 96px;
    gap: 5px;
  }

  /* 答え枠を折り返して表示できるようにします。 */
  .slots-area {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* 折り返し時にラベルの位置を合わせます。 */
  .label-row {
    transform: translateY(48px);
  }

  /* 小さい画面用の答え枠サイズです。 */
  .slot {
    flex: 1 1 calc(25% - 4px);
    max-width: none;
    height: 82px;
  }

  /* 小さい画面用のカードサイズです。 */
  .planet-card {
    width: 64px;
    min-height: 66px;
  }

  /* 小さい画面用の惑星SVGサイズです。 */
  .planet-card svg {
    max-width: 54px;
  }

  /* 小さい画面用の惑星名サイズです。 */
  .p-name {
    font-size: 10px;
  }

}
