* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #1e2329; font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif; color: #222; }
button { font: inherit; cursor: pointer; border: none; background: none; }
button:disabled { cursor: default; opacity: .45; }
.hidden { display: none !important; }

#app { position: relative; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto; background: #fff; overflow: hidden; box-shadow: 0 0 30px rgba(0, 0, 0, .5); }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

.btn { display: block; width: 100%; padding: 12px; border-radius: 10px; background: #eef0f3; color: #333; font-weight: bold; transition: transform .08s, filter .15s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: #06c755; color: #fff; }
.btn.small { width: auto; padding: 9px 16px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; font-size: 30px; line-height: 30px; color: #333; }

/* タイトル */
#screen-title { background: radial-gradient(circle at 50% 20%, #2d3b52 0%, #12161d 70%); color: #fff; justify-content: center; }
.title-inner { padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center; }
.logo { font-size: 64px; font-weight: 900; letter-spacing: 6px; color: #06c755; text-shadow: 0 0 24px rgba(6, 199, 85, .55); }
.subtitle { font-size: 18px; letter-spacing: 3px; margin-top: -8px; }
.lead { font-size: 14px; line-height: 1.9; color: #c9d1dc; margin: 10px 0; }
.name-label { font-size: 13px; color: #c9d1dc; display: flex; flex-direction: column; gap: 6px; }
.name-label input { padding: 10px; border-radius: 8px; border: 1px solid #45526a; background: #1b222d; color: #fff; font-size: 16px; text-align: center; }
#ending-collection { font-size: 12px; color: #9aa6b6; line-height: 1.8; margin-top: 8px; }
#ending-collection .got { color: #ffd76a; }

/* バー */
.bar { height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: #fff; border-bottom: 1px solid #e5e5e5; flex-shrink: 0; }
.bar-title { font-size: 20px; font-weight: bold; }
.bar-info { display: flex; gap: 12px; font-size: 13px; color: #555; align-items: center; }
#ap-label { color: #06c755; letter-spacing: 2px; font-size: 15px; }
.room-bar { background: #2b3647; color: #fff; border: none; font-weight: bold; }
.room-bar .icon-btn { color: #fff; }

/* トーク一覧 */
#talk-list { list-style: none; flex: 1; overflow-y: auto; }
.talk-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f2f2f2; }
.talk-item:hover { background: #f7f8fa; }
.talk-item.locked { opacity: .5; }
.talk-main { flex: 1; min-width: 0; }
.talk-name { font-weight: bold; font-size: 15px; }
.talk-preview { font-size: 13px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.talk-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: #aaa; }
.badge { background: #06c755; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; font-weight: bold; }
.tag { border: 1px solid #ccc; border-radius: 6px; padding: 0 5px; }
.list-footer { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid #eee; flex-shrink: 0; }

.avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 18px; }
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }

/* トークルーム */
#messages { flex: 1; overflow-y: auto; background: #8cabd9; padding: 12px 10px 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; align-items: flex-end; gap: 6px; animation: pop .22s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.other { align-items: flex-start; }
.msg .body { display: flex; flex-direction: column; gap: 3px; max-width: 72%; }
.msg .name { font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.bubble { background: #fff; padding: 9px 12px; border-radius: 18px; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.other .bubble { border-top-left-radius: 4px; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: #8de055; border-top-right-radius: 4px; max-width: 72%; }
.msg .read { font-size: 10px; color: #f2f5fa; }
.msg.sys, .msg.date { justify-content: center; }
.msg.sys span { background: rgba(30, 40, 60, .35); color: #fff; font-size: 12px; padding: 5px 12px; border-radius: 12px; max-width: 88%; text-align: center; line-height: 1.6; white-space: pre-wrap; }
.msg.date span { background: rgba(30, 40, 60, .25); color: #fff; font-size: 11px; padding: 2px 12px; border-radius: 10px; }
.stamp { font-size: 30px; padding: 6px 10px; background: rgba(255, 255, 255, .85); border-radius: 16px; }
.bubble.revoked { background: transparent; border: 1px dashed rgba(255,255,255,.5); color: #fff; font-size: 11.5px; font-style: italic; }
.msg .mtime { font-size: 10px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); align-self: flex-end; margin: 0 2px 3px; }
.bubble.letter { background: #f7f0dd; color: #4a3f28; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; border: 1px solid #d8cba6; border-radius: 4px; line-height: 1.8; padding: 14px 16px; }
.typing .bubble { display: flex; gap: 4px; padding: 13px 14px; }
.typing .dot { width: 7px; height: 7px; border-radius: 50%; background: #aab; animation: blink 1s infinite; }
.typing .dot:nth-child(2) { animation-delay: .15s; }
.typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

#choices { background: #f4f5f7; border-top: 1px solid #dde; padding: 10px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; min-height: 58px; justify-content: center; }
.choice-btn { text-align: left; background: #fff; border: 1px solid #cfd6e0; border-radius: 20px; padding: 10px 16px; font-size: 14px; color: #1d3a63; transition: background .12s; }
.choice-btn:hover { background: #eaf7ef; border-color: #06c755; }
.panel-info { text-align: center; font-size: 13px; color: #777; }

/* トースト */
#toast { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 20; }
.toast-item { background: rgba(20, 25, 35, .88); color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 13px; animation: toast 2.2s forwards; white-space: nowrap; }
.toast-item .up { color: #ff7aa8; }
.toast-item .down { color: #8fb4ff; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 12%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* モーダル */
#modal { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; z-index: 30; }
.modal-box { background: #fff; border-radius: 14px; padding: 22px; width: 82%; }
.modal-box p { font-size: 15px; line-height: 1.7; white-space: pre-wrap; margin-bottom: 18px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; }

/* ステータス */
#status-body { flex: 1; overflow-y: auto; padding: 14px; background: #f4f5f7; display: flex; flex-direction: column; gap: 12px; }
.card { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.card-head .nm { font-weight: bold; font-size: 16px; }
.card-head .sub { font-size: 12px; color: #888; }
.gauge { height: 10px; background: #eee; border-radius: 5px; overflow: hidden; position: relative; }
.gauge > div { height: 100%; background: linear-gradient(90deg, #ff9ab8, #ff4f86); }
.gauge-marks { display: flex; justify-content: space-between; font-size: 10px; color: #aaa; margin: 2px 0 8px; }
.card dl { font-size: 13px; line-height: 1.7; }
.card dt { color: #888; font-size: 11px; margin-top: 6px; }
.skill { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eee; color: #aaa; }
.skill.on { background: #06c755; color: #fff; }

/* エンディング */
#screen-ending { background: #0f131a; color: #fff; }
#ending-body { flex: 1; overflow-y: auto; padding: 48px 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.end-type { letter-spacing: 6px; color: #9aa6b6; font-size: 13px; }
.end-title { font-size: 28px; font-weight: 900; color: #ffd76a; }
.end-note { font-size: 13px; color: #c9d1dc; line-height: 1.9; white-space: pre-wrap; }

/* デバッグ */
#debug-panel { position: fixed; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .85); color: #fff; padding: 10px; border-radius: 8px; font-size: 12px; z-index: 99; display: flex; flex-direction: column; gap: 4px; }
#debug-panel input[type=number] { width: 56px; }
#debug-panel button { background: #444; color: #fff; padding: 3px 6px; border-radius: 4px; }

/* ステータスバー（擬スマホ） */
#statusbar { position: absolute; top: 0; left: 0; right: 0; height: 26px; z-index: 40; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; background: rgba(255,255,255,.92); font-size: 12px; font-weight: bold; color: #333; transition: background .8s, color .8s; }
#statusbar.night { background: rgba(20,24,34,.92); color: #dde; }
#statusbar .batt { color: #06c755; letter-spacing: 1px; }
.screen { top: 26px; }

/* 通知バナー */
#banners { position: absolute; top: 30px; left: 0; right: 0; z-index: 45; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.banner { pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 88%; max-width: 380px; background: rgba(28,32,42,.94); color: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.35); animation: banner-in .35s ease-out; cursor: pointer; }
.banner.out { animation: banner-out .4s forwards; }
.banner-body { min-width: 0; flex: 1; }
.banner-name { font-size: 12px; font-weight: bold; }
.banner-text { font-size: 12px; color: #cfd6e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes banner-in { from { transform: translateY(-120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes banner-out { to { transform: translateY(-120%); opacity: 0; } }

/* 日付カード */
.daycard { position: absolute; inset: 0; z-index: 50; background: #06080d; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; opacity: 0; pointer-events: none; transition: opacity .5s; }
.daycard.show { opacity: 1; pointer-events: auto; }
.dc-line { font-size: 30px; font-weight: 900; letter-spacing: 4px; }
.dc1 { font-size: 15px; font-weight: normal; color: #aab; letter-spacing: 2px; }
.daycard.battle .dc-line { color: #ff9d7a; text-shadow: 0 0 22px rgba(255,90,60,.5); }
.daycard.night .dc-line { color: #9fb4d8; }

/* 時間帯の背景 */
#messages.bg-day { background: #8cabd9; }
#messages.bg-evening { background: #b49ac9; }
#messages.bg-night { background: #3d4a6b; }
#messages.bg-battle { background: #2a1520; animation: pulse-bg 3s infinite; }
#messages.bg-night .msg .read, #messages.bg-battle .msg .read { color: #cfd6e8; }
@keyframes pulse-bg { 0%,100% { background: #2a1520; } 50% { background: #371a26; } }

/* 四択グリッド */
#choices.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: center; }
#choices.grid .choice-btn { border-radius: 14px; text-align: center; padding: 12px 8px; font-size: 13.5px; }

/* アイコン画像 */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* 夜タグ・サウンドボタン・実績 */
.night-tag { border-color: #7d92c9; color: #7d92c9; }
.talk-item.night { background: #f2f4fb; }
.sound-btn { font-size: 17px; padding: 2px 4px; }
#btn-ff { font-size: 17px; width: 36px; height: 36px; }
#btn-ff.active { color: #06c755; }
#ach-collection { font-size: 11px; color: #9aa6b6; line-height: 1.9; margin-top: 4px; }
#ach-collection .got { color: #ffd76a; }
.ach-off { opacity: .55; }
.memo { letter-spacing: 2px; }

/* 魔王ゲージ */
#maou-gauge { display: flex; align-items: center; gap: 5px; padding: 6px 12px; background: #1c1018; flex-shrink: 0; }
.mg-label { font-size: 11px; color: #d08; color: #e08aa8; margin-right: 4px; letter-spacing: 2px; }
.mg-seg { flex: 1; height: 10px; border-radius: 5px; background: #3a2434; border: 1px solid #5b3a52; transition: background .5s, opacity .5s; }
.mg-seg.success { background: #ff5f7a; box-shadow: 0 0 8px #ff5f7a; }
.mg-seg.partial { background: linear-gradient(90deg, #ff5f7a 50%, #3a2434 50%); }
.mg-seg.fail { background: #241a22; opacity: .5; }
#screen-room.battle .room-bar { background: #3d2030; }

/* シェイク・フラッシュ */
#screen-room.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-8px); } 45% { transform: translateX(7px); } 70% { transform: translateX(-4px); } }
.flash { position: absolute; inset: 0; background: #fff; opacity: .85; pointer-events: none; animation: flashout .5s forwards; }
@keyframes flashout { to { opacity: 0; } }

/* ---------- コレクション画面 ---------- */
#screen-collection { background: #f4f5f7; }
#collection-body { flex: 1; overflow-y: auto; padding: 12px; }
.col-head { font-size: 13px; color: #555; margin: 14px 4px 8px; border-bottom: 1px solid #ddd; padding-bottom: 4px; letter-spacing: 2px; }
.col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.col-card { background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; padding: 10px; font-size: 12px; }
.col-type { font-size: 10px; font-weight: 700; letter-spacing: .08em; margin-bottom: 4px; color: #999; }
.col-card.t-true .col-type { color: #d4a72c; }
.col-card.t-good .col-type { color: #06c755; }
.col-card.t-bad .col-type { color: #e0564f; }
.col-card.t-normal .col-type { color: #4a7fb5; }
.col-title { font-weight: bold; margin-bottom: 4px; }
.col-desc { color: #888; font-size: 11px; line-height: 1.5; }
.col-ach { background: #fff; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 12px; opacity: .55; border: 1px solid #e5e5e5; }
.col-ach.got { opacity: 1; }
.col-ach-name { font-weight: bold; }
.col-ach-desc { color: #888; font-size: 11px; margin-top: 2px; }
#title-summary { font-size: 12px; color: #9aa6b6; }
#day-select { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#day-select .btn { width: auto; padding: 8px 14px; background: #2b3647; color: #fff; }

/* ---------- メニュー（セーブ枠） ---------- */
#menu { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 70; }
.menu-box { background: #fff; border-radius: 14px; padding: 16px; width: 86%; max-height: 88%; overflow-y: auto; }
.menu-title { font-weight: bold; text-align: center; margin-bottom: 10px; }
.menu-sec { font-size: 11px; color: #999; margin: 12px 0 6px; border-bottom: 1px solid #eee; padding-bottom: 3px; letter-spacing: 2px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot-btn { background: #f4f5f7; border: 1px solid #dde; border-radius: 8px; padding: 8px 12px; text-align: left; font-size: 12px; font-family: inherit; }
.slot-btn b { display: block; font-size: 12px; }
.slot-btn span { color: #888; font-size: 11px; }
.slot-btn .empty { font-style: italic; }
.menu-btns { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.dim { color: #999; font-size: 12px; }

/* ---------- 絆ノート改訂 ---------- */
.card-body { padding-top: 2px; }
.info-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: #f0f2f5; border: 1px solid #dde; border-radius: 999px; padding: 3px 10px; font-size: 11px; color: #444; }
.chip.dim { border-style: dashed; }
.memo-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.memo-chip { border-radius: 999px; padding: 3px 10px; font-size: 11px; border: 1px solid #dde; background: #fff; }
.memo-chip.mp { color: #0aa355; border-color: #bfe8cf; background: #f0fbf4; }
.memo-chip.mm { color: #e0564f; border-color: #f0cdc8; background: #fdf2f0; }
.memo-chip.mz { color: #a8862c; border-color: #e8dcbd; background: #fbf8ee; }
.secret-box { background: #fffbe8; border: 1px solid #eadfae; border-radius: 8px; padding: 8px 10px; margin: 10px 0; font-size: 12px; line-height: 1.6; }
.secret-h { font-size: 10px; color: #a8862c; letter-spacing: .12em; margin-bottom: 4px; }
.secret-box ul { margin: 0; padding-left: 18px; }
.secret-box li { margin: 3px 0; }
.profile-line { margin-top: 8px; font-size: 11px; line-height: 1.6; }
#ending-body .btn { max-width: 240px; }
