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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
  font-family: 'Noto Serif JP', serif;
  color: #fff;
  touch-action: manipulation;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas {
  position: relative;
  width: min(100vw, calc(100dvh * 1080 / 1920), calc(100vh * 1080 / 1920));
  aspect-ratio: 1080 / 1920;
  background-color: #000;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  container-type: inline-size;
  overflow: hidden;
}

.canvas--input   { background-image: url('../img/page1_bg.jpg'); }
.canvas--success { background-image: url('../img/default.png'); }
.canvas--fail    { background-image: url('../img/page3_bg.jpg'); }

/* ===== パスコード入力枠 =====
   page1_frame_single.png (214×209) を各inputに個別背景として当てる
   canvas 1080×1920 に対して:
   - 枠幅: 214/1080 = 19.81%
   - 枠高: 209/1920 = 10.89%
   - フレーム中心: 19.58% / 39.86% / 60.14% / 80.42%
   - 各入力の left: 中心 - 幅/2 = 9.68% / 29.96% / 50.24% / 70.52% */
.passcode-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5%;         /* 実機で微調整 */
  height: 10.89%;
}

.passcode-input {
  position: absolute;
  top: 0;
  height: 100%;
  width: 19.81%;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  background-image: url('../img/page1_frame_single.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  outline: none;
  color: #ffd966;
  font-family: 'Noto Serif JP', serif;
  font-size: 11cqw;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  caret-color: transparent;
  text-shadow:
    0 0 12px rgba(255, 200, 50, 0.9),
    0 0 24px rgba(255, 150, 30, 0.6);
  transition: transform 0.15s ease;
  box-shadow: none;
}

.passcode-input:nth-child(1) { left: 9.68%; }
.passcode-input:nth-child(2) { left: 29.96%; }
.passcode-input:nth-child(3) { left: 50.24%; }
.passcode-input:nth-child(4) { left: 70.52%; }

.passcode-input:focus {
  transform: scale(1.06);
}

.passcode-wrap.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.passcode-wrap.success .passcode-input {
  animation: glow 0.3s ease-in-out;
}

@keyframes glow {
  0%, 100% {
    text-shadow: 0 0 12px rgba(255, 200, 50, 0.9), 0 0 24px rgba(255, 150, 30, 0.6);
  }
  50% {
    text-shadow: 0 0 30px rgba(255, 255, 200, 1), 0 0 60px rgba(255, 200, 50, 1);
  }
}

.flash-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease-out;
}

.flash-overlay.active {
  opacity: 1;
}

/* ===== 不正解ページ Xボタン ===== */
.x-button-link {
  position: absolute;
  left: 1.3%;
  right: 1.3%;
  bottom: 5.5%;       /* 実機で微調整 */
  aspect-ratio: 1052 / 203;
  background-image: url('../img/page3_xbutton.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: block;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.x-button-link:hover,
.x-button-link:active {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* ===== 準備中（Coming Soon）ページ ===== */
.stage--coming {
  flex-direction: column;
  text-align: center;
  padding: 8vw;
}

.coming-inner {
  animation: reveal 0.8s ease-out;
}

.coming-brand {
  margin-bottom: 1.8em;
  font-size: clamp(15px, 4.6vw, 24px);
  letter-spacing: 0.1em;
  color: #e8dcc0;
}

.coming-brand-name {
  display: block;
  margin-top: 0.45em;
  font-size: 1.5em;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #ffd966;
}

.coming-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(22px, 8vw, 60px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: #ffd966;
  text-shadow:
    0 0 18px rgba(255, 200, 50, 0.6),
    0 0 36px rgba(255, 150, 30, 0.4);
}

.coming-sub {
  margin-top: 1.4em;
  font-size: clamp(13px, 4vw, 18px);
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: #d8c9a0;
}

/* ===== 結果ページ登場演出 ===== */
.canvas--success { animation: reveal 0.7s ease-out; }
.canvas--fail    { animation: reveal 0.5s ease-out; }

@keyframes reveal {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
