/* また来てね：控えめな UI（白〜灰色の細い文字、小さめ）。単位は画面（16:9）の幅に対する cqw。 */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  color: #c8c4bc;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
[hidden] { display: none !important; }

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  transform: translate(-50%, -50%);
  container-type: size;
  overflow: hidden;
  background: #000;
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* --- 画面（タイトル・注意書きなど） --- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #050505;
  gap: 1.2cqw;
}
.screen.veil { background: rgba(0, 0, 0, 0.62); }
/* 一時停止：ほぼ黒の幕（景色が透けて文字と重ならないように）。字間は詰めて、操作の説明はボタンの下に */
#screen-pause { background: rgba(0, 0, 0, 0.85); }
#screen-pause h2 { letter-spacing: 0.2em; padding-left: 0.2em; }
#screen-pause .menu button { letter-spacing: 0.1em; }
#screen-pause p.pause-controls {
  margin-top: 2.2cqw;
  max-width: 62%;
  font-size: 0.95cqw;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: #8a867f;
}
.screen h1 {
  margin: 0;
  font-size: 4.2cqw;
  font-weight: 300;
  letter-spacing: 0.6em;
  padding-left: 0.6em;
  color: #d8d4cc;
}
.screen h2 {
  margin: 0;
  font-size: 2.2cqw;
  font-weight: 300;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
}
.screen .sub {
  font-size: 1.05cqw;
  letter-spacing: 0.4em;
  color: #6f6c66;
}
.screen p { margin: 0; font-size: 1.35cqw; letter-spacing: 0.08em; line-height: 1.9; }
.screen p.dim { color: #7c7871; font-size: 1.1cqw; }
.screen p.controls { position: absolute; bottom: 4cqw; font-size: 0.95cqw; color: #77736c; }
.screen .credit { position: absolute; bottom: 2.4cqw; font-size: 0.8cqw; letter-spacing: 0.3em; color: #44423e; }
/* タイトル：背景はゲームの中のバス停（canvas）をそのまま見せる。文字が読めるように、まわりと下を少しだけ暗く */
#screen-title {
  background:
    radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.42) 75%, rgba(0, 0, 0, 0.7) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45) 100%);
  justify-content: center;
  padding-bottom: 7cqw; /* 文字のかたまりを、画面の中央より少し上に */
}
.title-head { display: flex; flex-direction: column; align-items: center; gap: 1.1cqw; }
#screen-title h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "BIZ UDPMincho", "MS PMincho", serif;
  font-size: 3.4cqw;
  color: #dedad3;
  text-shadow: 0 0 1.2cqw rgba(0, 0, 0, 0.55);
}
#screen-title .sub { color: #8f8b84; text-shadow: 0 0 0.6cqw rgba(0, 0, 0, 0.6); }
#screen-title button { text-shadow: 0 0 0.5cqw rgba(0, 0, 0, 0.8); }
#screen-title .credit { color: #5c5a55; }
/* 「おかえり」：エンドを1つ以上見たあと、タイトルが出て1秒ほどして、うすく一瞬だけ（場所はとっておき、ずれないように） */
#title-welcome { height: 1.6cqw; font-size: 1.05cqw; letter-spacing: 0.5em; padding-left: 0.5em; color: #b9b4aa; opacity: 0; }
#title-welcome.show { animation: welcome 2.4s ease-in-out 1s forwards; }
@keyframes welcome { 0% { opacity: 0; } 35% { opacity: 0.42; } 55% { opacity: 0.42; } 100% { opacity: 0; } }

/* エンド一覧：タイトルの背景の上に、暗い幕 */
#screen-endlist { background: rgba(3, 3, 3, 0.86); gap: 0; }
#endlist-count { margin-top: 1.2cqw; font-size: 1.0cqw; letter-spacing: 0.3em; color: #8a867f; }
#endlist-rows { margin-top: 2.2cqw; display: flex; flex-direction: column; gap: 1.5cqw; align-items: center; }
.endlist-row { display: flex; flex-direction: column; align-items: center; gap: 0.3cqw; }
.endlist-row .name { font-size: 1.3cqw; letter-spacing: 0.25em; color: #cfcac0; }
.endlist-row.unseen .name { color: #6f6c66; letter-spacing: 0.5em; padding-left: 0.5em; }
.endlist-row .line { font-size: 0.92cqw; letter-spacing: 0.08em; color: #8f8a81; line-height: 1.6; }
.endlist-row .hint { font-size: 0.88cqw; letter-spacing: 0.1em; color: #57544f; }
#endlist-complete { margin-top: 2.2cqw; font-size: 1.1cqw; letter-spacing: 0.5em; padding-left: 0.5em; color: #b4afa5; }
.endlist-foot { margin-top: 2.4cqw; display: flex; flex-direction: column; align-items: center; gap: 0.5cqw; }
#endlist-confirm { display: flex; align-items: center; gap: 0.6cqw; font-size: 0.95cqw; letter-spacing: 0.12em; color: #a39e95; }
button.tiny { font-size: 0.8cqw; color: #5f5c57; letter-spacing: 0.2em; }

/* 注意書きの操作の説明（3行） */
.screen p.howto { margin-top: 1.6cqw; font-size: 0.95cqw; line-height: 1.9; color: #77736c; white-space: pre-line; }

.menu { display: flex; flex-direction: column; gap: 0.5cqw; margin-top: 2.4cqw; align-items: center; }

button {
  font: inherit;
  font-size: 1.3cqw;
  letter-spacing: 0.25em;
  color: #c8c4bc;
  background: none;
  border: none;
  padding: 0.4cqw 1.6cqw;
  cursor: pointer;
  opacity: 0.85;
}
button.quiet { font-size: 1.0cqw; color: #8a867f; }
button:hover, button:focus-visible { opacity: 1; color: #f0ece4; outline: none; }
button:hover::before, button:focus-visible::before { content: "— "; }
button:hover::after, button:focus-visible::after { content: " —"; }

/* --- HUD --- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.22cqw;
  height: 0.22cqw;
  margin: -0.11cqw 0 0 -0.11cqw;
  background: rgba(220, 215, 205, 0.45);
  border-radius: 50%;
}
#prompt {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translateX(-50%);
  font-size: 0.95cqw;
  letter-spacing: 0.15em;
  color: rgba(220, 215, 205, 0.75);
}
#message {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  max-width: 64%;
  font-size: 1.25cqw;
  line-height: 1.7;
  letter-spacing: 0.06em;
  text-align: center;
  color: #d4d0c8;
  text-shadow: 0 0 0.4cqw #000, 0 0 0.2cqw #000;
  animation: fadein 0.5s ease-out;
}
/* 会話（画面下に1行ずつ） */
#dialogue {
  position: absolute;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  width: 60%;
  padding: 1cqw 2cqw 0.8cqw;
  text-align: center;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.55) 30%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0));
  animation: fadein 0.4s ease-out;
}
#dialogue-text {
  font-size: 1.35cqw;
  line-height: 1.8;
  letter-spacing: 0.08em;
  color: #dcd8d0;
  text-shadow: 0 0 0.4cqw #000, 0 0 0.2cqw #000;
}
#dialogue-options { display: flex; justify-content: center; gap: 2.4cqw; margin-top: 0.6cqw; }
#dialogue-options button { font-size: 1.1cqw; letter-spacing: 0.1em; pointer-events: auto; }
#dialogue-options button::before, #dialogue-options button::after { content: none; }
#dialogue-options button .key { color: #77736c; margin-right: 0.6em; }
#dialogue-hint { margin-top: 0.4cqw; font-size: 0.75cqw; letter-spacing: 0.15em; color: rgba(200, 195, 185, 0.45); }

/* 画面が一瞬ゆがむ（お茶を飲んだとき） */
#view.warp { animation: warp 0.5s ease-in-out; }
@keyframes warp {
  0% { transform: none; filter: none; }
  25% { transform: scale(1.018, 0.99) skewX(0.9deg); filter: blur(0.5px); }
  50% { transform: scale(0.992, 1.02) skewX(-0.7deg); filter: blur(0.8px); }
  75% { transform: scale(1.01, 1) skewX(0.3deg); filter: blur(0.3px); }
  100% { transform: none; filter: none; }
}

#notify {
  position: absolute;
  right: 2.2cqw;
  top: 2.2cqw;
  display: flex;
  align-items: center;
  gap: 0.5cqw;
  font-size: 0.85cqw;
  letter-spacing: 0.1em;
  color: rgba(210, 205, 195, 0.8);
}
#notify .icon {
  display: block;
  width: 0.9cqw;
  height: 1.6cqw;
  border: 0.12cqw solid rgba(210, 205, 195, 0.8);
  border-radius: 0.2cqw;
}
#notify-reply { margin-left: 0.4cqw; color: rgba(232, 228, 218, 0.92); }
#notify.buzz .icon { animation: buzz 0.09s linear 6; }
@keyframes buzz {
  0% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-0.12cqw) rotate(-4deg); }
  75% { transform: translateX(0.12cqw) rotate(4deg); }
  100% { transform: translateX(0) rotate(0); }
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* --- スマホ --- */
#phone-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
/* 上の時刻から下の書き込みの欄まで、画面（16:9）の高さの中に収める（傾きのぶんも上下に余白） */
#phone {
  position: absolute;
  left: 50%;
  top: 4%;
  height: 90%;
  aspect-ratio: 9 / 17;
  transform: translateX(-38%) rotate(-1deg);
  animation: phoneup 0.28s ease-out;
}
@keyframes phoneup { from { transform: translate(-38%, 18%) rotate(-1deg); opacity: 0; } }
.phone-body {
  width: 100%;
  height: 100%;
  padding: 3.5% 4%;
  background: #121212;
  border-radius: 1.6cqw;
  box-shadow: 0 0 0 0.15cqw #2a2a2a, 0 1cqw 3cqw rgba(0, 0, 0, 0.8);
}
.phone-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #1b1b1a;
  border-radius: 1.0cqw;
  overflow: hidden;
  font-family: "Hiragino Sans", "Yu Gothic", "YuGothic", "Meiryo", sans-serif;
  font-weight: 400;
  color: #bdb9b0;
}
.phone-status {
  display: flex;
  justify-content: space-between;
  padding: 0.5cqw 1cqw 0.3cqw;
  font-size: 0.7cqw;
  color: #807c75;
}
#phone.no-signal #phone-carrier { color: #b8573e; }
.phone-board { padding: 0 1cqw; font-size: 0.7cqw; color: #6c6963; }
.phone-title {
  padding: 0.2cqw 1cqw 0.6cqw;
  font-size: 0.9cqw;
  line-height: 1.45;
  color: #b8573e;
  border-bottom: 1px solid #2c2b29;
}
.phone-posts {
  flex: 1;
  overflow-y: auto;
  padding: 0.4cqw 1cqw 1cqw;
  scrollbar-width: none;
}
.phone-posts::-webkit-scrollbar { display: none; }
.post { padding: 0.6cqw 0; border-bottom: 1px solid #252423; }
.post .head { font-size: 0.66cqw; color: #7d7a73; line-height: 1.5; word-break: break-all; }
.post .head .no { color: #9a968e; }
.post .head .name { color: #6f8a5e; }
.post .body { margin-top: 0.25cqw; font-size: 0.82cqw; line-height: 1.6; white-space: pre-wrap; color: #c9c5bc; }
.post.self .head .uid { color: #a8a39a; text-decoration: underline; text-underline-offset: 0.15em; }
.post.new { animation: fadein 0.6s ease-out; }
/* 書き込む：ふつうの掲示板の返信フォームのように（見出し → 枠で囲んだ候補 → 選び方） */
.phone-reply { border-top: 1px solid #3a3835; padding: 0.6cqw 0.8cqw 0.5cqw; background: #1f1e1c; }
.phone-reply.flash { animation: replyflash 1s ease-out; }
@keyframes replyflash {
  0% { background: #4a463e; box-shadow: inset 0 0 0 1px #8f897d; }
  100% { background: #1f1e1c; box-shadow: inset 0 0 0 1px transparent; }
}
.phone-reply-head { font-size: 0.82cqw; color: #c9c5bc; margin-bottom: 0.4cqw; }
#phone-options { display: flex; flex-direction: column; gap: 0.3cqw; }
#phone-options button {
  display: flex;
  align-items: baseline;
  width: 100%;
  text-align: left;
  font-size: 0.82cqw;
  line-height: 1.5;
  letter-spacing: 0.04em;
  padding: 0.35cqw 0.5cqw;
  color: #e6e2d8;
  background: #262522;
  border: 1px solid #4d4a45;
  border-radius: 0.3cqw;
  opacity: 1;
  pointer-events: auto;
}
#phone-options button:hover, #phone-options button:focus-visible { background: #312f2b; border-color: #8a867f; color: #f4f0e8; }
#phone-options button::before, #phone-options button::after { content: none; }
#phone-options button .key { flex: none; color: #a8a39a; margin-right: 0.3em; }
.phone-reply-hint { margin-top: 0.35cqw; font-size: 0.7cqw; color: #8a867f; }
.phone-foot { padding: 0.3cqw 1cqw 0.5cqw; font-size: 0.58cqw; color: #55524d; text-align: center; }

/* --- 暗転・デバッグ --- */
#fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 2.4s ease-in; pointer-events: none; }
#fade.on { opacity: 1; }

/* エンドの画面：黒い画面に、エンドの名前と後日談（1行ずつ、ゆっくり出す） */
#screen-end { background: #000; }
#end-name { color: #cfcac0; }
#end-lines { margin-top: 2.6cqw; display: flex; flex-direction: column; gap: 0.7cqw; align-items: center; }
#end-lines p { opacity: 0; animation: endLine 2.2s ease-in forwards; color: #b8b3a9; }
#screen-end .menu { opacity: 0; animation: endLine 1.6s ease-in forwards; }
@keyframes endLine { to { opacity: 1; } }

/* 捕まったとき：白い布が画面いっぱいに近づく */
#cloth {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.25);
  background:
    repeating-linear-gradient(87deg, rgba(120, 112, 98, 0.18) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-3deg, rgba(90, 84, 72, 0.14) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 50% 45%, #b9b2a2 0%, #9d9686 55%, #4a463e 100%);
}
#cloth.on { animation: cloth 0.9s ease-in forwards; }
@keyframes cloth {
  0% { opacity: 0; transform: scale(0.25); }
  35% { opacity: 1; }
  100% { opacity: 1; transform: scale(1.6); }
}

/* スレが消えた（エンドD） */
.phone-gone { margin-top: 40%; text-align: center; font-size: 0.85cqw; color: #8a867e; letter-spacing: 0.1em; }
#debug {
  position: absolute;
  left: 0.6cqw;
  top: 0.6cqw;
  margin: 0;
  padding: 0.4cqw 0.6cqw;
  font: 0.75cqw/1.4 ui-monospace, Consolas, monospace;
  color: #9fe39f;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: pre;
  max-width: 40%;
  overflow: hidden;
}
