* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #05040a;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  /* 携帯で指を滑らせたときの「ページごと引っぱられる」動きを止める。
     盤面を撫でる操作がスクロールに化けると、歩けないまま画面だけ揺れる。 */
  overscroll-behavior: none; touch-action: none;
  -webkit-text-size-adjust: 100%;
}
/* iOS Safari のアドレス欄は出入りするので、100vh だと下端が隠れたり余ったりする。
   dvh はいま実際に見えている高さを指す（対応していない端末は 100% へ落ちる）。 */
#stage { position: fixed; inset: 0; height: 100%; }
@supports (height: 100dvh) { #stage { height: 100dvh; } }
#game {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: #07060c; cursor: pointer; touch-action: none;
}

/* 全画面の映像（オープニング／中間エンディング）。canvas の上・ログイン窓（z-index:1000）の下に敷く。
   16:9 の映像をどんな窓へも収めるので object-fit は contain（切らずに黒帯）——
   タイトル絵と違い、こちらは «見せたい絵» が全編に渡って動いているため。 */
.movie {
  position: fixed; inset: 0; z-index: 900;
  background: #000; display: grid; place-items: center;
  cursor: pointer;
}
.movie[hidden] { display: none; }
.movie-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.movie-skip {
  /* 切り欠き・ホームバーの内側へ。固定値だけだと、横向きの iPhone で
     ホームバーの下に潜って読めなくなる。 */
  position: absolute; margin: 0;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  font: 12px/1.4 "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  color: rgba(240,238,250,0.62); letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9); pointer-events: none;
}
/* 幕切れは黒へ沈める。映像側も末尾でフェードするので、二重に暗くならないよう
   こちらの淡色は最後の一瞬だけ効かせる。 */
.movie.is-closing { transition: opacity 380ms ease; opacity: 0; }

/* Account gate: a semantic DOM form sits above the canvas so password
   managers, IME input, keyboard focus, and screen readers work normally. */
.account-gate {
  position: fixed; inset: 0; z-index: 1000; overflow: auto;
  display: grid; place-items: center;
  /* 切り欠き・ホームバーの内側へ収める。padding を固定値だけにすると、
     iPhone では入力欄がホームバーの下へ潜って押せなくなる。 */
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  color: #f8f7ff; user-select: text; -webkit-user-select: text;
  background:
    radial-gradient(circle at 50% 22%, rgba(111, 78, 163, .34), transparent 32rem),
    linear-gradient(180deg, rgba(17, 13, 34, .97), rgba(4, 4, 12, .99));
}
.account-gate[hidden] { display: none; }
.account-window {
  position: relative; width: min(100%, 470px); padding: 35px 38px 30px;
  border: 3px solid #f4f3ff; border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 18, 48, .98), rgba(5, 7, 24, .99));
  box-shadow: 0 0 0 5px rgba(112, 119, 181, .5), 0 24px 70px rgba(0, 0, 0, .72), inset 0 1px rgba(255,255,255,.14);
}
.account-window::before {
  content: ""; position: absolute; inset: 8px; pointer-events: none;
  border: 1px solid rgba(170, 178, 232, .42); border-radius: 8px;
}
.account-crest {
  width: 64px; height: 64px; margin: -2px auto 9px; display: grid; place-items: center;
  border: 2px solid #f1d077; border-radius: 50%; color: #ffe492; font-size: 34px;
  background: radial-gradient(circle, #5d467d, #211a39 72%);
  box-shadow: 0 0 24px rgba(255, 211, 112, .22);
}
.account-kicker { color: #d9b85e; font-size: 12px; font-weight: 800; letter-spacing: .22em; text-align: center; }
.account-window h1 { margin-top: 5px; font-size: clamp(25px, 6vw, 34px); line-height: 1.25; text-align: center; }
.seo-heading {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.account-lead { margin: 8px 0 22px; color: #cbd0e9; font-size: 14px; line-height: 1.7; text-align: center; }
.account-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 20px; }
.account-tab, .account-submit, .account-reveal {
  min-height: 44px; border: 1px solid #777fae; border-radius: 7px; color: #e8eaff;
  background: #171b42; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.account-tab.is-active { border-color: #f1cf72; color: #ffe69d; background: #393052; box-shadow: inset 0 -3px #c99e43; }
.account-form { position: relative; z-index: 1; display: grid; gap: 7px; }
.account-form label { margin-top: 5px; color: #fff; font-size: 14px; font-weight: 800; }
.account-form input {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 2px solid #6d739d; border-radius: 7px;
  outline: none; color: #fff; caret-color: #ffe38a; background: #090c26;
  font-family: inherit; font-size: 16px; font-weight: 500; line-height: 1.2;
  user-select: text; -webkit-user-select: text;
}
.account-form input:focus { border-color: #f0cf71; box-shadow: 0 0 0 3px rgba(240, 207, 113, .2); }
.account-form input[aria-invalid="true"] { border-color: #ff8585; }
.account-password-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.account-reveal { min-width: 65px; padding: 0 12px; }
.account-help { color: #959dbf; font-size: 12px; line-height: 1.45; }
.account-confirm[hidden] { display: none; }
.account-error { margin: 7px 0 0; padding: 10px 12px; border-left: 4px solid #ff7777; color: #ffdada; background: rgba(116, 28, 40, .42); font-size: 13px; line-height: 1.55; }
.account-submit {
  margin-top: 12px; min-height: 52px; border-color: #e2b94e; color: #19101f;
  background: linear-gradient(#ffe696, #d8a93e); box-shadow: inset 0 1px #fff4c8, 0 5px 15px rgba(0,0,0,.32);
}
.account-submit:hover { filter: brightness(1.07); }
.account-submit:disabled, .account-tab:disabled, .account-reveal:disabled { cursor: wait; opacity: .62; }
.account-status { min-height: 20px; color: #a8efba; font-size: 12px; line-height: 1.5; text-align: center; }
.account-security { position: relative; z-index: 1; margin-top: 16px; color: #858eaf; font-size: 11px; line-height: 1.55; text-align: center; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

@media (max-width: 540px) {
  .account-gate { align-items: start; padding: 14px; }
  .account-window { margin: 8px 0; padding: 27px 22px 23px; }
  .account-crest { width: 54px; height: 54px; font-size: 29px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (prefers-contrast: more) {
  .account-window, .account-form input, .account-tab { border-color: #fff; }
  .account-help, .account-security { color: #d8dcf0; }
}
