:root {
  --navy: #151a4a;
  --ink: #0b0b16;
  --pink: #ff4fb0;
  --paper: #f6eefe;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--navy);
  color: var(--paper);
  font-family: "Bangers", "Zen Maru Gothic", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  touch-action: pinch-zoom;
}

/* 画面全体にうっすら網点と紙のざらつきをかけて、キャラと背景の絵柄をそろえる */
.halftone {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(10, 6, 30, .55) 0.9px, transparent 1.4px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
  opacity: .22;
}

.grain {
  position: fixed;
  inset: -40px;
  pointer-events: none;
  opacity: .09;
  mix-blend-mode: overlay;
  animation: grain .45s steps(1) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-13px, 9px); }
  50% { transform: translate(11px, -7px); }
  75% { transform: translate(-6px, -12px); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 55% 50%, transparent 55%, rgba(5, 3, 20, .55) 100%);
}

.brand {
  position: fixed;
  top: clamp(14px, 3vh, 32px);
  left: clamp(14px, 2.6vw, 40px);
  width: clamp(150px, 19vw, 300px);
  pointer-events: none;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .45));
}

.brand img { display: block; width: 100%; height: auto; }

.weather {
  position: fixed;
  top: clamp(18px, 3.4vh, 36px);
  right: clamp(16px, 2.6vw, 40px);
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 22px;
  letter-spacing: .06em;
}

.weather button {
  font: inherit;
  color: rgba(246, 238, 254, .5);
  background: none;
  border: 0;
  padding: 4px 2px;
  cursor: pointer;
  text-shadow: 2px 2px 0 var(--ink);
  transition: color .2s, transform .15s;
}

.weather button[aria-pressed="true"] {
  color: var(--paper);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
  text-decoration-color: var(--pink);
}

.weather button:active { transform: scale(.94); }

.weather button:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 4px;
}

.weather .slash { color: rgba(246, 238, 254, .35); }

/* ロゴをはじかれたときの揺れ */
.brand { transform-origin: 30% 60%; }
.brand.poked { animation: brand-poke .7s ease-out; }
@keyframes brand-poke {
  0% { transform: none; }
  15% { transform: rotate(-7deg) translate(-6px, 3px); }
  35% { transform: rotate(5deg); }
  55% { transform: rotate(-3deg); }
  75% { transform: rotate(1.5deg); }
  100% { transform: none; }
}

/* ---- メニュー（左下に縦の並び） ---- */
:root {
  --edge: clamp(14px, 2.6vw, 40px);
  --logo-w: clamp(150px, 19vw, 300px);
  --nav-h: 172px;
  --nav-b: clamp(16px, 3.4vh, 36px);
}

.menu-nav {
  position: fixed;
  left: var(--edge);
  bottom: var(--nav-b);
  z-index: 3;
}

.menu-nav ul { list-style: none; display: grid; gap: 2px; }

.menu-nav button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font: 24px/1.25 "Bangers", sans-serif;
  letter-spacing: .06em;
  color: rgba(246, 238, 254, .62);
  background: none;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  text-shadow: 2px 2px 0 var(--ink);
  transition: color .2s, transform .15s;
}

.menu-nav .num { font-size: 16px; color: var(--pink); letter-spacing: .04em; }

.menu-nav button:hover { color: var(--paper); transform: translateX(4px); }

.menu-nav button[aria-expanded="true"] {
  color: var(--paper);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
  text-decoration-color: var(--pink);
}

.menu-nav button:active { transform: scale(.95); }

.menu-nav button:focus-visible,
.panel .close:focus-visible,
.panel input:focus-visible,
.panel textarea:focus-visible,
.panel .submit:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 3px;
}

/* ---- 板（燃えた紙が逆再生でよみがえる、暗いすりガラスと太い墨の枠） ---- */
.panel {
  position: fixed;
  left: var(--edge);
  top: calc(clamp(14px, 3vh, 32px) + var(--logo-w) * .67 + 10px);
  width: min(460px, 40vw);
  max-height: calc(100vh - (clamp(14px, 3vh, 32px) + var(--logo-w) * .67 + 10px) - var(--nav-h) - var(--nav-b) - 16px);
  overflow-y: auto;
  padding: 20px 24px 22px;
  background: rgba(20, 13, 48, .68);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 0 0 1.5px rgba(246, 238, 254, .22), 8px 8px 0 rgba(11, 11, 22, .85);
  font: 500 15px/1.8 "Zen Maru Gothic", sans-serif;
  color: var(--paper);
  word-break: auto-phrase;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
}

/* 出入りの切り抜き（clip-path）は main.js が毎こま書く（終わると消して、このくっきりした形に戻す） */
.panel.open {
  opacity: 1;
  visibility: visible;
}

/* 板の出入りの火の線・焦げ・火の粉を描く、板ごとの canvas（main.js が出入りの間だけ作って、板に重ねる） */
.burn {
  position: fixed;
  pointer-events: none;
  z-index: 5;
}

.panel:focus { outline: none; }

.panel h2 {
  font: 46px/1 "Bangers", sans-serif;
  letter-spacing: .04em;
  color: var(--paper);
  text-shadow: 3px 3px 0 var(--ink);
  margin: 0 44px 10px 0;
}

.panel h2 .ja {
  display: inline-block;
  margin-left: .6em;
  font: 700 15px/1 "Zen Maru Gothic", sans-serif;
  letter-spacing: .08em;
  color: var(--pink);
  text-shadow: none;
  vertical-align: middle;
}

.panel .lead { margin-bottom: 14px; }

.panel .close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--paper);
  background: rgba(11, 11, 22, .5);
  border: 2px solid rgba(246, 238, 254, .35);
  border-radius: 50%;
  cursor: pointer;
}

.panel .close:hover { border-color: var(--pink); color: var(--pink); }
.panel .close svg { display: block; }

/* Games：3枚のカード */
.cards { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card h3 { font: 700 14px/1.5 "Zen Maru Gothic", sans-serif; margin-top: 6px; }
.card p { font-size: 13px; line-height: 1.6; color: rgba(246, 238, 254, .78); }
.card .thumb {
  aspect-ratio: 4 / 3;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 79, 176, .22) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #2b1f5e, #120c2c);
  box-shadow: 3px 3px 0 var(--ink);
}

/* Apps：スマホの形の枠 */
.phone {
  position: relative;
  width: 100%;
  padding: 34px 14px 22px;
  border: 6px solid var(--ink);
  border-radius: 30px;
  background: linear-gradient(170deg, #2d2160, #140d30);
  box-shadow: 0 0 0 1.5px rgba(246, 238, 254, .25), 6px 6px 0 var(--ink);
}
.phone-notch {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 56px;
  height: 10px;
  margin-left: -28px;
  border-radius: 6px;
  background: var(--ink);
}
.app-grid { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; text-align: center; font-size: 13px; line-height: 1.4; }
.app-grid .icon {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 4px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(140deg, var(--pink), #7a3cff);
}
.app-grid li:nth-child(2n) .icon { background: linear-gradient(140deg, #ffd3f0, var(--pink)); }
.app-grid li:nth-child(3n) .icon { background: linear-gradient(140deg, #5b4bd6, #1c1446); }

/* Client Work：少し傾いた4枚 */
.panes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; padding: 0 0 6px; }
.pane { font: 700 14px/1.5 "Zen Maru Gothic", sans-serif; transform: rotate(-2.5deg); }
.pane:nth-child(2) { transform: rotate(2deg); }
.pane:nth-child(3) { transform: rotate(1.5deg); }
.pane:nth-child(4) { transform: rotate(-1.8deg); }
.pane-img {
  display: block;
  aspect-ratio: 16 / 10;
  margin-bottom: 6px;
  border: 3px solid var(--ink);
  background:
    linear-gradient(transparent 70%, rgba(11, 11, 22, .5)),
    linear-gradient(135deg, #3a2a7a, #1a1240 60%, #4a1f52);
  box-shadow: 4px 4px 0 var(--ink);
}

/* About：段落の間 */
.panel p + p { margin-top: .7em; }

/* Contact：フォーム */
.contact-form { display: grid; gap: 8px; }
.contact-form label { display: grid; gap: 4px; font-weight: 700; }
.contact-form input,
.contact-form textarea {
  width: 100%;
  font: 500 16px/1.5 "Zen Maru Gothic", sans-serif;
  color: var(--ink);
  background: rgba(246, 238, 254, .94);
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 4px 10px;
  resize: vertical;
}
.contact-form .submit {
  justify-self: start;
  margin-top: 4px;
  padding: 6px 26px 8px;
  font: 900 16px/1.4 "Zen Maru Gothic", sans-serif;
  color: var(--ink);
  background: var(--pink);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.contact-form .submit:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.contact-form .status { min-height: 1.8em; color: #ffd3f0; font-weight: 700; }

/* ---- スマホ：メニューは下に横1列、板はその上に出す ---- */
@media (max-width: 599px) {
  :root { --nav-h: 62px; }
  .menu-nav {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .menu-nav ul { display: flex; justify-content: space-between; gap: 2px; }
  .menu-nav li { flex: 1 1 0; }
  .menu-nav button {
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 0;
    font-size: 17px;
    line-height: 1.1;
    text-align: center;
    padding: 4px 0;
  }
  .menu-nav .num { font-size: 13px; }
  .menu-nav button:hover { transform: none; }
  .panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 58vh;
    padding: 16px 16px 18px;
  }
  .panel h2 { font-size: 38px; }
  .cards { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  /* 動きを控える設定：燃える動きなし、不透明度だけで出す */
  .panel { transition: opacity .2s, visibility 0s .2s; }
  .panel.open { transition: opacity .2s, visibility 0s; }
  .burn { display: none; }
  .brand.poked { animation: none; }
}

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  font-size: 28px;
  letter-spacing: .12em;
  color: var(--pink);
  transition: opacity .6s;
  z-index: 10;
}

#loading .pct { margin-left: .4em; color: var(--paper); }
#loading.done { opacity: 0; pointer-events: none; }

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

.noscript {
  position: fixed;
  left: 24px; right: 24px; bottom: 24px;
  font: 500 15px/1.7 "Zen Maru Gothic", sans-serif;
  word-break: auto-phrase;
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
}
