/* style.css — 段階4（統合フロント） */

:root {
  --board-size: 330px;
  --gap: 3px;
  --accent: #e83030;
  --bg: #fafafa;
  --text: #333;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { max-width: 420px; margin: 0 auto; padding: 16px; min-height: 100vh; }

.screen { display: none; }
.screen.active { display: block; }

h1 { font-size: 20px; margin: 8px 0 16px; }
p { line-height: 1.7; }
.muted { color: #999; font-size: 14px; }
.fineprint { font-size: 13px; color: #999; text-align: center; }

.center {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.spinner {
  width: 36px; height: 36px;
  border: 4px solid #ddd;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.message-text { font-size: 16px; line-height: 1.9; }

.notice {
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 28px;
  cursor: pointer;
  width: 100%;
  margin-top: 16px;
}
button:active { opacity: 0.85; }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: #eee; color: #333; }

/* プレイHUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.hud .elapsed { font-size: 22px; font-weight: 700; }
.hud .remain { font-size: 14px; color: #888; }
.hud .remain.danger { color: var(--accent); font-weight: 700; }

/* 盤面 */
.board {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
  touch-action: manipulation;
}
.hint-layer {
  position: absolute;
  inset: 0;
  background-image: var(--image-url);
  background-size: 100% 100%;
  filter: grayscale(1);
  opacity: 0.18;
  display: none;
}
.board.show-hint .hint-layer { display: block; }

.piece {
  position: absolute;
  width: calc((var(--board-size) - var(--gap) * 2) / 3);
  height: calc((var(--board-size) - var(--gap) * 2) / 3);
  background-image: var(--image-url);
  background-size: var(--board-size) var(--board-size);
  border-radius: 4px;
  transition: left 0.12s ease, top 0.12s ease;
  cursor: pointer;
  overflow: hidden;
}
.piece.blank { visibility: hidden; cursor: default; }
.piece .num {
  position: absolute;
  right: 4px; bottom: 2px;
  font-size: 14px; font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  display: none;
}
.board.show-numbers .piece .num { display: block; }

/* プレビュー */
.preview-image {
  width: var(--board-size);
  height: var(--board-size);
  margin: 8px auto;
  border-radius: 10px;
  background-size: cover;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.preview-count { text-align: center; font-size: 14px; color: #888; margin-top: 8px; }

/* 結果 */
.result-card { text-align: center; padding: 24px 0; }
.result-card .big {
  font-size: 40px; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.result-card .label { font-size: 14px; color: #888; }

/* プレイ画面の操作説明 */
.play-hint {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-top: 14px;
}

/* 全画面共通フッタ */
.app-footer { margin-top: 32px; padding-bottom: 16px; }
.app-footer-line { border-top: 1px solid #ddd; }
.app-footer-text {
  text-align: center;
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

/* 履歴 */
.history-list { margin: 8px 0; }
.history-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}
.history-row .hdate { color: #666; }
.history-row .hres { font-weight: 700; }
