/* ==========================================
   1. 全体リセット & 画面固定 (dvh中央寄せ)
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  text-align: center;
  background: #212121 url("/common/image01.webp") no-repeat center / cover fixed;
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  overflow-x: hidden;
}

body .bgm-btn:focus,
body .size-btn:focus,
body .manual-btn:focus,
body .reset-btn:focus {
  outline: none;
  box-shadow: none;
}

.ui-container {
  width: min(1280px, 95vw);
  margin: 0 auto;
  position: relative;
  padding: 20px 0;
}

/* ==========================================
   2. タイトルエリア (緑ネオン管仕様)
   ========================================== */
.title-area h1 {
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 8px 0;
  background-color: rgba(0, 32, 16, 0.85);
  color: #00ffcc;
  border-radius: 9999px;
  text-shadow: 0 0 10px rgba(0, 255, 204, 0.6);
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.8),
    inset 0 0 15px rgba(0, 255, 204, 0.2);
  border: 1px solid #00bfa5;
}

/* ==========================================
   3. 左右2分割メーターUI
   ========================================== */
.status-area {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.status-info {
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  font-weight: bold;
  color: #e0e0e0;
  text-align: left;
  padding-left: 4px;
  white-space: pre-line;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ==========================================
   4. フィールドエリア & レイヤー構造 (16:9ワイド)
   ========================================== */
.field-area {
  position: relative;
  width: min(1280px, 90vw);
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border-radius: 14px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8);
  border: 6px solid #37474f;
  overflow: hidden;
}

.bg-layer,
.fx-layer,
.core-layer,
.card-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.bg-layer {
  z-index: 1;
  background-color: #212121;
}

/* レイヤー2: 特殊効果レイヤー（下地画像） */
.fx-layer {
  z-index: 2;
  pointer-events: none;
  background-image: url("../img/img01.webp");
  background-size: 100% 100%;
  opacity: 0.25;
}

/* レイヤー3: パズルメインコア（4x4固定グリッド） */
.core-layer {
  z-index: 3;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  background-color: transparent;
  gap: 1px;
  transition: opacity 1s ease;
}

/* ==========================================
   5. マス目 (セル) & スライドアニメーション
   ========================================== */
.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background-color: transparent;
  border: 1px solid rgba(0, 255, 204, 0.1);
  margin: -1px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 動かせるピースにマウスが乗ったとき、緑色のネオン枠でアタリをつけさせる */
.cell.movable {
  cursor: pointer;
  border-color: rgba(0, 255, 204, 0.5);
  box-shadow: inset 0 0 8px rgba(0, 255, 204, 0.3);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

/* 正解位置にハマっているピース（動かせなくても正解なら薄くガイド） */
.cell.correct:not(.empty-cell) {
  border-color: rgba(0, 255, 204, 0.25);
}

/* 空白のマス（ピースがない虚無空間） */
.cell.empty-cell {
  background-color: rgba(0, 0, 0, 0.6);
  border: 1px dashed rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
}

/* 🎯 完成時（solved）に枠線を消し去る美しきエフェクト */
.core-layer.solved .cell {
  border-color: transparent !important;
  box-shadow: none !important;
  transition:
    border-color 1s ease,
    box-shadow 1s ease;
}

/* ==========================================
   6. パズルピース (../img/img02.webp を4x4分割)
   ========================================== */
.piece {
  width: 100%;
  height: 100%;
  background-image: url("../img/img02.webp");
  background-size: 400% 400%;
  background-repeat: no-repeat;
  user-select: none;
  transition: transform 0.15s ease-out;
}

/* ==========================================
   7. 操作ボタン
   ========================================== */
.reset-btn,
.manual-btn {
  width: 110px;
  padding: 8px 0;
  font-size: 0.95rem;
  font-weight: bold;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-block;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.2s,
    transform 0.1s,
    box-shadow 0.2s,
    text-shadow 0.2s;
}
.reset-btn:active,
.manual-btn:active {
  transform: scale(0.95);
}
.reset-btn {
  background-color: rgba(211, 47, 47, 0.2);
  border: 1px solid #ff8a80;
  color: #ff8a80;
  text-shadow: 0 0 5px rgba(255, 138, 128, 0.6);
  box-shadow:
    0 0 10px rgba(255, 138, 128, 0.3),
    inset 0 0 5px rgba(255, 138, 128, 0.2);
}
.reset-btn:hover {
  background-color: #b71c1c;
  color: #ffffff;
  box-shadow:
    0 0 20px rgba(255, 138, 128, 0.8),
    0 0 30px rgba(255, 138, 128, 0.4);
}
.manual-btn {
  background-color: rgba(26, 115, 232, 0.2);
  border: 1px solid #4fc3f7;
  color: #4fc3f7;
  text-shadow: 0 0 5px rgba(79, 195, 247, 0.6);
  box-shadow:
    0 0 10px rgba(79, 195, 247, 0.3),
    inset 0 0 5px rgba(79, 195, 247, 0.2);
}
.manual-btn:hover {
  background-color: #1557b0;
  color: #ffffff;
  box-shadow:
    0 0 20px rgba(79, 195, 247, 0.8),
    0 0 30px rgba(79, 195, 247, 0.4);
}

/* ==========================================
   8. カードレイヤー（説明書）
   ========================================== */
.card-layer {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: 80%;
  height: 80%;
  background: rgba(0, 20, 10, 0.75);
  border: 2px solid #00ffcc;
  padding: 24px;
  border-radius: 8px;
  box-shadow:
    inset 0 0 25px rgba(0, 255, 204, 0.4),
    0 0 30px rgba(0, 255, 204, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  transition:
    opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.34, 1.8, 0.64, 1);
}
.card-layer.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.title-card {
  font-size: 1.1rem;
  font-weight: bold;
  color: #00ffcc;
  border-bottom: 2px dashed rgba(0, 255, 204, 0.5);
  padding-bottom: 8px;
  margin-bottom: 16px;
  letter-spacing: 2px;
  font-family: "Courier New", monospace;
  text-align: left;
}
.line-card {
  font-size: 0.85rem;
  color: #a7ffeb;
  margin: 12px 0;
  font-family: "Courier New", Courier, monospace;
  line-line-height: 1.5;
  text-align: left;
}
.powered-card {
  font-size: 0.65rem;
  font-family: "Courier New", monospace;
  letter-spacing: 3px;
  color: rgba(0, 255, 204, 0.4);
  text-align: right;
  margin-top: 24px;
  text-shadow: 0 0 4px rgba(0, 255, 204, 0.3);
  text-transform: uppercase;
}
.scanline-card {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0.3;
}

/* ==========================================
   9. スマホレスポンシブ
   ========================================== */
@media (max-width: 480px) {
  .status-area {
    margin: 8px 0;
  }
  .title-area h1 {
    font-size: 1rem;
    padding: 6px 0;
  }
  .field-area {
    width: 95vw;
  }
  .reset-btn,
  .manual-btn {
    font-size: 0.75rem;
    width: 80px;
    padding: 6px 0;
  }
  .status-info {
    font-size: 0.75rem;
  }
  .title-card {
    font-size: 0.9rem;
    margin-bottom: 8px;
    padding-bottom: 4px;
  }
  .line-card {
    font-size: 0.7rem;
    margin: 6px 0;
    line-height: 1.3;
  }
  .powered-card {
    font-size: 0.55rem;
    margin-top: 12px;
  }
}
