/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0c;
  --bg-room: #0f0f12;
  --bg-card: #16161a;
  --bg-yietter: #0e1117;
  --text: #c8c8cc;
  --text-dim: #6b6b72;
  --text-bright: #e8e8ec;
  --accent: #d4a053;
  --accent-dim: #8a6a3a;
  --danger: #c45c5c;
  --link: #6ba3d4;
  --border: #2a2a30;
  --font-body: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-mono: "Source Code Pro", "Noto Sans Mono", monospace;
  --transition-scene: 800ms;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.8;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ===== Scene Container ===== */
#app {
  position: relative;
  width: 100%;
  min-height: 100dvh;
}

.scene {
  display: none;
  width: 100%;
  min-height: 100dvh;
  opacity: 0;
  transition: opacity var(--transition-scene) ease;
}

.scene.active {
  display: flex;
  flex-direction: column;
}

.scene.visible {
  opacity: 1;
}

/* ===== Scene: Title ===== */
#scene-title {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.title-icon {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.title-main {
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
}

.title-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 3rem;
  line-height: 2;
}

.title-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  line-height: 2;
}

.btn-start {
  background: none;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.8rem 3rem;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 300ms ease;
}

.btn-start:hover {
  background: var(--accent-dim);
  color: var(--bg);
  border-color: var(--accent);
}

/* ===== Scene: Room (GM Dialogue) ===== */
#scene-room {
  align-items: center;
  padding: 0;
}

.room-container {
  width: 100%;
  max-width: 640px;
  padding: 2rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.room-log {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.msg {
  margin-bottom: 1.5rem;
  animation: msg-in 600ms ease both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-narrator {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 2;
}

.msg-gm {
  color: var(--text);
  line-height: 2;
  padding-left: 1rem;
  border-left: 2px solid var(--accent-dim);
}

.msg-player {
  color: var(--accent);
  text-align: right;
  padding-right: 1rem;
  border-right: 2px solid var(--accent-dim);
}

.room-input-area {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: auto;
}

.room-input-area.hidden { display: none; }

.room-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.8;
  padding: 0.8rem 1rem;
  resize: none;
  min-height: 80px;
  border-radius: 2px;
  outline: none;
  transition: border-color 200ms;
}

.room-textarea:focus {
  border-color: var(--accent-dim);
}

.room-textarea::placeholder {
  color: var(--text-dim);
}

.room-send {
  display: block;
  margin-top: 0.5rem;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  transition: all 200ms;
}

.room-send:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* Choice buttons (Turn 4, 5) */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.choice-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.8rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 200ms;
  line-height: 1.6;
}

.choice-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ===== Scene: Character Sheet ===== */
#scene-sheet {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  max-width: 480px;
  width: 100%;
  padding: 2rem;
}

.sheet-header {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.sheet-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.sheet-field {
  margin-bottom: 1.2rem;
}

.sheet-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}

.sheet-value {
  color: var(--text-bright);
  font-size: 0.95rem;
  line-height: 1.6;
}

.sheet-value.redacted {
  background: var(--text-dim);
  color: var(--text-dim);
  user-select: none;
}

.sheet-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.sheet-footer {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.8;
}

.sheet-footer-small {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 1rem;
  opacity: 0.5;
}

/* ===== Scene: Post (X + Yietter) ===== */
#scene-post {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.post-container {
  max-width: 480px;
  width: 100%;
}

.post-gm-text {
  color: var(--text);
  line-height: 2;
  margin-bottom: 2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent-dim);
}

.post-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
}

.post-targets {
  margin-bottom: 1.5rem;
}

.post-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.post-check input[type="checkbox"] {
  accent-color: var(--accent);
}

.post-actions {
  display: flex;
  gap: 0.8rem;
}

.post-actions .btn-start {
  flex: 1;
  text-align: center;
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.8rem 2rem;
  cursor: pointer;
  flex: 1;
  text-align: center;
  transition: all 300ms ease;
}

.btn-secondary:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

/* ===== Scene: Yietter ===== */
#scene-yietter {
  align-items: center;
  padding: 0;
  background: var(--bg-yietter);
}

.yietter-container {
  width: 100%;
  max-width: 580px;
  min-height: 100dvh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.yietter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-yietter);
  z-index: 10;
}

.yietter-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.05em;
}

.yietter-notif {
  position: relative;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
}

.yietter-notif .badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yietter-notif .badge.hidden { display: none; }

.yietter-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.yietter-tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 200ms;
}

.yietter-tab.active {
  color: var(--text-bright);
  border-bottom-color: var(--accent);
}

.yietter-feed {
  padding: 0;
}

.yietter-post {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  animation: msg-in 400ms ease both;
}

.yietter-post-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.yietter-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
  overflow: hidden;
}

.yietter-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yietter-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-bright);
}

.yietter-handle {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.yietter-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-left: auto;
}

.yietter-post-body {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text);
  padding-left: calc(36px + 0.5rem);
}

.yietter-post-body .hashtag {
  color: var(--link);
  cursor: pointer;
}

.yietter-post.clickable { cursor: pointer; }
.yietter-post.clickable:hover { background: rgba(255,255,255,0.02); }

/* ===== Scene: END-D (Reversal) ===== */
#scene-endd {
  align-items: center;
  padding: 0;
}

/* Reuses .room-container, .msg, .choices etc. */

/* ===== Scene: Endroll ===== */
#scene-endroll {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.endroll-text {
  max-width: 480px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 2.2;
  margin-bottom: 2rem;
}

.endroll-text em {
  color: var(--text);
  font-style: normal;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

.fade-in {
  animation: fade-in 800ms ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.delay-1 { animation-delay: 300ms; }
.delay-2 { animation-delay: 600ms; }
.delay-3 { animation-delay: 900ms; }
.delay-4 { animation-delay: 1200ms; }
.delay-5 { animation-delay: 1500ms; }

/* ===== Loading / Thinking ===== */
.thinking {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem 0;
}

.thinking span {
  width: 6px;
  height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .room-container { padding: 1.5rem 1rem; }
  .sheet-card { padding: 1.5rem; }
  .title-main { font-size: 1.2rem; }
}

/* ===== Yietter: Message Overlay ===== */
.yietter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.yietter-overlay.active { display: flex; }

.yietter-msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  max-width: 480px;
  width: 100%;
  max-height: 80dvh;
  overflow-y: auto;
  padding: 1.5rem;
}

.yietter-msg-type {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.8rem;
}

.yietter-msg-from {
  font-size: 0.85rem;
  color: var(--text-bright);
  margin-bottom: 0.3rem;
}

.yietter-msg-subject {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.yietter-msg-body {
  font-size: 0.9rem;
  line-height: 2;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.yietter-msg-actions {
  display: flex;
  gap: 0.5rem;
}

.yietter-msg-actions button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.6rem;
  cursor: pointer;
  transition: all 200ms;
}

.yietter-msg-actions button:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* Follow-up after reply */
.yietter-msg-followup {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text);
  animation: msg-in 400ms ease both;
}

/* GM voice overlay on Yietter */
.gm-voice-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(10,10,12,0.95) 30%);
  padding: 3rem 1.5rem 2rem;
  z-index: 50;
  text-align: center;
  display: none;
}

.gm-voice-overlay.active { display: block; }

.gm-voice-text {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 2;
  max-width: 480px;
  margin: 0 auto 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent-dim);
  text-align: left;
}

.gm-voice-overlay .btn-start {
  font-size: 0.85rem;
  padding: 0.6rem 2rem;
}

/* Notification list */
.yietter-notif-list {
  padding: 0;
}

.yietter-notif-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 200ms;
  animation: msg-in 400ms ease both;
}

.yietter-notif-item:hover { background: rgba(255,255,255,0.02); }

.yietter-notif-item .notif-type {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.yietter-notif-item .notif-preview {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.3rem;
  line-height: 1.6;
}

.yietter-notif-item .notif-from {
  font-size: 0.8rem;
  color: var(--text-bright);
  font-weight: 700;
}

.yietter-notif-item.read { opacity: 0.5; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.5;
  line-height: 1.8;
}

/* ===== BGM Note ===== */
.bgm-note {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 1.5rem;
  opacity: 0.5;
}

/* ===== Section Label ===== */
.section-label {
  margin-bottom: 0.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
}

.sheet-prologue {
  font-size: 0.8rem;
  line-height: 1.9;
  color: var(--text-dim);
}

/* ===== Yietter Profile ===== */
.yietter-profile {
  padding: 0;
}

.yietter-profile-header {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.yietter-profile-back {
  display: block;
  text-align: left;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--link);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-body);
}

.yietter-profile-back:hover { text-decoration: underline; }

.yietter-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 0.8rem;
  border: 2px solid var(--border);
}

.yietter-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yietter-profile-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
}

.yietter-profile-handle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.yietter-profile-bio {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  margin-top: 0.5rem;
}

.yietter-profile-class {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
}

.yietter-profile-tl-header {
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ===== Yietter Continue Button ===== */
.yietter-continue {
  padding: 2rem 1rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ===== BGM Toggle ===== */
.bgm-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms;
}

.bgm-toggle:hover { border-color: var(--accent-dim); color: var(--accent); }
