/* ============================================================
   Tsunagete Pikmin - Solutions (Unofficial Fan Analysis)
   ============================================================ */

:root {
  --bg: #10121a;
  --bg-alt: #191c28;
  --bg-card: #1f2333;
  --bg-card-hover: #282e43;
  --border: #2a3048;
  --text: #e8ecf5;
  --text-dim: #8b93a8;
  --accent: #f0c020;
  --accent-dim: #9a7a0a;
  --ok: #4ecb71;
  --warn: #f15a5a;
  --jiriki: #e89028;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --font-ja: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ja);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.3; }
h1 { font-size: 1.8rem; color: var(--accent); }
h2 { font-size: 1.3rem; color: var(--text); }
h3 { font-size: 1.05rem; color: var(--text); }

kbd {
  display: inline-block;
  padding: 0.1em 0.5em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
}

/* --------------------- site header --------------------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-brand {
  font-weight: bold;
  color: var(--accent);
  font-size: 1rem;
  text-decoration: none;
}
.site-header-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.nav-btn {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
.nav-btn:hover {
  background: var(--bg-card-hover);
  text-decoration: none;
  color: var(--accent);
}
.nav-btn-home {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent-dim);
}
.nav-btn-home:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* --------------------- top page --------------------- */
.top-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.2rem 4rem;
}
.top-intro {
  margin-bottom: 2.5rem;
}
.lede {
  font-size: 1rem;
  color: var(--text-dim);
}
.warn {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(241, 90, 90, 0.08);
  border: 1px solid rgba(241, 90, 90, 0.3);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.92rem;
}

.shortcuts {
  margin-top: 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.shortcuts-note {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin: 0 0 0.4rem;
}
.shortcut-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.2rem;
  margin: 0;
  font-size: 0.9rem;
}
.shortcut-list dt { color: var(--text); }
.shortcut-list dd { color: var(--text-dim); margin: 0; }

/* ----- stage grid ----- */
.stage-select { margin-top: 2rem; }
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.7rem;
}
.stage-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  transition: background 120ms, border-color 120ms;
  position: relative;
  min-height: 96px;
}
.stage-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
  text-decoration: none;
}
.stage-card-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
}
.stage-card-meta {
  margin-top: 0.4rem;
  font-size: 0.88rem;
  color: var(--text);
}
.stage-card-size {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.loading, .error {
  text-align: center;
  color: var(--text-dim);
  padding: 1rem;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1em 0.5em;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--bg);
  margin-top: 0.4rem;
  font-weight: bold;
}
.badge-jiriki { background: var(--jiriki); color: #1a1a1a; }
.badge-unsolved { background: var(--warn); color: #ffffff; }

/* --------------------- stage page --------------------- */
.stage-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem 1.2rem 4rem;
}
.stage-info {
  margin-bottom: 1.2rem;
}
.stage-meta {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0.25rem 0;
}
.stage-note {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0.4rem 0;
}
.stage-note .badge { margin-right: 0.4rem; margin-top: 0; }
.error-msg {
  color: var(--warn);
}

.canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  overflow: auto;
}
#game-canvas {
  display: block;
  image-rendering: -webkit-optimize-contrast;
}
.placeholder-unsolved {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-dim);
}
.placeholder-unsolved h2 {
  color: var(--warn);
}

/* ----- controls ----- */
.controls {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.hud {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
}
.hud-label {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.hud-moves {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent);
}
.hud-status {
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-dim);
  font-size: 0.85rem;
}
.hud-status-playing { background: rgba(78, 154, 240, 0.18); color: #75bfff; }
.hud-status-clear { background: rgba(78, 203, 113, 0.22); color: #6fe89c; font-weight: bold; }
.hud-status-death { background: rgba(241, 90, 90, 0.22); color: #ff8888; font-weight: bold; }

.button-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.button-bar button {
  flex: 1 0 auto;
  min-width: 120px;
  padding: 0.55rem 0.8rem;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-ja);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.button-bar button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
}
.button-bar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-icon {
  font-family: var(--font-mono);
  color: var(--accent);
}

.path-wrap {
  margin-top: 0.75rem;
}
.path-wrap h2 {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}
.path-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}
.path-token {
  padding: 0.15rem 0.4rem;
  background: var(--bg-alt);
  border-radius: 4px;
  color: var(--text-dim);
}
.path-done { color: var(--text); }
.path-next {
  background: var(--accent);
  color: var(--bg);
  font-weight: bold;
}
.path-sep { color: var(--text-dim); }

.controls-hint {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --------------------- footer / disclaimer --------------------- */
.site-disclaimer {
  max-width: 900px;
  margin: 2rem auto 2rem;
  padding: 1.2rem 1.4rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.86rem;
}
.site-disclaimer h3 {
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}
.site-disclaimer ul {
  padding-left: 1.2rem;
  margin: 0;
}
.site-disclaimer li {
  margin-bottom: 0.25rem;
}

/* --------------------- responsive --------------------- */
@media (max-width: 480px) {
  .site-header { padding: 0.6rem 0.8rem; flex-direction: column; gap: 0.4rem; align-items: stretch; }
  .site-header-right { justify-content: center; }
  .top-main, .stage-main { padding-left: 0.8rem; padding-right: 0.8rem; }
  .stage-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
