/* ろぶラボ v1 ― ポップな研究室 × ドット絵レトロゲーム
   クリーム × ティール × オレンジ（えびロボ公式カラー準拠）
   角ばった枠・ハードなドット影・ピクセルフォント見出し＋CSS/JSの軽い動き */
:root {
  --cream: #f2e7d3;
  --cream-light: #fdf4e2;
  --cream-card: #fffaf0;
  --teal: #17555c;
  --teal-dark: #0e3a40;
  --orange: #e4653f;
  --orange-dark: #c9512f;
  --ink: #0d1b21;
  --text: #2b2b26;
  --text-sub: #5c5a50;
  --line: #d8c9a6;
  --glow: #ffdca8;
  --shadow-px: 6px 6px 0 rgba(14, 58, 64, 0.9);
  --shadow-px-sm: 4px 4px 0 rgba(14, 58, 64, 0.9);
  --font-pixel: "DotGothic16", "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream-light);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* 背景：余白をゆっくり流れるドット模様（固定レイヤー） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(23, 85, 92, 0.13) 2px, transparent 2.6px);
  background-size: 26px 26px;
  animation: dotflow 7s linear infinite;
}
@keyframes dotflow {
  from { background-position: 0 0; }
  to { background-position: 26px 52px; }
}

img { max-width: 100%; height: auto; }

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

h1, h2, h3, .brand-name, .btn, .badge, .lab-no, .link-name, .about-name,
.hero-catch, .press-start, .footer-copy, figcaption {
  font-family: var(--font-pixel);
  font-weight: 400;
}

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

/* ===== スクロール連動：ステップ感のある出現 ===== */
.js .reveal {
  opacity: 0;
  transform: translateY(22px);
}
.js .reveal.inview {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s steps(5), transform 0.45s steps(5);
}
.card-grid .card:nth-child(2), .link-grid .link-card:nth-child(2) { transition-delay: 0.08s; }
.card-grid .card:nth-child(3), .link-grid .link-card:nth-child(3) { transition-delay: 0.16s; }
.card-grid .card:nth-child(4), .link-grid .link-card:nth-child(4) { transition-delay: 0.24s; }
.card-grid .card:nth-child(5) { transition-delay: 0.32s; }

/* ===== ヘッダー（ゲームのメニューバー風） ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--cream-light);
  border-bottom: 4px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 3px solid var(--ink);
  flex: none;
}

.brand-name { font-size: 1.25rem; letter-spacing: 0.04em; white-space: nowrap; }
.brand-name small { color: var(--orange); font-size: 0.78rem; margin-left: 4px; letter-spacing: 0.14em; }

.site-nav { display: flex; gap: 8px; }
.site-nav a {
  text-decoration: none;
  color: var(--teal-dark);
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  padding: 2px 10px;
  border: 3px solid transparent;
  white-space: nowrap;
}
.site-nav a:hover {
  color: var(--ink);
  background: var(--cream);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 rgba(14, 58, 64, 0.9);
}

/* ===== ヒーロー（タイトル画面） ===== */
.hero {
  position: relative;
  overflow: hidden;
  background-color: var(--cream-light);
  background-image: radial-gradient(rgba(23, 85, 92, 0.16) 2px, transparent 2.6px);
  background-size: 22px 22px;
  border-bottom: 4px solid var(--ink);
}

.hero-inner {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 44px 24px 52px;
  text-align: center;
}

.hero-visual {
  display: block;
  width: 100%;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px);
  background: var(--cream-light);
}

/* ゲームのメッセージウィンドウ風パネル */
.hero-panel {
  margin: 26px auto 0;
  max-width: 640px;
  background: var(--cream-card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px-sm);
  padding: 20px 24px 22px;
  text-align: left;
}

.hero-catch {
  margin: 0 0 10px;
  font-size: 1.45rem;
  line-height: 1.5;
  color: var(--orange-dark);
  min-height: 1.5em;
}

.type-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 3px;
  background: var(--orange);
  vertical-align: -0.12em;
  animation: blink 0.9s steps(1) infinite;
}

.hero-lead { margin: 0; color: var(--text); }

.press-start {
  display: inline-block;
  margin-top: 26px;
  text-decoration: none;
  color: var(--teal-dark);
  font-size: 1.25rem;
  letter-spacing: 0.24em;
  animation: blink 1.2s steps(1) infinite;
}
.press-start:hover { color: var(--orange-dark); }

@keyframes blink { 50% { opacity: 0; } }

/* ヒーロー背景のキラキラ（ドットの星） */
.sparkle {
  position: absolute;
  width: 18px; height: 18px;
  background: var(--orange);
  clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%);
  opacity: 0;
  animation: twinkle 2.4s steps(1) infinite;
  pointer-events: none;
}
.sparkle.sp1 { left: 6%; top: 12%; }
.sparkle.sp2 { right: 8%; top: 20%; background: var(--teal); animation-delay: 0.6s; width: 13px; height: 13px; }
.sparkle.sp3 { left: 12%; bottom: 16%; background: var(--teal); animation-delay: 1.1s; width: 13px; height: 13px; }
.sparkle.sp4 { right: 14%; bottom: 10%; animation-delay: 1.6s; }
.sparkle.sp5 { left: 46%; top: 6%; background: #e8a13a; animation-delay: 0.3s; width: 11px; height: 11px; }
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 0.85; transform: scale(1); }
}

/* ===== ボタン（ドット影つき・押し込み式） ===== */
.btn {
  display: inline-block;
  text-decoration: none;
  border: 3px solid var(--ink);
  padding: 10px 24px;
  white-space: nowrap;
  transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}

.btn-card {
  background: var(--teal);
  color: #fff;
  padding: 6px 20px;
  font-size: 0.98rem;
  box-shadow: var(--shadow-px-sm);
}
.btn-card:hover { background: var(--teal-dark); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(14, 58, 64, 0.9); }
.btn-card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(14, 58, 64, 0.9); }

/* 「あそぶ」ボタン：ゆるやかな発光パルス */
.btn-play { animation: playglow 1.8s steps(2) infinite; }
@keyframes playglow {
  0%, 100% { box-shadow: var(--shadow-px-sm); }
  50% { box-shadow: 4px 4px 0 rgba(14, 58, 64, 0.9), 0 0 0 3px var(--glow); }
}

.btn-disabled {
  background: #cbbfa5;
  color: #fbf5e8;
  box-shadow: none;
  pointer-events: none;
}

/* ===== セクション ===== */
.section {
  max-width: 1080px;
  margin: 0 auto;
  padding: 64px 24px 8px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 10px;
  font-size: 2rem;
  color: var(--teal-dark);
  letter-spacing: 0.04em;
}

.section-title-bar {
  width: 12px;
  height: 30px;
  background: var(--orange);
  border: 3px solid var(--ink);
  align-self: center;
  flex: none;
}

.section-sub {
  font-size: 0.95rem;
  color: var(--orange-dark);
  letter-spacing: 0.22em;
}

.section-lead { margin: 0 0 28px; color: var(--text-sub); }

/* ステージ選択マップ風バナー */
.section-banner {
  margin: 0 0 30px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px);
  line-height: 0;
}
.section-banner img { width: 100%; }

/* ===== 作品カード（ステージ選択タイル） ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}

.card {
  background: var(--cream-card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px);
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 rgba(14, 58, 64, 0.9), 0 0 0 3px var(--glow);
  border-color: var(--orange-dark);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  flex: none;
}
.card-icon svg { width: 28px; height: 28px; }

/* カードのドット絵サムネイル */
.card-thumb {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border: 3px solid var(--ink);
  background: var(--cream-light);
  image-rendering: pixelated;
  flex: none;
}
.icon-teal { background: rgba(23, 85, 92, 0.16); color: var(--teal-dark); }
.icon-orange { background: rgba(228, 101, 63, 0.2); color: var(--orange-dark); }

/* ステージ番号：色がカクッと切り替わる軽い点滅 */
.lab-no {
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  color: #fff;
  background: var(--teal);
  border: 3px solid var(--ink);
  padding: 1px 10px;
  white-space: nowrap;
  animation: stageblink 2.8s steps(1) infinite;
}
@keyframes stageblink {
  0%, 100% { background: var(--teal); }
  50% { background: var(--teal-dark); }
}

.card h3 { margin: 0 0 8px; font-size: 1.3rem; color: var(--ink); letter-spacing: 0.03em; }
.card p { margin: 0 0 18px; font-size: 0.95rem; flex: 1; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
}

.badge {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  padding: 2px 10px;
  border: 3px solid var(--ink);
  white-space: nowrap;
}
.badge-live { background: var(--glow); color: var(--ink); }
.badge-soon { background: var(--cream); color: var(--text-sub); }
.badge-private { background: var(--ink); color: var(--glow); white-space: normal; line-height: 1.45; }

.card-private { background: #f1e7cf; }

/* ===== 運営者について ===== */
.about-box {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  background: var(--cream-card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px);
  padding: 28px;
}

.about-icon {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border: 3px solid var(--ink);
  flex: none;
}

/* About のマスコット（ドット絵えびロボ）：ゆっくり上下に揺れる */
.about-mascot {
  width: 150px;
  height: 150px;
  object-fit: cover;
  flex: none;
  align-self: center;
  image-rendering: pixelated;
  animation: mascotbob 1.6s steps(2) infinite;
}
@keyframes mascotbob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.about-name { margin: 0 0 8px; font-size: 1.5rem; color: var(--teal-dark); }
.about-text p { margin: 0 0 12px; }
.about-text p:last-child { margin-bottom: 0; }

.about-figure {
  margin: 26px 0 0;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px);
  background: var(--teal-dark);
  line-height: 0;
}
.about-figure img { width: 100%; }
.about-figure figcaption {
  line-height: 1.6;
  color: var(--glow);
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  padding: 6px 14px;
}

/* ===== リンク集 ===== */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  padding-bottom: 16px;
}

.link-card {
  display: block;
  text-decoration: none;
  background: var(--cream-card);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-px-sm);
  padding: 16px 18px;
  transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}
.link-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(14, 58, 64, 0.9), 0 0 0 3px var(--glow); border-color: var(--orange-dark); }
.link-card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(14, 58, 64, 0.9); }

.link-name { display: block; font-size: 1.2rem; color: var(--teal-dark); }
.link-name::before { content: "▶ "; color: var(--orange); }
.link-desc { display: block; font-size: 0.88rem; color: var(--text-sub); margin-top: 4px; }

/* ===== フッター ===== */
.site-footer {
  margin-top: 72px;
  background: var(--teal-dark);
  color: #e9e2cf;
  text-align: center;
  padding: 18px 24px 30px;
  border-top: 4px solid var(--ink);
  overflow: hidden;
}

/* フッターを歩く小さなえびロボ */
.footer-walk {
  position: relative;
  height: 84px;
  max-width: 1080px;
  margin: 0 auto 8px;
  border-bottom: 3px dashed rgba(255, 220, 168, 0.4);
}
.walker {
  position: absolute;
  bottom: 4px;
  left: 0;
  height: 72px;
  width: 72px;
  object-fit: cover;
  image-rendering: pixelated;
  animation: patrol 16s steps(160) infinite, bob 0.5s steps(2) infinite;
}
@keyframes patrol {
  0% { left: 0; transform: scaleX(1); }
  46% { left: calc(100% - 76px); transform: scaleX(1); }
  50% { left: calc(100% - 76px); transform: scaleX(-1); }
  96% { left: 0; transform: scaleX(-1); }
  100% { left: 0; transform: scaleX(1); }
}
@keyframes bob {
  0%, 100% { margin-bottom: 0; }
  50% { margin-bottom: 4px; }
}

.footer-note { margin: 10px auto 10px; max-width: 640px; font-size: 0.88rem; }
.footer-copy { margin: 0; letter-spacing: 0.08em; }

/* ===== スマホ ===== */
@media (max-width: 720px) {
  .site-header { padding: 8px 10px; gap: 8px; }
  .brand-icon { width: 34px; height: 34px; }
  .brand-name { font-size: 1rem; }
  .brand-name small { display: none; }
  .site-nav { gap: 0; }
  .site-nav a { font-size: 0.78rem; padding: 2px 5px; }

  .hero-inner { padding: 28px 16px 40px; }
  .hero-panel { padding: 16px 18px 18px; }
  .hero-catch { font-size: 1.15rem; }
  .press-start { font-size: 1.05rem; }
  .sparkle { width: 12px; height: 12px; }

  .section { padding: 48px 18px 4px; }
  .section-title { font-size: 1.6rem; }
  .about-box { flex-direction: column; align-items: center; text-align: center; padding: 24px 20px; }
  .footer-walk { height: 70px; }
  .walker { height: 58px; width: 58px; }
  .about-mascot { width: 120px; height: 120px; }
}

/* ===== 動きを減らす設定への配慮 ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
