* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: #0d1014; overflow: hidden; }
body { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; color: #e8e2d0; }

#stage { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
#glyphs path { stroke-linejoin: round; stroke-linecap: round; }

#loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 15px; letter-spacing: 0.2em; color: #9aa3ad; opacity: 0.9;
  transition: opacity 0.4s;
}
.hidden { display: none !important; }

#start-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: rgba(8, 10, 13, 0.55); backdrop-filter: blur(2px);
  cursor: pointer; z-index: 10;
}
#start-overlay p { font-size: 13px; letter-spacing: 0.25em; color: #b8bfc8; }
#btn-start {
  width: 92px; height: 92px; border-radius: 50%;
  border: 1px solid rgba(232, 226, 208, 0.5); background: rgba(232, 226, 208, 0.06);
  color: #e8e2d0; font-size: 30px; padding-left: 6px; cursor: pointer;
  transition: background 0.3s, transform 0.3s;
}
#btn-start:hover { background: rgba(232, 226, 208, 0.14); transform: scale(1.05); }

#hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 12px 18px; gap: 16px;
  opacity: 0.12; transition: opacity 0.35s;
  background: linear-gradient(transparent, rgba(5, 7, 9, 0.75));
}
#hud:hover { opacity: 1; }

/* 題名・作者は常時表示（背景が明るくても読めるよう影付き） */
#meta {
  position: fixed; top: 0; left: 0; z-index: 6;
  display: flex; gap: 10px; align-items: baseline; min-width: 0;
  max-width: 78vw; padding: 14px 18px;
  text-shadow: 0 1px 10px rgba(5, 7, 9, 0.95), 0 0 3px rgba(5, 7, 9, 0.9);
  pointer-events: none;
}
#work-title { font-size: 17px; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#work-author { font-size: 12.5px; color: #aab3bd; white-space: nowrap; }
#progress-pct { font-size: 11px; color: #9aa3ad; font-variant-numeric: tabular-nums; }
#buy-link {
  font-size: 11px; color: #c9a86a; text-decoration: none;
  opacity: 0.75; pointer-events: auto; white-space: nowrap;
}
#buy-link:hover { opacity: 1; text-decoration: underline; }

/* 青空文庫クレジット（タイトルカード表示中のみフェードイン） */
#credit {
  position: absolute; left: 0; right: 0; bottom: 8%;
  text-align: center; font-size: 11px; line-height: 1.9;
  letter-spacing: 0.06em; color: #97a0aa; padding: 0 24px;
  opacity: 0; transition: opacity 1.4s; pointer-events: none;
}
#credit.show { opacity: 0.85; }
#credit .cl { display: block; }
#credit .credit-sub { font-size: 10px; color: #7b8590; }

/* スマホ: 縦書き既定・コントロールは再生と「別の作品」のみ（間は既定2.5sで非表示） */
body.mobile #ctl-vertical, body.mobile #ctl-vol, body.mobile #ctl-pace { display: none; }
body.mobile #hud {
  opacity: 0.9; justify-content: center; padding: 14px 16px 18px;
  transition: opacity 0.6s;
}
body.mobile #hud.hud-hidden { opacity: 0; pointer-events: none; }
body.mobile #controls { gap: 20px; }
body.mobile #controls button { padding: 10px 18px; font-size: 14px; }
/* タイトルは省略せず、長ければ折り返して全文表示 */
body.mobile #meta { flex-wrap: wrap; row-gap: 2px; max-width: calc(100vw - 24px); }
body.mobile #work-title {
  font-size: 15px; white-space: normal; overflow: visible;
  text-overflow: clip; line-height: 1.45;
}
/* クレジットは改行を解いて左寄せの連続文に（タイトルとの重なり・端切れ改行を防ぐ） */
body.mobile #credit { font-size: 10px; bottom: 92px; text-align: left; line-height: 1.7; }
body.mobile #credit .cl { display: inline; }
body.mobile #credit .credit-sub { font-size: inherit; }

#progress {
  position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 7;
  background: rgba(232, 226, 208, 0.07);
}
#progress-fill {
  height: 100%; width: 0%;
  background: rgba(217, 164, 92, 0.55);
  transition: width 0.8s ease;
}

#controls { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
#controls button {
  background: rgba(232, 226, 208, 0.08); color: #e8e2d0;
  border: 1px solid rgba(232, 226, 208, 0.25); border-radius: 6px;
  padding: 6px 12px; font-size: 12px; font-family: inherit; cursor: pointer;
}
#controls button:hover { background: rgba(232, 226, 208, 0.18); }
#controls .seg { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #b8bfc8; cursor: pointer; }
#controls input[type="range"] { width: 90px; accent-color: #d9a45c; }
#controls input[type="checkbox"] { accent-color: #d9a45c; }
#pace-val { min-width: 34px; font-variant-numeric: tabular-nums; }
