/* アリ帝国 水分けパズル攻略ツール スタイル */
:root {
  --bg: #14201b;
  --bg2: #1d2c25;
  --card: #233a30;
  --card2: #2c463a;
  --line: #3a5848;
  --text: #e8f0ea;
  --muted: #9bb3a6;
  --accent: #7bdc9a;
  --accent-d: #4cae73;
  --danger: #e06b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #21342b, var(--bg)) fixed;
  color: var(--text);
  line-height: 1.6;
  /* スマホでボタン連打がダブルタップ拡大になるのを防ぐ（ピンチ拡大は残す） */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  text-align: center;
  padding: 22px 16px 6px;
}
.app-header h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 14px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--accent-d);
  color: #07130c;
  border-radius: 50%;
  font-size: .9rem;
  font-weight: 700;
}

.hint { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }

/* ボタン */
.btn {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: .9rem;
  cursor: pointer;
  transition: .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { background: #355544; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #06140d; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: #93e7ad; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ドロップゾーン */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px 16px;
  text-align: center;
  transition: .2s;
}
.drop-zone.drag { border-color: var(--accent); background: rgba(123,220,154,.08); }
.drop-text { margin: 0; }
.preview-wrap { margin-top: 14px; text-align: center; }
.preview-wrap canvas {
  max-width: 100%;
  max-height: 340px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* 設定 */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 560px) {
  .settings-grid { grid-template-columns: 1.4fr 1fr 1fr; align-items: end; }
}
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.field input[type="number"] {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 1rem;
}
.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .82rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.seg-btn.active { background: var(--accent-d); color: #06140d; border-color: var(--accent-d); font-weight: 700; }

/* パレット */
.palette-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 16px;
  align-items: center;
}
.swatch {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
/* 選択中の色を微調整する入力（パレットとは別の行に分離） */
.color-edit {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: var(--muted); margin-top: 4px;
}
.color-edit input[type="color"] {
  width: 42px; height: 30px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: none; cursor: pointer;
}
.swatch.special {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: var(--text);
  background: var(--bg2); border: 2px solid var(--line);
}
.swatch.special.active { border-color: var(--accent); }
.swatch.unknown { background: repeating-linear-gradient(45deg,#5a3a28,#5a3a28 6px,#704a34 6px,#704a34 12px); color:#fff; }

/* 盤面: 試験管は横6列で固定＋中央寄せ（ゲーム画面と同じ並び。端数の行も中央に） */
.board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 8px;
  padding: 10px 4px;
}
.tube-wrap {
  width: calc((100% - 41px) / 6); /* 6列固定（列間8px×5=40px＋誤差吸収1px） */
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tube {
  width: 100%;
  max-width: 46px;
  border: 3px solid #cfe6d8;
  border-top: none;
  border-radius: 8px 8px 22px 22px;
  background: rgba(255,255,255,.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tube .cell {
  width: 100%;
  border-top: 1px solid rgba(0,0,0,.18);
  cursor: pointer;
  transition: background .1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tube .cell:first-child { border-top: none; }
.tube .cell.empty { background: transparent; }
.tube .cell.unknown {
  background: repeating-linear-gradient(45deg,#5a3a28,#5a3a28 7px,#73513b 7px,#73513b 14px);
}
.tube.done { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(123,220,154,.4); }
.tube.highlight-from { border-color: #ffd166; box-shadow: 0 0 10px #ffd166; }
.tube.highlight-to { border-color: #6fb1ff; box-shadow: 0 0 10px #6fb1ff; }
/* 操作対象でない試験管は暗くして「今は触らない」と分かるように */
.tube.dimmed { opacity: .3; filter: saturate(.6); transition: opacity .2s; }
/* ブラインドで「出てきた色を入力するマス」を強調 */
.tube .cell.reveal-target {
  box-shadow: inset 0 0 0 3px #ffd166;
  animation: revealPulse 1s ease-in-out infinite;
}
@keyframes revealPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.55); }
}
.tube-label { font-size: .72rem; color: var(--muted); }
.tube-del {
  font-size: .68rem; color: var(--danger); cursor: pointer; background: none; border: none; padding: 0;
}

.board-actions, .solve-actions {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px;
}

/* 解 */
.status { margin-top: 12px; font-size: .9rem; min-height: 1.2em; }
.status.ok { color: var(--accent); }
.status.warn { color: #ffd166; }
.status.err { color: var(--danger); }

.step-nav {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 6px;
}
.step-label { font-weight: 700; min-width: 96px; text-align: center; }
.board.mini .tube { max-width: 38px; }
.move-text { text-align: center; font-size: 1.05rem; font-weight: 700; margin: 6px 0 10px; min-height: 1.4em; }
.move-list {
  max-height: 240px; overflow-y: auto;
  margin: 8px 0 0; padding-left: 28px; font-size: .9rem; color: var(--muted);
}
.move-list li { padding: 3px 0; cursor: pointer; }
.move-list li.current { color: var(--accent); font-weight: 700; }
.move-list li:hover { color: var(--text); }

.app-footer { text-align: center; color: var(--muted); font-size: .76rem; padding: 0 16px 30px; }
