/* ===== games.hacci.dev 共通スタイル ===== */
:root {
  --bg: #10141c;
  --bg-soft: #171d28;
  --panel: #1e2634;
  --panel-2: #26303f;
  --line: #33405480;
  --fg: #e6ecf5;
  --fg-dim: #93a1b5;
  --accent: #56b6f2;
  --accent-2: #f2a154;
  --danger: #e2606b;
  --ok: #57c98a;
  --radius: 12px;
  --shadow: 0 6px 24px #0006;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, #1d2740 0%, transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic UI", "Meiryo", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

a { color: var(--accent); }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* --- ヘッダ --- */
.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #0d111899;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.site-header .home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: .02em;
}
.site-header .home .mark {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: linear-gradient(140deg, var(--accent), #7d6cf0);
  color: #08111c; font-weight: 900; font-size: 13px;
}
.site-header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  color: var(--fg-dim);
}
.site-header h1::before { content: "/ "; opacity: .5; }

/* --- ボタン類 --- */
button, .btn {
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .12s, transform .06s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover, .btn:hover { background: #32405480; border-color: #4a5b76; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary {
  background: linear-gradient(150deg, var(--accent), #4a86e8);
  border-color: transparent;
  color: #06121e;
  font-weight: 700;
}
button.primary:hover { filter: brightness(1.08); background: linear-gradient(150deg, var(--accent), #4a86e8); }

select {
  font: inherit; font-size: 14px;
  color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
}

/* --- ツールバー / ステータス --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.spacer { flex: 1 1 auto; }

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 84px;
  text-align: center;
}
.stat .label { display: block; font-size: 11px; color: var(--fg-dim); letter-spacing: .08em; }
.stat .value { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.board-area {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
}

.hint-text {
  color: var(--fg-dim);
  font-size: 13px;
  margin-top: 18px;
}
.hint-text kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: inherit;
}

/* --- 勝敗オーバーレイ --- */
.overlay {
  position: fixed;
  inset: 0;
  background: #060a12cc;
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.overlay[hidden] { display: none; }
.overlay .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 32px;
  text-align: center;
  max-width: 340px;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0 } to { transform: none; opacity: 1 } }
.overlay .card h2 { margin: 0 0 6px; font-size: 24px; }
.overlay .card p { margin: 0 0 18px; color: var(--fg-dim); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ===== スマートフォン向け ===== */
@media (max-width: 640px) {
  .wrap { padding: 12px 8px 34px; }
  .site-header { padding: 10px 12px; gap: 8px; }
  .site-header .home { font-size: 14px; }
  .site-header h1 { font-size: 13px; }
  .toolbar { gap: 6px; margin: 10px 0; }
  .stats { gap: 6px; }
  .stat { min-width: 58px; padding: 4px 9px; }
  .stat .label { font-size: 10px; letter-spacing: .04em; }
  .stat .value { font-size: 17px; }
  button, .btn, select { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
  .hint-text { font-size: 12px; margin-top: 12px; }
  .overlay .card { padding: 22px 22px; }
}

/* 横向き（高さの狭い画面）では余白と説明を削ってできるだけ盤面に使う */
@media (orientation: landscape) and (max-height: 520px) {
  .site-header { position: static; padding: 4px 10px; }
  .site-header .home { font-size: 13px; }
  .site-header h1 { font-size: 12px; }
  .wrap { padding: 4px 8px 8px; }
  .toolbar { margin: 5px 0; gap: 6px; }
  .hint-text { display: none; }
  .rotate-hint { display: none; }
  .stat { padding: 2px 8px; min-width: 50px; }
  .stat .label { font-size: 9px; }
  .stat .value { font-size: 14px; }
  button, .btn, select { font-size: 12px; padding: 5px 9px; }
}

/* タッチ操作の誤爆防止 */
.board, .tile, .piece, .cell, .pcard, .slot {
  -webkit-touch-callout: none;
}

/* 縦持ちのときだけ出す「横向き推奨」バナー */
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  .rotate-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 4px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f2a1541a;
    color: var(--fg-dim);
    font-size: 13px;
    line-height: 1.5;
  }
  .rotate-hint .icon { font-size: 20px; }
}
