:root {
  --navy: #1b2131;
  --navy-deep: #12151f;
  --brass: #b8873a;
  --brass-bright: #d7a752;
  --paper: #f6f1e6;
  --card: #fffdf8;
  --line: #e4dcc8;
  --ink: #221e19;
  --ink-soft: #7a7164;
  --danger: #a8402e;
  --success: #3e7a52;
  --bubble-mine: var(--navy);
  --bubble-mine-text: #f6f1e6;
  --bubble-theirs: var(--card);
  --bubble-theirs-text: var(--ink);
  --font-display: "Zen Old Mincho", "Hiragino Mincho ProN", serif;
  --font-body: "Zen Maru Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  touch-action: pan-x pan-y; /* ピンチズームのジェスチャー自体を許可しない */
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }

/* --- Join screen: 合言葉で開ける扉 --- */
#join-screen {
  background: var(--paper);
}
.hero {
  position: relative;
  min-height: 92vh; min-height: 92dvh;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background:
    radial-gradient(ellipse at 50% -10%, #262d42 0%, var(--navy) 55%, var(--navy-deep) 100%);
}

.scroll-hint {
  position: absolute;
  left: 50%; bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  color: rgba(246, 241, 230, 0.55);
  font-size: 0.75rem;
  text-decoration: none;
  animation: scroll-hint-bob 2.2s ease-in-out infinite;
}
.scroll-hint:hover { color: rgba(246, 241, 230, 0.85); }
@keyframes scroll-hint-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint { animation: none; }
}
.join-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 2.25rem 2rem 2rem; text-align: center;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.45);
}
.keyhole-mark {
  width: 64px; height: 64px; margin: 0 auto 1.1rem; display: block;
  filter: drop-shadow(0 2px 3px rgba(184,135,58,0.35));
}
.keyhole-ring {
  fill: none; stroke: var(--brass); stroke-width: 3;
}
.keyhole-shape { fill: var(--brass); }

.join-card h1 {
  font-family: var(--font-display); font-weight: 600; letter-spacing: 0.04em;
  font-size: 1.4rem; margin: 0 0 0.4rem; color: var(--navy);
}
.join-card p.tagline { color: var(--ink-soft); font-size: 0.82rem; margin: 0 0 1.6rem; line-height: 1.7; }
.field { margin-bottom: 1rem; text-align: left; }
.field label { display: block; font-size: 0.76rem; color: var(--ink-soft); margin-bottom: 0.3rem; }
.field input {
  width: 100%; padding: 0.7rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--brass); background: var(--card); }
.field textarea {
  width: 100%; padding: 0.7rem 0.9rem; border-radius: 10px; font-family: inherit; resize: vertical;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 16px;
}
.field textarea:focus { outline: none; border-color: var(--brass); background: var(--card); }
.btn-primary {
  width: 100%; padding: 0.85rem; border-radius: 10px;
  background: var(--navy); color: var(--paper); font-weight: 700; font-size: 0.98rem; margin-top: 0.6rem;
  letter-spacing: 0.02em;
  transition: background 120ms ease;
}
.btn-primary:active { background: var(--navy-deep); }
.join-notice { margin-top: 1.4rem; font-size: 0.68rem; color: var(--ink-soft); line-height: 1.75; text-align: left; }
.join-notice a { color: var(--brass); }
.join-error { margin-top: 0.7rem; font-size: 0.8rem; color: var(--danger); text-align: left; line-height: 1.6; }
.join-safety-notice { margin-top: 1rem; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); line-height: 1.7; text-align: left; }

/* --- Safety notice shown inside the room (always visible, not just on scroll) --- */
.safety-notice {
  flex-shrink: 0; padding: 0.4rem 0.9rem; font-size: 0.68rem; color: var(--ink-soft); text-align: center;
  background: var(--card); border-bottom: 1px solid var(--line);
}

/* 解錠アニメーション：送信直後、鍵穴が真鍮色に輝いて開く */
.keyhole-mark.unlocking .keyhole-ring { animation: ring-glow 520ms ease-out; }
.keyhole-mark.unlocking .keyhole-shape { animation: shape-glow 520ms ease-out; }
@keyframes ring-glow {
  0% { stroke: var(--brass); }
  45% { stroke: var(--brass-bright); filter: brightness(1.4); }
  100% { stroke: var(--brass); }
}
@keyframes shape-glow {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); fill: var(--brass-bright); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .keyhole-mark.unlocking .keyhole-ring,
  .keyhole-mark.unlocking .keyhole-shape { animation: none; }
}

/* --- Marketing content below the hero --- */
.marketing {
  max-width: 720px; margin: 0 auto; padding: 3.5rem 1.5rem;
}
.m-section { margin-bottom: 3.5rem; }
.m-section:last-child { margin-bottom: 1.5rem; }
.m-eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; color: var(--brass);
  text-transform: uppercase; margin: 0 0 0.5rem;
}
.m-section h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; color: var(--navy);
  margin: 0 0 1.1rem; line-height: 1.5;
}
.m-lead { font-size: 0.92rem; line-height: 1.85; color: var(--ink-soft); max-width: 60ch; }

.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem;
}
.feature-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem;
}
.feature-card h3 { font-size: 0.92rem; margin: 0 0 0.4rem; color: var(--navy); }
.feature-card p { font-size: 0.82rem; line-height: 1.7; color: var(--ink-soft); margin: 0; }

.m-list { margin: 0; padding-left: 1.2rem; }
.m-list li { font-size: 0.86rem; line-height: 1.85; color: var(--ink-soft); margin-bottom: 0.5rem; }
.m-more { margin-top: 1rem; }
.m-more a { color: var(--brass); font-size: 0.86rem; font-weight: bold; text-decoration: none; }

.faq-item { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-weight: 700; font-size: 0.88rem; color: var(--navy); margin: 0 0 0.4rem; }
.faq-a { font-size: 0.84rem; line-height: 1.75; color: var(--ink-soft); margin: 0; }

.ad-slot {
  display: block; margin: 0 auto; max-width: 640px; text-align: center;
  min-height: 0; overflow: hidden;
}
.ad-slot:empty { margin: 0; }

.site-footer {
  max-width: 720px; margin: 0 auto; padding: 1.5rem; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.75rem; color: var(--ink-soft);
}
.site-footer a { color: var(--ink-soft); }

/* --- Room screen shell --- */
#room-screen {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 560px; margin: 0 auto;
  background: var(--paper);
}

.room-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem; background: var(--card); border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.room-title { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.room-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: var(--brass-bright);
  display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0;
  font-family: var(--font-display);
}
.room-title-text { min-width: 0; }
.room-code { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-sub { font-size: 0.72rem; color: var(--ink-soft); }
.header-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.icon-round {
  width: 38px; height: 38px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.icon-round svg { display: block; }
.icon-round.active { background: var(--brass); border-color: var(--brass); color: var(--navy-deep); }
.icon-round.ghost { background: transparent; border-color: transparent; }

/* --- Call pill (minimized call indicator) --- */
.call-pill {
  display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem auto 0;
  padding: 0.4rem 0.9rem; border-radius: 20px; background: var(--success); color: #fff;
  font-size: 0.78rem; font-weight: bold; width: fit-content;
}
.call-pill-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite;
}
.call-pill-hint { opacity: 0.85; font-weight: normal; margin-left: 0.2rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- Incoming / ongoing call banner (for members not yet in the call) --- */
.call-invite-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  margin: 0.5rem 0.75rem 0; padding: 0.6rem 0.9rem; border-radius: 12px;
  background: #efe6d3; border: 1px solid var(--line); font-size: 0.82rem; color: var(--navy);
}
.call-invite-join-btn {
  padding: 0.4rem 0.8rem; border-radius: 16px; background: var(--navy); color: var(--paper);
  font-size: 0.78rem; font-weight: bold; flex-shrink: 0;
}

/* --- Full-screen call view (LINE / Instagram style, night-door tone) --- */
#call-view {
  position: fixed; inset: 0; z-index: 30; background: var(--navy-deep);
  display: flex; flex-direction: column;
}
.call-view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem 0.5rem; flex-shrink: 0;
}
.icon-round.on-dark { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.14); color: #fff; }
.call-view-title { text-align: center; color: var(--paper); }
.call-view-name { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; }
.call-view-timer { font-size: 0.72rem; color: rgba(246,241,230,0.55); margin-top: 2px; }

.call-video-grid {
  flex: 1; min-height: 0; display: grid; gap: 0.5rem; padding: 0.5rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  overflow-y: auto;
}
.call-tile {
  position: relative; border-radius: 16px; overflow: hidden; background: #22273a;
  width: 100%; height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center;
}

/* 1対1通話：相手を全画面、自分は隅の小さなPinPに（LINE/Instagram風） */
.call-video-grid.pip-mode {
  display: block; position: relative; padding: 0; overflow: hidden;
}
.call-video-grid.pip-mode .call-tile {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0;
}
.call-video-grid.pip-mode .call-tile#call-tile-self {
  inset: auto; top: 12px; right: 12px; width: 88px; height: 124px;
  border-radius: 12px; border: 2px solid rgba(246,241,230,0.35);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4); z-index: 2;
}
.call-video-grid.pip-mode .call-tile#call-tile-self .avatar-circle {
  width: 40px; height: 40px; font-size: 0.85rem;
}
.call-video-grid.pip-mode .call-tile#call-tile-self .label { display: none; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; }
.call-tile.no-video video { display: none; }
.call-tile .avatar-circle {
  width: 68px; height: 68px; border-radius: 50%; background: var(--brass); color: var(--navy-deep);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: bold;
  font-family: var(--font-display);
}
.call-tile .label {
  position: absolute; bottom: 8px; left: 10px; font-size: 0.75rem; color: #fff;
  background: rgba(0,0,0,0.4); padding: 2px 8px; border-radius: 10px;
}
.call-tile .mic-off-badge {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; font-size: 0.7rem;
}

.call-controls {
  display: flex; justify-content: center; align-items: center; gap: 1.4rem;
  padding: 1.3rem 1rem 2.2rem; flex-shrink: 0;
}
.call-ctrl-btn {
  width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.call-ctrl-btn.active { background: rgba(255,255,255,0.12); }
.call-ctrl-btn:not(.active):not(.end) { background: var(--brass); color: var(--navy-deep); }
.call-ctrl-btn.end { background: var(--danger); transform: rotate(135deg); width: 64px; height: 64px; }
.call-ctrl-btn .icon-off { display: none; }
.call-ctrl-btn:not(.active) .icon-on { display: none; }
.call-ctrl-btn:not(.active) .icon-off { display: block; }

/* --- Chat log / bubbles --- */
.chat-log {
  flex: 1; overflow-y: auto; padding: 0.9rem 0.75rem; display: flex; flex-direction: column; gap: 0.35rem;
}
.msg-row { display: flex; flex-direction: column; max-width: 78%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }
.msg-sender { font-size: 0.68rem; color: var(--ink-soft); margin: 0 0.3rem 0.15rem; }
.bubble {
  padding: 0.55rem 0.85rem; border-radius: 18px; font-size: 0.92rem; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.mine .bubble { background: var(--bubble-mine); color: var(--bubble-mine-text); border-bottom-right-radius: 4px; }
.msg-row.theirs .bubble { background: var(--bubble-theirs); color: var(--bubble-theirs-text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.media { padding: 4px; }
.bubble.media img, .bubble.media video { max-width: 100%; border-radius: 14px; display: block; }

.system-row { align-self: center; font-size: 0.72rem; color: var(--ink-soft); padding: 0.2rem 0; text-align: center; }

/* --- Input bar --- */
.input-bar {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.7rem; background: var(--card); border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.input-bar input[type="text"] {
  flex: 1; padding: 0.6rem 1rem; border-radius: 20px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-size: 16px; /* iOS Safariのフォーカス時自動ズームを防ぐには16px以上が必要 */
}
.input-bar input[type="text"]:focus { outline: none; border-color: var(--brass); background: var(--card); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: var(--paper);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}

/* --- Bottom sheet (participants / menu) --- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(18,21,31,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 0.75rem 1.1rem 1.25rem; max-height: 80vh; overflow-y: auto;
}
.sheet-handle { width: 40px; height: 4px; background: var(--line); border-radius: 2px; margin: 0 auto 0.9rem; }
.sheet h2 { font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; margin: 0 0 0.5rem; }
.participant-row { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0; font-size: 0.9rem; border-bottom: 1px solid var(--line); }
.participant-row:last-child { border-bottom: none; }
.row-actions { display: flex; gap: 0.4rem; }
.tiny-btn { font-size: 0.7rem; padding: 0.3rem 0.55rem; border-radius: 8px; background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }
.sheet-btn {
  width: 100%; text-align: center; padding: 0.8rem; margin-top: 0.9rem; border-radius: 12px;
  background: var(--paper); color: var(--ink); font-size: 0.9rem; font-weight: bold; border: 1px solid var(--line);
}
.sheet-btn.danger { background: #f7e6e2; color: var(--danger); border-color: #edd0c8; }
.sheet-btn.ghost { background: transparent; color: var(--ink-soft); font-weight: normal; margin-top: 0.3rem; border-color: transparent; }

/* --- Report sheet --- */
.report-target { font-size: 0.88rem; font-weight: 700; color: var(--navy); margin: 0 0 0.9rem; }
.report-attach-row {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--ink-soft); margin: 0.9rem 0 0.2rem;
}
.report-attach-row input { width: 16px; height: 16px; flex-shrink: 0; }
