/* ハグレ色 — シンプル/視覚重視。文字は最小限・小さめ。 */

:root {
  --bg: #0d0f12;
  --panel: #15181c;
  --line: #2a2f36;
  --text: #e7ecf2;
  --muted: #8b95a1;
  --accent: #5db0ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  margin: 0; height: 100%;
  background: #000; color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; align-items: center; justify-content: center; }

.phone {
  position: relative;
  width: 100%; max-width: 440px;
  height: 100vh; height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
@media (min-width: 480px) {
  .phone {
    height: min(880px, 96vh);
    border-radius: 28px;
    box-shadow: 0 0 0 10px #000, 0 24px 60px rgba(0,0,0,0.6);
    margin: 2vh 0;
  }
}

.app { display: flex; flex-direction: column; height: 100%; }

/* 上部バー：スコア＋時間ゲージ（文字は控えめ） */
.bar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
}
.score {
  font-size: 15px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--text); min-width: 56px;
}
.time {
  flex: 1; height: 10px; background: #20242b;
  border-radius: 999px; overflow: hidden;
}
.time-fill {
  width: 100%; height: 100%;
  background: linear-gradient(90deg, #5db0ff, #7ee0c4);
  transition: width 0.08s linear;
}
.mute {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mute:active { background: #20242b; }
.mute.off { opacity: 0.5; }

/* ステージ（正方形のグリッドを中央に） */
.stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 16px 18px 28px;
}
.grid {
  width: min(86vw, 360px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 8px;
  transition: transform 0.05s ease;
}
.tile {
  position: relative;
  border: none; padding: 0; margin: 0;
  border-radius: 12px;
  width: 100%; height: 100%;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.06s ease;
}
.tile:active { transform: scale(0.94); }

/* ゲームオーバー時に正解の場所を赤まるで囲う */
.tile.reveal::after {
  content: "";
  position: absolute; inset: 7%;
  border: 4px solid #ff3b5c;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 59, 92, 0.85), inset 0 0 10px rgba(255, 59, 92, 0.45);
  pointer-events: none;
  animation: revealpop 0.35s ease both;
}
@keyframes revealpop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 「タップして結果を見る」ヒント（結果画面へは手動で進む） */
.advance-hint {
  position: absolute; left: 50%; bottom: 40px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72); color: #fff;
  padding: 10px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  z-index: 15; pointer-events: none;
  animation: hintpulse 1.1s ease-in-out infinite;
}
@keyframes hintpulse {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) translateY(0); }
  50%      { opacity: 1;    transform: translateX(-50%) translateY(-4px); }
}

/* 文字・絵文字・図形タイル */
.tile.glyph {
  background: #20242b;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.tile.glyph span {
  font-size: calc(min(86vw, 360px) / var(--cols, 2) * 0.5);
  line-height: 1;
  display: inline-block;
}

/* 正解/ミスのフィードバック（色のフラッシュ＆シェイク） */
.grid.ok { animation: okflash 0.25s ease; }
.grid.ng { animation: shake 0.3s ease; }
@keyframes okflash { 0% { filter: brightness(1.4); } 100% { filter: none; } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* オーバーレイ */
.overlay {
  position: absolute; inset: 0;
  background: rgba(5,7,10,0.92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 20;
}
.overlay.hidden { display: none; }
.overlay-card {
  width: 100%; max-width: 320px; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 30px 22px;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  animation: pop 0.22s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

.title { font-size: 28px; margin: 0 0 14px; font-weight: 900; letter-spacing: 2px; }
.lead { color: var(--muted); line-height: 1.7; font-size: 14px; margin: 0 0 22px; }
.lead b { color: var(--text); }

/* タイトルの遊び方ミニ図解（文字なしで伝える） */
.demo { display: flex; justify-content: center; gap: 10px; margin: 6px 0 34px; }
.demo-tile {
  width: 36px; height: 36px; border-radius: 9px;
  background: hsl(210, 70%, 55%); position: relative;
}
.demo-tile.odd { background: hsl(210, 70%, 76%); }
.demo-tile.odd::after {
  content: "👆";
  position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%); margin-top: 4px;
  font-size: 20px;
  animation: hintpulse 1.1s ease-in-out infinite;
}

.btn {
  display: block; width: 100%;
  border: none; border-radius: 14px;
  padding: 14px; font-size: 16px; font-weight: 800;
  cursor: pointer; margin-bottom: 10px;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); filter: brightness(1.1); }
.btn-primary { background: var(--accent); color: #04121f; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:last-child { margin-bottom: 0; }

/* 称号 */
.rate-emoji { font-size: 56px; line-height: 1; margin-bottom: 6px; }
.rate-label { font-size: 24px; font-weight: 900; margin-bottom: 2px; }
.rate-score { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* ランキング登録 */
.reg { display: flex; gap: 8px; margin-bottom: 14px; }
.name-input {
  flex: 1; min-width: 0;
  background: #0d0f12; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 15px;
}
.name-input::placeholder { color: #5b6470; }
.reg .btn { width: auto; white-space: nowrap; margin-bottom: 0; padding: 12px 14px; font-size: 14px; }
.reg-done { background: #16271d; color: #7ee0c4; border-radius: 12px; padding: 12px; font-size: 14px; margin-bottom: 14px; }
.reg-done b { color: #fff; }

/* ランキング表 */
.board { margin-bottom: 16px; text-align: left; }
.board-title { font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-bottom: 8px; text-align: center; }
.board-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 8px 0; }
.board-list { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.board-list li {
  counter-increment: rank;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 10px; font-size: 14px;
}
.board-list li::before { content: counter(rank); width: 20px; color: var(--muted); font-weight: 800; }
.board-list li .bn { flex: 1; margin: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .bs { font-variant-numeric: tabular-nums; font-weight: 700; }
.board-list li.mine { background: rgba(93,176,255,0.14); }
.board-list li:nth-child(1) .bs { color: #ffd35b; }
