/* 神々の遊び — 夕暮れの小樽運河。藍色の空、ガス灯の琥珀色、赤レンガ */
:root {
  --ivory: #eef1fb;
  --amber: #ffd29a;
  --accent: linear-gradient(90deg, #ffd89c, #ffa67e 55%, #f283ad);
  --muted: rgba(225, 230, 250, .55);
  --glass: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .14);
  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --retro: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1214; color: var(--ivory); font-family: var(--jp); }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; display: block; touch-action: none; }

/* 上の表示 */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2;
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 8px;
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.title { min-width: 0; }
.title h1 {
  margin: 0; font-family: var(--mincho); font-weight: 600; font-size: 21px; letter-spacing: .1em; line-height: 1.1; white-space: nowrap;
  background: linear-gradient(180deg, #ffffff, #ffe0c4); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 170, 110, .35));
}
.title p { margin: 4px 0 0; font-family: var(--retro); font-weight: 600; font-size: 8px; letter-spacing: .32em; white-space: nowrap; color: var(--amber); opacity: .8; }
.scores { display: flex; gap: 6px; }
.score {
  min-width: 54px; padding: 4px 6px; text-align: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.score small, .next small { display: block; font-family: var(--retro); font-weight: 600; font-size: 8px; letter-spacing: .24em; color: var(--muted); }
.score b { font-family: var(--retro); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.score.best b { font-size: 15px; color: var(--muted); }
.side { display: flex; gap: 6px; align-items: center; }
.next { padding: 3px 6px 4px; text-align: center; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.next canvas { display: block; width: 34px; height: 34px; margin: 1px auto 0; }
.icons { display: grid; gap: 5px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 50%; padding: 0;
  background: var(--glass); color: var(--ivory); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 14px; line-height: 1; cursor: pointer;
}

/* 下の「進化の順番」 */
.ladder {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 6px 10px calc(env(safe-area-inset-bottom) + 8px);
  pointer-events: none;
}
.ladder-row {
  display: flex; justify-content: center; align-items: center; gap: 3px;
  padding: 5px 8px; margin: 0 auto; width: fit-content; max-width: 100%;
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.ladder-row canvas { display: block; }
.ladder-row canvas + canvas::before { content: "›"; }

/* ゲームオーバー */
.gameover {
  position: fixed; inset: 0; z-index: 5;
  display: grid; place-items: center; padding: 20px;
  background: rgba(4, 6, 16, .55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade .4s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(100%, 330px); padding: 24px 22px; text-align: center;
  background: linear-gradient(180deg, rgba(60, 38, 40, .72), rgba(24, 14, 18, .84));
  border: 1px solid var(--line); border-radius: 22px;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .1), 0 0 40px rgba(255, 160, 110, .15);
  animation: rise .5s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes rise { from { transform: translateY(24px) scale(.94); opacity: 0; } }
.go-label { margin: 0; font-family: var(--retro); font-weight: 600; font-size: 11px; letter-spacing: .5em; background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card h2 { margin: 8px 0 14px; font-family: var(--mincho); font-weight: 600; font-size: 20px; letter-spacing: .1em; }
.go-score b { font-family: var(--retro); font-size: 58px; font-weight: 300; line-height: 1; letter-spacing: -.01em; }
.go-score span { margin-left: 4px; color: var(--muted); }
.go-best { margin: 6px 0 14px; color: var(--amber); font-size: 14px; }
.go-top { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-size: 13.5px; color: var(--muted); }
.btn {
  width: 100%; min-height: 50px;
  background: var(--accent); color: #2a1416;
  border: none; border-radius: 999px;
  font-family: var(--jp); font-weight: 700; font-size: 16px; letter-spacing: .16em;
  box-shadow: 0 8px 28px rgba(255, 150, 110, .4); cursor: pointer;
}
.btn:active { transform: translateY(1px); }

.toast {
  position: fixed; left: 50%; top: 40%; z-index: 6;
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  padding: 10px 22px; border-radius: 999px;
  background: rgba(30, 18, 20, .7); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-family: var(--jp); font-weight: 700; letter-spacing: .12em; color: var(--ivory);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 420px) {
  .title h1 { font-size: 26px; }
}
