/* Byakuya Gift Control — 白夜テーマ（紺・ラベンダー・銀・金） */
:root {
  --night: #0b0f2e; --night2: #161a4a; --violet: #3d3486; --lav: #b9a8ff; --lav2: #d8d0ff;
  --silver: #d9dcef; --gold: #ffd75e; --text: #eef0ff; --muted: #9a9cc4; --line: rgba(217, 220, 239, .14);
  --card: rgba(22, 26, 74, .72); --ok: #5ee0a0; --warn: #ffcc66; --ng: #ff7a8a;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #0b0f2e; }
body {
  color: var(--text); font: 15px/1.6 "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 70% -10%, #2c2670 0%, rgba(44,38,112,0) 60%),
              linear-gradient(180deg, #0b0f2e 0%, #121547 55%, #1d1a55 100%) fixed;
  -webkit-font-smoothing: antialiased;
}
body::before { /* 白夜の地平線 */
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 220px; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse 60% 100% at 55% 100%, rgba(255,255,255,.14), rgba(255,255,255,0));
}
a { color: var(--lav2); }
button, input, select, textarea { font: inherit; color: var(--text); }
input, select, textarea {
  background: rgba(11, 15, 46, .7); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lav); outline-offset: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: #9b86ff; padding: 0; }
input[type=range] { padding: 0; accent-color: #9b86ff; }
button {
  border: 1px solid var(--line); background: rgba(185,168,255,.12); border-radius: 12px; padding: 9px 14px; cursor: pointer;
  transition: background .15s, transform .1s;
}
button:hover { background: rgba(185,168,255,.22); }
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: linear-gradient(135deg, #cfc4ff, #8f7cf0); color: #120f3a; font-weight: 800; border: 0; }
button.gold { background: linear-gradient(135deg, #fff1b8, #f2c14e); color: #3a2a00; font-weight: 800; border: 0; }
button.danger { background: rgba(255,122,138,.14); color: #ffc1c9; }
button.small { padding: 5px 10px; font-size: 13px; border-radius: 9px; }

/* ===== レイアウト ===== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { padding: 26px 18px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 26px; }
.brand .logo { width: 40px; height: 40px; border-radius: 12px; }
.brand b { display: block; letter-spacing: .18em; font-size: 14px; color: var(--silver); }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--muted); }
.nav a .ic { width: 22px; text-align: center; }
.nav a.on { background: rgba(185,168,255,.16); color: #fff; box-shadow: inset 2px 0 0 var(--lav); }
.main { padding: 26px 30px 120px; max-width: 980px; width: 100%; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; flex: 1; }
.pc-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; background: rgba(11,15,46,.6); border: 1px solid var(--line); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #666a8f; display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); } .dot.ng { background: var(--ng); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(5, 4, 25, .35);
}
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--lav2); display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.field label, label.field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.big { font-size: 28px; font-weight: 800; }
.stat { background: rgba(11,15,46,.5); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat small { color: var(--muted); display: block; font-size: 12px; }
.stat b { font-size: 18px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* ギフトルール */
.rule { background: rgba(11,15,46,.55); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.rule.off { opacity: .55; }
.rule-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.gimg { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 24px;
  background: radial-gradient(circle, rgba(255,255,255,.9), rgba(200,190,255,.35) 55%, rgba(0,0,0,0) 72%); }
.gimg img { width: 38px; height: 38px; object-fit: contain; }
.rule-title { flex: 1; min-width: 0; }
.rule-title b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rule-title small { color: var(--muted); }
.rule .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

/* ギフトを選ぶ */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px; border-radius: 14px;
  background: rgba(11,15,46,.55); border: 1px solid var(--line); min-height: 128px; }
.pick:hover { background: rgba(185,168,255,.16); }
.pick.on { border-color: var(--lav); background: rgba(185,168,255,.14); }
.pick-img { width: 64px; height: 64px; display: grid; place-items: center; font-size: 36px;
  background: radial-gradient(circle, rgba(255,255,255,.85), rgba(200,190,255,.25) 60%, rgba(0,0,0,0) 72%); border-radius: 50%; }
.pick-img img { width: 56px; height: 56px; object-fit: contain; }
.pick-name { font-size: 12px; line-height: 1.25; text-align: center; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pick-coin { font-size: 11px; color: var(--gold); }
.pick-check { position: absolute; top: 6px; right: 8px; color: var(--lav); font-weight: 800; }
@media (max-width: 820px) { .pick-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; } }

/* 受信ギフト・サウンド一覧 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(11,15,46,.5); border: 1px solid var(--line); }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t small { color: var(--muted); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(255,215,94,.15); color: var(--gold); }

/* 保存バー */
.savebar { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(150%); transition: transform .25s;
  display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 18px; border-radius: 99px; z-index: 30; white-space: nowrap;
  background: rgba(22,26,74,.96); border: 1px solid rgba(217,220,239,.3); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.savebar { visibility: hidden; pointer-events: none; }
.savebar.show { transform: translateX(-50%) translateY(0); visibility: visible; pointer-events: auto; }
@media (min-width: 821px) { .savebar { bottom: 24px; margin-left: 120px; } }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 12px;
  background: rgba(22,26,74,.97); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.4); display: none; max-width: 92vw; }
.toast.show { display: block; }
.toast.err { border-color: var(--ng); color: #ffd1d7; }

/* ログイン */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 30px 26px; }
.login h1 { text-align: center; margin: 10px 0 4px; letter-spacing: .14em; font-size: 20px; }
.login .sub { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .2em; margin-bottom: 20px; }
.login .logo { display: block; margin: 0 auto; width: 64px; height: 64px; border-radius: 18px; }
.login form > * { margin-bottom: 12px; }

/* ===== バナーのプレビュー（PCアプリの /banner と同じ見た目） ===== */
.pv-wrap { position: relative; max-width: 100%; overflow: hidden; border-radius: 14px; background: linear-gradient(180deg, #5b6378, #2d3140); padding: 14px 0; }
.pv-scale { position: absolute; left: 0; top: 14px; width: 920px; transform-origin: 0 0; }
.pv .frame { padding: 4px; border-radius: 34px; background: linear-gradient(120deg, #f4f6ff 0%, #a9b0cf 22%, #ffffff 45%, #8d93b8 70%, #e9ecff 100%); }
.pv .cardb { position: relative; overflow: hidden; border-radius: 30px; height: 196px; background: linear-gradient(105deg, #0b0f2e 0%, #1b1d55 38%, #3d3486 70%, #7b67c4 100%); }
.pv .horizon { position: absolute; left: 0; right: 0; bottom: 0; height: 120px; background: radial-gradient(ellipse 70% 100% at 58% 100%, rgba(255,255,255,.30), rgba(214,205,255,.10) 50%, rgba(214,205,255,0)); }
.pv .moon { position: absolute; right: 26px; top: 18px; width: 34px; height: 34px; border-radius: 50%; box-shadow: -8px 6px 0 0 #f6f1d8; opacity: .85; }
.pv .rowb { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 30px 0 24px; }
.pv .avatar { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.pv .ring { position: absolute; inset: -6px; border-radius: 50%; background: linear-gradient(140deg, #fff, #cfc4ff 35%, #7d6ae0 65%, #f6e7a8); box-shadow: 0 0 18px rgba(196,180,255,.85); }
.pv .inner { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; border: 4px solid #0d1033; background: linear-gradient(140deg, #6f5bd6, #2b2c78); display: grid; place-items: center; font-size: 64px; font-weight: 800; }
.pv .info { flex: 1; min-width: 0; padding: 0 18px 0 26px; }
.pv .label { display: inline-block; font-size: 17px; font-weight: 800; letter-spacing: .28em; color: #1a1650; background: linear-gradient(90deg, #f7f3ff, #cfd4ee); border-radius: 99px; padding: 3px 14px 3px 16px; margin-bottom: 8px; }
.pv .name { font-size: 48px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 rgba(10,8,40,.9), 0 0 12px rgba(160,140,255,.6); line-height: 1.15; }
.pv .msg { font-size: 26px; font-weight: 700; color: #d8d0ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }
.pv .msg span { color: #fff4c8; }
.pv .gift { width: 132px; height: 132px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: 76px; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.95), rgba(226,218,255,.55) 45%, rgba(120,100,220,0) 72%); }
.pv .count { min-width: 150px; padding-left: 10px; font-family: "Arial Black", "Segoe UI Black", sans-serif; font-weight: 900; font-size: 84px; line-height: 1; color: #ffd75e; text-shadow: 0 3px 0 #8a5a00, 0 0 14px rgba(255,210,90,.65); }
.pv .count small { font-size: 52px; }

/* ===== スマホ: 左上のメニューボタン（ハンバーガー）から開く ===== */
.burger { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(78vw, 290px); height: 100%; box-sizing: border-box;
    padding: calc(22px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
    background: #0d1036; border-right: 1px solid var(--line); z-index: 40; overflow-y: auto;
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0,0,0,.45); }
  .side.open { transform: translateX(0); }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .nav a { padding: 13px 12px; font-size: 16px; }
  .nav a .ic { font-size: 19px; }
  .burger { display: inline-flex; flex-direction: column; justify-content: center; gap: 5px; width: 42px; height: 42px; padding: 0 10px;
    border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; flex: none; }
  .burger span { display: block; height: 2px; border-radius: 2px; background: #e8e4ff; }
  .top { position: sticky; top: 0; z-index: 30; margin: -18px -14px 16px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: rgba(11,15,46,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: nowrap; }
  .main { padding: 18px 14px 110px; }
  .top h1 { font-size: 19px; }
  .pc-pill { white-space: nowrap; }
  .savebar { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* v0.6 リスナー */
textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
a.item { text-decoration: none; color: inherit; cursor: pointer; }
a.item:hover { border-color: rgba(185,168,255,.45); }
.item .t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t small.memo { color: #cfc8ff; }
.gimg.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.gimg.avatar { overflow: hidden; }
.tag.new { background: rgba(120,220,170,.16); color: #7fe0b0; }
label.field { margin: 0 0 14px; }
label.field > span { display: block; margin-bottom: 4px; }
label.field input, label.field textarea { margin: 0; color: var(--text, #fff); font-size: 15px; }
label.field small { display: block; margin-top: 4px; }
details summary { cursor: pointer; color: var(--muted); margin: 6px 0 10px; }

/* v0.7 履歴 */
.history { max-height: 60vh; overflow-y: auto; }
.hday { position: sticky; top: 0; background: var(--card, #17143a); color: var(--muted); font-size: 12px; padding: 8px 0 4px; }
.hrow { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 14px; }
.hrow .hbody { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.hrow.gift .hbody { color: #ffd98a; }

/* v0.8 プレビュー（本物の表示画面を縮小） */
.fp-wrap { position: relative; width: 100%; overflow: hidden; border-radius: 14px; margin-bottom: 12px;
  background: linear-gradient(180deg, #5b6378, #2d3140); }
.fp-wrap iframe { position: absolute; left: 0; top: 0; width: 1080px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; background: transparent; }

/* v0.9 罰ゲーム */
.pn-row { gap: 10px; align-items: center; }
.pn-row .t input { width: 100%; box-sizing: border-box; }
.pn-row label input { width: 56px; }
.card.sub { background: rgba(255,255,255,.03); margin: 10px 0; }

/* v0.12 瓶のプレビュー（下の方だけ見せる） */
.jar-pv .fp-wrap { height: 300px !important; }
.jar-pv .fp-wrap iframe { top: auto; bottom: 0; transform-origin: 0 100% !important; }
