: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; }

/* 右上：天気（月夜・雨）と効果音を、アイコンだけで小さな暗い札にまとめる（11/21 ご主人様。本家の英単語の並びから離す）。
   選んでいる方（今の天気・音 ON）はピンク、ほかは暗く。動きは付けない（押すと色が変わるだけ）。PC もスマホも同じ大きさ（札 194x70px） */
.topbar {
  position: fixed;
  top: clamp(18px, 3.4vh, 36px);
  right: clamp(16px, 2.6vw, 40px);
  display: flex;
  align-items: center;
  padding: 5px;
  background: rgba(11, 11, 22, .62);
  border: 2px solid rgba(246, 238, 254, .16);
  border-radius: 17px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .45);
  z-index: 3;
}
.weather { display: flex; align-items: center; }
.weather button,
.sound {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  color: rgba(246, 238, 254, .42);
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.topbar svg { display: block; width: 30px; height: 30px; }
.weather button[aria-pressed="true"],
.sound[aria-pressed="true"] {
  color: var(--pink);
  background: rgba(255, 79, 176, .16);
}
.weather button[aria-pressed="false"]:hover,
.sound[aria-pressed="false"]:hover { color: rgba(246, 238, 254, .8); }
.weather button:focus-visible,
.sound:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.topbar .sep { width: 2px; height: 30px; margin: 0 5px; background: rgba(246, 238, 254, .18); }
.sound .ic-on,
.sound[aria-pressed="true"] .ic-off { display: none; }
.sound[aria-pressed="true"] .ic-on { display: block; }

/* ロゴをはじかれたときの揺れ */
.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; }
}

/* ---- メニュー：PC は画面の下の端から5枚のカードが扇に顔を出す（11/21 ご主人様。本家の「番号つきの縦の並び」から離す） ----
   カードは四隅を内側に丸くえぐった形（index.html の #card-frame）。線は墨の外枠とピンクの細い線の2本、中身は手書きの名前と記号だけ。
   近づくとカードが持ち上がる。開いているメニューは、いちばん上まで出て、ピンクの線が明るくなり外に少し光る。
   スマホと横向きは、カードを出さず落書きの形（下の @media） */
:root {
  --edge: clamp(14px, 2.6vw, 40px);
  --logo-w: clamp(150px, 19vw, 300px);
  --nav-h: 150px;
  --nav-b: clamp(16px, 3.4vh, 36px);
}

.menu-nav {
  position: fixed;
  left: calc(var(--edge) + 14px);   /* 左端のカードは傾く分だけ左へはみ出すので、少し内へ */
  bottom: 0;
  z-index: 3;
}

.menu-nav ul { list-style: none; display: flex; align-items: flex-end; }
/* 扇の開き方（--r：傾き、--y：下がり方） */
.menu-nav li { --r: 0deg; --y: 0px; margin-left: -12px; }
.menu-nav li:first-child { margin-left: 0; }
.menu-nav li:nth-child(1) { --r: -9deg; --y: 18px; }
.menu-nav li:nth-child(2) { --r: -4.5deg; --y: 6px; }
.menu-nav li:nth-child(3) { --r: 0deg; --y: 2px; }
.menu-nav li:nth-child(4) { --r: 4.5deg; --y: 6px; }
.menu-nav li:nth-child(5) { --r: 9deg; --y: 18px; }

.menu-nav button {
  --line: rgba(255, 79, 176, .55);   /* 内側の細い線 */
  --line-w: 1.2px;
  position: relative;
  display: block;
  width: 108px;
  height: 184px;
  padding: 0;
  color: var(--paper);
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, .45));
  transform-origin: 50% 100%;
  transform: translateY(calc(60px + var(--y))) rotate(var(--r));
  transition: transform .18s ease-out, color .2s, filter .2s;
}
.menu-nav .frame { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.menu-nav .lbl {
  position: absolute; left: 0; right: 0; top: 18px;
  text-align: center;
  font: 17px/1 "Permanent Marker", "Bangers", sans-serif;
  letter-spacing: .02em;
  text-shadow: 2px 2px 0 var(--ink);
}
.menu-nav .sym {
  position: absolute; left: 26px; top: 46px; width: 56px; height: 56px;
  overflow: visible;
  filter: drop-shadow(2px 2px 0 var(--ink));
}
.menu-nav .sym path, .menu-nav .sym circle, .menu-nav .sym rect { fill: var(--pink); }
.menu-nav .sym .st { fill: none; stroke: var(--pink); stroke-width: 22; }
.menu-nav .sym .st.round { stroke-linecap: round; }

.menu-nav button:hover { transform: translateY(calc(36px + var(--y))) rotate(var(--r)); color: var(--paper); }
.menu-nav button:active { transform: translateY(calc(32px + var(--y))) rotate(var(--r)) scale(.97); }
.menu-nav button[aria-expanded="true"],
.menu-nav button[aria-expanded="true"]:hover {
  --line: var(--pink);
  --line-w: 1.6px;
  color: var(--pink);
  transform: translateY(calc(18px + var(--y))) rotate(var(--r));
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, .45)) drop-shadow(0 0 10px rgba(255, 79, 176, .55));
}

.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);
  /* PC は、左の猫の手前（--char-left-open は js/content/fit.js が書く）まで広げる。広げられないときは今までの幅 */
  width: max(min(460px, 40vw), min(620px, calc(var(--char-left-open, 0px) - var(--edge) - 20px)));
  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 .kicker {
  display: inline-block;
  margin-left: .6em;
  font: 700 14px/1 "Zen Maru Gothic", sans-serif;
  letter-spacing: .06em;
  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; }

/* ---- 板の中身（js/content/panels.js が組み立てる。ここから「スマホ」の手前までが中身の見た目） ---- */
.panel ul { list-style: none; }
.panel h3 { font: 700 15px/1.5 "Zen Maru Gothic", sans-serif; }

/* 共通：ボタン（今は形だけで、押しても移動しない） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 14px 5px;
  font: 700 13px/1.3 "Zen Maru Gothic", sans-serif;
  letter-spacing: .04em;
  color: #ffd3f0;
  background: rgba(11, 11, 22, .55);
  border: 2px solid var(--pink);
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn svg { flex: none; }
.btn:hover { color: var(--ink); background: var(--pink); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
.btn--sm { min-height: 32px; gap: 4px; padding: 2px 8px 3px; }

/* 共通：札（使った技術・使う道具） */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  padding: 1px 9px 2px;
  font: 500 13px/1.5 "Zen Maru Gothic", sans-serif;
  color: rgba(246, 238, 254, .9);
  background: rgba(246, 238, 254, .08);
  border: 1.5px solid rgba(246, 238, 254, .3);
  border-radius: 999px;
}

/* 共通：絵の枠（絵がないときは縞の仮の絵） */
.thumb, .work-img, .face { display: block; overflow: hidden; border: 3px solid var(--ink); }
.thumb img, .work-img img, .face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.is-empty {
  background:
    repeating-linear-gradient(135deg, rgba(255, 79, 176, .22) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #2b1f5e, #120c2c);
}

/* Games：絵・題名・ひとこと・ボタン（PC は2列。ボタンは下の端にそろえる） */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.card { display: flex; flex-direction: column; }
.card .thumb { aspect-ratio: 16 / 10; border-radius: 6px; box-shadow: 3px 3px 0 var(--ink); }
.card h3 { margin-top: 8px; }
.card p { flex: 1; margin: 2px 0 10px; font-size: 13px; line-height: 1.6; color: rgba(246, 238, 254, .78); }
.card .btn { align-self: flex-start; }

/* Apps：スマホの形の枠の中に、アイコン・名前・ひとこと・入手先のボタン
   並べ方は config/panels.js の layout で替える（list：1行に1件 ／ grid：アイコンを3列、名前だけ） */
.phone {
  position: relative;
  width: 100%;
  padding: 30px 14px 16px;
  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-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(140deg, var(--pink), #7a3cff);
  box-shadow: 2px 2px 0 var(--ink);
}
.app-icon img { width: 100%; height: 100%; border-radius: 11px; object-fit: cover; }
.app:nth-child(3n+2) .app-icon { color: var(--ink); background: linear-gradient(140deg, #ffd3f0, var(--pink)); }
.app:nth-child(3n) .app-icon { background: linear-gradient(140deg, #5b4bd6, #1c1446); }
.app h3 { font-size: 14px; line-height: 1.4; }
.app p { font-size: 13px; line-height: 1.55; color: rgba(246, 238, 254, .78); }
.app-body { flex: 1; min-width: 0; }
.app-links { flex: none; display: flex; flex-wrap: wrap; gap: 6px; }
.apps--list .app { display: flex; gap: 12px; align-items: center; padding: 10px 2px; }
.apps--list .app + .app { border-top: 1.5px solid rgba(246, 238, 254, .14); }
.apps--grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; text-align: center; }
.apps--grid .app-icon { margin: 0 auto 4px; }
.apps--grid p, .apps--grid .app-links { display: none; }

/* Works：横長のバナー（左に絵、まん中に名前・したこと・札、右の端にボタン）。1行1件で縦に伸ばさない。
   看板のように、1枚ずつほんの少し傾ける */
.works { display: grid; gap: 12px; padding: 2px 4px 6px 0; }
.work {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 14px;
  padding: 6px 12px 6px 6px;
  background: rgba(11, 11, 22, .45);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 0 0 1.5px rgba(246, 238, 254, .14), 4px 4px 0 var(--ink);
  transform: rotate(-.6deg);
}
.work:nth-child(2n) { transform: rotate(.5deg); }
.work-img { width: 100%; aspect-ratio: 16 / 9; border-width: 2px; border-radius: 4px; }
.work-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; }
.work .roles { font-size: 13px; line-height: 1.5; color: #ffd3f0; }
.work .roles .lbl { margin-right: .5em; color: rgba(246, 238, 254, .6); }
.work .roles span { white-space: nowrap; }

/* Profile：顔の絵とひとこと・プロフィールの3つ・ハッシュタグの札 */
.profile { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.face { flex: none; width: 92px; height: 92px; border-radius: 50%; box-shadow: 0 0 0 2px var(--pink), 3px 3px 0 3px var(--ink); background: #2b1f5e; }
.profile .name { font: 32px/1 "Bangers", sans-serif; letter-spacing: .05em; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }
.profile .name + p { margin-top: 6px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.facts > div { padding: 10px 10px 12px; background: rgba(11, 11, 22, .4); border: 2px solid rgba(246, 238, 254, .16); border-radius: 8px; }
.fact-ic { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 6px; color: var(--ink); background: var(--pink); border: 2px solid var(--ink); border-radius: 50%; }
.facts dt { font-size: 13px; line-height: 1.4; color: rgba(246, 238, 254, .7); }
.facts dd { font-size: 15px; font-weight: 700; line-height: 1.5; }
.tags-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 14px; }
.panel .sub { font-size: 13px; letter-spacing: .08em; color: var(--pink); }

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

/* Contact：フォーム・送れなかったとき・届いたとき */
/* PC は、お名前とメールアドレスを横に並べ、送れなかった知らせは送るボタンの横に出す（板を縦に伸ばさない） */
.contact-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.contact-form .choice, .contact-form .f-message, .form-foot { grid-column: 1 / -1; }
.contact-form textarea { height: 4.8em; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 4px; }
.contact-form[hidden] { display: none; }
.contact-form label { display: grid; gap: 4px; font-weight: 700; }
/* ご用件：丸い札の形の選択 */
/* 見出し（ご用件）と札は1行に並べる */
.choice { border: 0; min-width: 0; }
.choice legend { float: left; margin-right: 14px; font-weight: 700; line-height: 36px; }
.choice-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-form .opt { display: block; position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 14px 5px;
  font: 700 14px/1.3 "Zen Maru Gothic", sans-serif;
  color: rgba(246, 238, 254, .85);
  background: rgba(11, 11, 22, .45);
  border: 2px solid rgba(246, 238, 254, .3);
  border-radius: 999px;
  transition: background .15s, color .15s, border-color .15s;
}
.opt:hover span { border-color: var(--pink); }
.opt input:checked + span { color: var(--ink); background: var(--pink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.opt input:focus-visible + span { outline: 3px solid var(--pink); outline-offset: 3px; }
.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;
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 8px;
  padding: 6px 24px 8px 20px;
  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 .submit:disabled { opacity: .7; cursor: progress; }
.form-error {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex: 1 1 240px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #ffd9de;
  background: rgba(110, 8, 24, .45);
  border: 2px solid #ff6b81;
  border-radius: 6px;
}
.form-error[hidden] { display: none; }
.form-error svg { flex: none; margin-top: 1px; color: #ff6b81; }
.form-error-title { font-size: 14px; font-weight: 700; color: #fff0f2; }
.form-error p + p { margin-top: 0; }
.sent { display: grid; justify-items: center; gap: 4px; padding: 18px 8px 8px; text-align: center; }
.sent[hidden] { display: none; }
.sent-ic { color: var(--pink); filter: drop-shadow(2px 2px 0 var(--ink)); }
.sent-title { margin-top: 2px; font: 900 22px/1.4 "Zen Maru Gothic", sans-serif; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }
.sent-title:focus { outline: none; }
.sent p + p { margin-top: 0; }
.sent .btn { margin-top: 12px; }

/* ---- スマホ（縦と横向き）：メニューはカードを出さず、落書きの形（11/21 ご主人様）----
   傾けた手書きの名前を横1列に並べ、開いているメニューはピンクの字と、手で描いた丸で囲む。
   置き場所は、縦は下の端、横向きはロゴの右（下の @media） */
@media (max-width: 599px), (min-width: 600px) and (max-height: 520px) {
  .menu-nav li { margin-left: 0; transform: rotate(var(--t, 0deg)); }
  .menu-nav li:first-child { margin-left: 0; }
  .menu-nav li:nth-child(1) { --t: -6deg; }
  .menu-nav li:nth-child(2) { --t: 4deg; }
  .menu-nav li:nth-child(3) { --t: -3deg; }
  .menu-nav li:nth-child(4) { --t: 5deg; }
  .menu-nav li:nth-child(5) { --t: -4deg; }
  .menu-nav button,
  .menu-nav button:hover,
  .menu-nav button:active,
  .menu-nav button[aria-expanded="true"],
  .menu-nav button[aria-expanded="true"]:hover {
    display: flex; justify-content: center; align-items: center;
    width: 100%; height: auto; min-height: 46px; padding: 0;
    filter: none; transform: none;
  }
  .menu-nav .frame, .menu-nav .sym { display: none; }
  .menu-nav .lbl { position: static; font-size: 15px; letter-spacing: 0; color: rgba(246, 238, 254, .88); }
  .menu-nav button[aria-expanded="true"] .lbl { color: var(--pink); text-shadow: 2px 2px 0 var(--ink), 0 0 10px rgba(255, 79, 176, .7); }
  /* 手で描いた丸（角の丸め方を少しずつ変えて、ゆがませる） */
  .menu-nav button[aria-expanded="true"]::before {
    content: ""; position: absolute; inset: 6px -2px 4px -2px;
    border: 3px solid var(--pink);
    border-radius: 52% 46% 56% 44% / 58% 48% 52% 42%;
    transform: rotate(-4deg);
    filter: drop-shadow(2px 2px 0 var(--ink));
    pointer-events: none;
  }
}

/* スマホ（縦と横向き）：ロゴは小さく（--logo-w は、縦の板の上の端・横向きのメニューの左の端にも使われる）（11/20 ご主人様） */
@media (max-width: 599px), (min-width: 600px) and (max-height: 520px) {
  :root { --logo-w: 110px; }
  .brand { width: var(--logo-w); }
  /* 雨の間は、お化けを隠す（処理を軽くするため。描くのを止めるのは ghost.js の側） */
  #ghost { transition: opacity .8s; }
  body:has([data-weather="rain"][aria-pressed="true"]) #ghost { opacity: 0; }
}

@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 { justify-content: space-between; gap: 2px; }
  .menu-nav li { flex: 1 1 0; }
  /* 板は上（ロゴの下）に出す。キャラは js/content/fit.js が板の下の空きに収まる大きさまで小さくする（本家の形）。
     板の下の端は、画面の高さの 62% まで（キャラをいちばん小さくしても、雨の日の魔法陣まで収まる高さ）。
     長いときは板の中をスクロールする */
  .panel {
    left: 10px;
    right: 10px;
    top: calc(clamp(14px, 3vh, 32px) + var(--logo-w) * .67 + 8px);
    bottom: auto;
    width: auto;
    max-height: calc(62vh - (clamp(14px, 3vh, 32px) + var(--logo-w) * .67 + 8px));
    max-height: calc(62svh - (clamp(14px, 3vh, 32px) + var(--logo-w) * .67 + 8px));
    padding: 14px 16px 16px;
  }
  .panel h2 { font-size: 34px; margin-bottom: 8px; }
  .panel .close { top: 8px; right: 8px; }
  .panel .lead { margin-bottom: 10px; }
  /* Games：カードは1列（左に小さい絵、右に題名・ひとこと・ボタン）。3列だと文字が細切れになるため */
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto 1fr; column-gap: 12px; align-items: start; }
  .card .thumb { grid-row: 1 / 4; }
  .card h3 { margin-top: 0; }
  .card p { margin-bottom: 6px; }
  .card .btn { justify-self: start; }
  /* Works：PC と同じ横長のバナー。絵を小さく、間を詰める。ボタンは矢印だけの四角（文字は読み上げ用に残す） */
  .work { grid-template-columns: 84px minmax(0, 1fr) auto; column-gap: 10px; padding: 6px 8px 6px 6px; }
  .works { gap: 8px; }
  .work .btn { width: 40px; min-height: 40px; padding: 0; }
  .work .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* Profile：プロフィールの3つは横に3つのまま、小さく */
  .face { width: 72px; height: 72px; }
  .profile { gap: 14px; margin-bottom: 12px; }
  .profile .name { font-size: 28px; }
  .facts { gap: 6px; }
  .facts > div { padding: 6px 8px 8px; }
  .fact-ic { width: 30px; height: 30px; margin-bottom: 4px; }
  .fact-ic svg { width: 18px; height: 18px; }
  .facts dd { font-size: 14px; }
  .tags-row { margin-top: 10px; }
  /* Links：1件ずつの上下を詰める */
  .apps--list .app { padding: 8px 2px; }
  .panel h2 .kicker { font-size: 13px; }
  /* Apps：スマホの枠の上下を詰める */
  .phone { padding: 26px 12px 10px; }
  /* Contact：お名前とメールアドレスは横に並べたまま。本文欄を少し低く、間を詰める */
  .contact-form { gap: 6px 10px; }
  .contact-form textarea { height: 3.6em; }
}

/* ---- 横向き（高さの低い画面）：メニューはロゴの右に横1列、板は左に高さいっぱい（キャラの左の空きまで） ---- */
/* --char-left は js/content/fit.js が書く（左の猫の左の端の画面の x） */
@media (min-width: 600px) and (max-height: 520px) {
  .menu-nav {
    left: calc(var(--edge) + var(--logo-w) + 16px);
    top: clamp(14px, 3vh, 32px);
    bottom: auto;
  }
  .menu-nav ul { align-items: center; gap: 6px 18px; flex-wrap: wrap; }
  .menu-nav li { flex: none; }
  .menu-nav .lbl { font-size: 17px; }
  .panel {
    left: var(--edge);
    top: 62px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: max(300px, min(440px, calc(var(--char-left, 50vw) - var(--edge) - 14px)));
    max-height: none;
    padding: 14px 18px 16px;
  }
  .panel h2 { font-size: 34px; margin-bottom: 8px; }
  .panel .close { top: 8px; right: 8px; }
  /* 板を開いている間は、板の下になるロゴを消す（すりガラス越しに透けて読みにくいため） */
  body.menu-open .brand { opacity: 0; transition: opacity .25s; }
  .brand { transition: opacity .25s; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto 1fr; column-gap: 12px; align-items: start; }
  .card .thumb { grid-row: 1 / 4; }
  .card h3 { margin-top: 0; }
  .card p { margin-bottom: 6px; }
  .card .btn { justify-self: start; }
  .work { grid-template-columns: 96px minmax(0, 1fr); row-gap: 8px; padding: 6px 10px 8px 6px; }
  .work-img { grid-row: span 2; align-self: start; }
  .work .btn { justify-self: start; }
  .face { width: 76px; height: 76px; }
  .facts { grid-template-columns: 1fr; gap: 6px; }
  .facts > div { display: grid; grid-template-columns: 36px 1fr; column-gap: 10px; align-items: center; padding: 8px 10px; }
  .fact-ic { grid-row: span 2; margin-bottom: 0; }
  .panel h2 .kicker { font-size: 13px; }
  .contact-form { gap: 6px 10px; }
}

@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; }
  .menu-nav button { transition: none; }
}

/* 3D のお化け（ghost.js）を描く canvas。舞台の上に重ね、押せるかどうかは ghost.js の側で見る */
#ghost { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
