/* ============================================================
   AIUTOPIA GAMES — 共有スタイル(ハブ + 各ゲームページ)
   ブランド: cyan #4cc9ff / violet #7b5cff / magenta #ff4ecd
   ============================================================ */
:root {
  --bg: #04060d;
  --panel: #0a0f1e;
  --line: #1c2440;
  --cyan: #4cc9ff;
  --violet: #7b5cff;
  --magenta: #ff4ecd;
  --text: #eaeefb;
  --dim: #9aa5c0;
  --grad: linear-gradient(100deg, var(--cyan), var(--violet) 52%, var(--magenta));
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100svh;
  overflow-x: hidden;
}
/* 微かなグリッド + 上部オーロラ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 42% at 18% -8%, rgba(76, 201, 255, 0.13), transparent 60%),
    radial-gradient(ellipse 70% 44% at 85% -10%, rgba(123, 92, 255, 0.15), transparent 62%),
    radial-gradient(ellipse 90% 50% at 50% 115%, rgba(255, 78, 205, 0.08), transparent 60%),
    linear-gradient(rgba(28, 36, 64, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 36, 64, 0.16) 1px, transparent 1px);
  background-size: auto, auto, auto, 44px 44px, 44px 44px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
canvas { display: block; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 15, 30, 0.8);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(76, 201, 255, 0.55); }
.btn-primary {
  background: var(--grad);
  border: none;
  color: #050810;
  box-shadow: 0 10px 30px -10px rgba(123, 92, 255, 0.65);
}
.btn-primary:hover { box-shadow: 0 14px 36px -10px rgba(255, 78, 205, 0.6); }

/* ============================================================
   ゲームページ
   ============================================================ */
.g-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 28px);
  background: rgba(4, 6, 13, 0.74);
  border-bottom: 1px solid rgba(28, 36, 64, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.g-back {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--dim);
  white-space: nowrap;
  transition: color 0.15s;
}
.g-back:hover { color: var(--cyan); }
.g-title {
  font-size: clamp(15px, 3.8vw, 20px);
  font-weight: 800;
  letter-spacing: 0.16em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.g-tools { display: flex; align-items: center; gap: 12px; }
.g-best {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
  white-space: nowrap;
}
.g-best b { color: var(--cyan); font-size: 14px; margin-left: 4px; }
.g-sound {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(10, 15, 30, 0.85);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}
.g-sound:hover { border-color: rgba(76, 201, 255, 0.55); }

.g-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 14px calc(34px + env(safe-area-inset-bottom));
}
.g-stage {
  position: relative;
  width: min(94vw, var(--stage-w, 520px));
  aspect-ratio: var(--stage-aspect, 3 / 4);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(28, 36, 64, 0.95);
  background: #05070f;
  box-shadow:
    0 24px 60px -30px rgba(76, 201, 255, 0.28),
    0 4px 24px rgba(0, 0, 0, 0.5);
}
.g-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* オーバーレイ(スタート / ポーズ / ゲームオーバー) */
.g-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  background: rgba(4, 6, 13, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.g-overlay.is-on { display: flex; }
.g-overlay h2 {
  font-size: clamp(24px, 7vw, 38px);
  font-weight: 800;
  letter-spacing: 0.14em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.g-overlay p { color: var(--dim); font-size: 13px; line-height: 1.9; }
.ov-score {
  font-family: var(--mono);
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.ov-best {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--cyan);
}
.ov-new {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--magenta);
  animation: ovBlink 0.9s steps(2) infinite;
}
@keyframes ovBlink { 50% { opacity: 0.25; } }

/* HUD(スコア行)と操作説明 */
.g-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.g-hud b { color: var(--text); font-size: 15px; margin-left: 6px; }
.g-help {
  max-width: 620px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  line-height: 2.1;
}
.g-help kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(10, 15, 30, 0.85);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* ============================================================
   ハブページ(ゲーム一覧)
   ============================================================ */
.hub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
}
.hub-brand { display: flex; align-items: center; gap: 10px; }
.hub-brand .brand-mark { width: 26px; height: 26px; }
.hub-brand-name {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 14px;
}
.hub-portal-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--dim);
  transition: color 0.15s;
}
.hub-portal-link:hover { color: var(--cyan); }

.hub-hero {
  text-align: center;
  padding: clamp(36px, 8vw, 72px) 18px clamp(22px, 5vw, 40px);
}
.hub-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--cyan);
  margin-bottom: 14px;
}
.hub-logo {
  font-size: clamp(34px, 9vw, 74px);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 26px rgba(123, 92, 255, 0.4));
}
.hub-tagline {
  margin-top: 16px;
  font-size: clamp(14px, 3.4vw, 17px);
  color: var(--text);
  font-weight: 600;
}
.hub-sub { margin-top: 10px; color: var(--dim); font-size: 13px; line-height: 2; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 8px clamp(14px, 4vw, 32px) 60px;
}
.game-card {
  position: relative;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(160deg, rgba(76, 201, 255, 0.45), rgba(28, 36, 64, 0.55) 42%, rgba(255, 78, 205, 0.45));
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 48px -18px rgba(123, 92, 255, 0.55);
}
.gc-inner {
  display: flex;
  gap: 14px;
  align-items: center;
  height: 100%;
  border-radius: 17px;
  background: rgba(7, 10, 20, 0.94);
  padding: 16px;
}
.gc-icon {
  flex: none;
  width: 68px;
  height: 68px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #070b16;
}
.gc-body { min-width: 0; flex: 1; }
.gc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.gc-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text);
}
.game-card:hover .gc-name {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gc-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(76, 201, 255, 0.4);
  color: var(--cyan);
}
.gc-tag.is-puzzle { border-color: rgba(255, 78, 205, 0.45); color: var(--magenta); }
.gc-desc { margin-top: 6px; font-size: 12px; line-height: 1.8; color: var(--dim); }
.gc-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--dim);
}
.gc-best b { color: var(--cyan); margin-left: 5px; }
.gc-arrow { transition: transform 0.2s; }
.game-card:hover .gc-arrow { transform: translateX(4px); color: var(--cyan); }

.hub-footer {
  padding: 26px 18px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  border-top: 1px solid rgba(28, 36, 64, 0.55);
}
.hub-footer a { color: var(--dim); transition: color 0.15s; }
.hub-footer a:hover { color: var(--cyan); }
.hub-footer .sep { margin: 0 10px; opacity: 0.4; }

/* スクロールリビール */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-in { opacity: 1; transform: none; }

/* 404 */
.notfound {
  min-height: 82svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}
.notfound h1 {
  font-size: clamp(64px, 18vw, 130px);
  font-weight: 800;
  letter-spacing: 0.1em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.notfound p { color: var(--dim); font-size: 14px; line-height: 2; }

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- モバイル ---------- */
@media (max-width: 640px) {
  .game-grid { grid-template-columns: 1fr; }
  .g-best { display: none; }
}
