/* narabe (並べ) - 色のグラデーションを並べ直すタップ式パズル */

:root {
  --bg: #20212b;
  --panel: #2a2c3a;
  --text: #e8e6f0;
  --text-dim: #9a97ab;
  --accent: #d9b26f;
  --complete: #84a59d;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  transition: opacity 0.3s ease;
}

/* journey 再生中は盤面と棒グラフ以外を薄く暗くする。
   フィルターボタンは journey 中も押せるので対象外にする。
   journey ボタン（再生中は stop）は Complete パネル内にあるが、中断に使うので
   パネル全体ではなく他の要素だけを暗くする（パネルに pointer-events:none を
   掛けると stop が押せなくなる）。 */
#app.journey-dim #giveup-button,
#app.journey-dim #complete-text,
#app.journey-dim #complete-stats,
#app.journey-dim #restart-button {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ========================================
   タイトル
   ======================================== */

#game-title {
  font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.4em;
  text-indent: 0.4em; /* letter-spacing 分の中央ずれ補正 */
  color: var(--text-dim);
  margin: 8px 0 20px;
}

/* ========================================
   盤面
   ======================================== */

#board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

#board {
  position: relative;
  width: min(92vw, 420px);
  height: min(92vw, 420px);
  background: var(--panel);
  border-radius: 16px;
  padding: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.tile {
  position: absolute;
  /* opacity の 0.3s は game.js の CONFIG.journeyResetMs と手動で同期している
     （yose と同じ手動同期方式）。変更する場合は両方合わせること。 */
  transition: top .32s cubic-bezier(.45,0,.55,1), left .32s cubic-bezier(.45,0,.55,1), opacity 0.3s ease, filter 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile.tile-nomove {
  transition: none;
}

.tile.tile-fading {
  opacity: 0;
}

.tile.tile-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  opacity: 1;
  animation: flash-fade 0.2s ease forwards;
}

@keyframes flash-fade {
  from { opacity: 0.75; }
  to   { opacity: 0; }
}

/* journey 中は rAF が直接 left/top/transform を書き換えるため通常の transition を切る */
.tile.tile-journeying {
  transition: none;
  z-index: 5;
}

/* ========================================
   完成パネル（盤面は隠さない）
   ======================================== */

#complete-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

#complete-panel.hidden {
  display: none;
}

#complete-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--complete);
}

#complete-stats {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

#complete-buttons {
  display: flex;
  gap: 12px;
}

#restart-button,
#journey-button {
  padding: 10px 24px;
  font-size: 15px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #2a2410;
  font-weight: 600;
  cursor: pointer;
}

#journey-button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

#restart-button:active,
#journey-button:active {
  transform: scale(0.97);
}

/* ========================================
   途中リスタート（yose と同じ配置: 画面右上に小さく）
   / hint（左右対称に画面左上に小さく）
   ======================================== */

#giveup-button {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  padding: 6px 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-dim);
  opacity: 0.6;
  cursor: pointer;
}

#giveup-button {
  right: 16px;
}



/* ========================================
   色フィルターボタン（盤面のすぐ下、棒グラフの下に大きめに配置）
   ======================================== */

#filter-button {
  margin-top: 18px;
  min-height: 44px;
  min-width: 100px;
  padding: 10px 32px;
  font-size: 15px;
  letter-spacing: 0.08em;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
}

#filter-button:active {
  transform: scale(0.97);
}

/* narabete: black velvet tray and identical cushion-cut rings. */
:root { --bg:#10100f; --panel:#171715; --text-dim:#b0a99c; --accent:#d3bd94; }
#game-title {margin-bottom:12px;}
#play-stats {font-size:12px; letter-spacing:.12em; color:var(--text-dim); margin-bottom:18px; font-variant-numeric:tabular-nums;}
#board {padding:12px; border-radius:9px; background-color:#090a08;
 background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' opacity='.095' filter='url(%23n)' d='M0 0h140v140H0z'/%3E%3C/svg%3E"),radial-gradient(ellipse at 35% 10%,#20231b00,#000b);
 box-shadow:inset 0 0 0 3px #28291f,inset 0 0 0 7px #11130e,inset 0 0 22px 10px #000,0 10px 35px #000b;}
.tile {cursor:pointer; background:transparent; border:0; padding:0;}
.tile svg {width:100%; height:100%; overflow:visible; pointer-events:none; transform:rotate(var(--tilt,0deg)); transition:none; filter:drop-shadow(1px 4px 2px #000);}
.tile.tile-fixed {box-shadow:none;}
.tile.tile-selected {box-shadow:none; z-index:3;}
.tile.tile-selected svg {transform:rotate(var(--tilt,0deg));}
.tile.tile-selected::before {content:''; position:absolute; inset:-12%; border-radius:50%; background:radial-gradient(circle,rgba(231,216,177,.48) 0%,rgba(231,216,177,.4) 42%,rgba(231,216,177,.18) 59%,rgba(231,216,177,0) 73%); pointer-events:none;}
.tile svg {position:relative; z-index:1;}
.tile-shake svg {animation:fixed-shake .3s ease;}
@keyframes fixed-shake {0%,100%{translate:0;}25%{translate:-3px;}50%{translate:3px;}75%{translate:-2px;}}
.tile.tile-flash::after {inset:15%; border-radius:30%; pointer-events:none;}
@media(prefers-reduced-motion:reduce){.tile,.tile svg{transition:none;} .tile-shake svg{animation-duration:.1s;}}

.tile.tile-swapping svg {transition:transform .32s cubic-bezier(.45,0,.55,1);}
.tile.tile-nomove svg,.tile.tile-journeying svg {transition:none;}
