/* ===== Base ===== */
body {
  font-family: "Segoe UI", "Meiryo", sans-serif;
  position: fixed;
  margin: 0;
  padding: 0;
  background: #fcf7f0;
}

.screen {
  width: 100vw;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #fcf7f0;
  z-index: 10;
}

#title-screen {
  background: white;
}

/* ===== Chat Screen Layout ===== */
#chat-screen {
  position: relative;          /* 背景動画の基準 */
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding-top: 0;
  box-sizing: border-box;
  width: 100vw;
  min-height: 100vh;
  overflow: hidden;            /* 背景動画をトリム */
  background: #fcf7f0;         /* 動画未読込時の色 */
}

/* 背景動画（index.html の <video id="chat-bg">） */

#chat-bg {
  position: absolute;   
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* 画面全体にちょうどよく表示 */
  z-index: 0;        /* 背景なので一番奥に */
  pointer-events: none; /* 背景をクリックできなくする */
}


/* ===== Foreground (UI) ===== */
.chat-header,
.container,
.bubble,
.input-group,
#appMenu.menu-list {
  position: relative;
  z-index: 1;                  /* 背景動画より手前 */
}

.chat-header {
  width: 100vw;
  z-index: 100;
  background: rgba(252, 247, 240, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  margin-bottom: 0;
  box-sizing: border-box;
  height: 52px;
  border-bottom: 1.5px solid #eee;
}

.chat-title {
  font-family: 'Potta One', cursive;
  color: #87cefa;
  font-size: 2.0em;
  font-weight: normal;
  text-shadow: 2px 2px 4px rgba(173, 216, 230, 0.5);
  letter-spacing: 1.5px;
  padding: 0.3em;
}

.menu-button {
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
  color: #444;
  padding: 0;
}

/* ===== Avatar / Stage ===== */
.container {
  position: absolute;
  top: 150px;
  left: 0;
  width: 100vw;
  bottom: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: hidden;
  box-sizing: border-box;
  padding-bottom: 16px;
}



/* ===== Menu ===== */
#appMenu.menu-list {
  position: fixed;
  top: 62px;
  right: 16px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  border: 1px solid #e0dbcd;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 200;
  display: none;
  padding: 10px;
  max-width: 200px;
}

.menu-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.menu-list li {
  padding: 10px 15px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 1.03em;
}
.menu-list li:hover {
  background: #f0f0f0;
}

/* ===== Bubble ===== */
.bubble {
  position: fixed;
  left: 5px;
  right: 16px;
  bottom: 50px;                 /* 入力欄の上（input-groupの高さ+α） */
  width: auto;
  background: rgba(255,251,204,0.85);
  backdrop-filter: blur(4px);
  border-radius: 16px;
  padding: 12px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  min-height: 48px;
  box-sizing: border-box;
  z-index: 2000;
  transition: box-shadow 0.3s;
}

/* ===== Input ===== */
.input-group {
  display: flex;
  gap: 8px;
  position: absolute;              
  left: 0;
  bottom: 0;
  width: 100vw;
  height: 60px;
  background: rgba(238,238,238,0.8);
  backdrop-filter: blur(6px);
  align-items: center;
  padding: 0 12px;
  box-sizing: border-box;
  transition: bottom 0.35s cubic-bezier(.7,1.7,.32,.99);
  z-index: 200;
}

.input-group input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1.1rem;
  background: rgba(255,255,255,0.9);
}

.input-group button {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #ffe066;
  font-weight: bold;
  cursor: pointer;
}

/* ニョキッとあいなっ！ */
.input-group .ainat-peek {
  position: fixed;
  right: 8px;
  bottom: 150px;
  width: 200px !important;
  height: 200px !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain;
  z-index: 1200;
  transform: translateY(100%) scale(1) rotate(-7deg);
  opacity: 0;
  transition: transform 0.65s cubic-bezier(.62,1.7,.16,1), opacity 0.2s;
  pointer-events: none;
}
.input-group .ainat-peek.active {
  transform: translateY(-40px) scale(1.1) rotate(-7deg);
  opacity: 1;
}

/* ===== Greeting / Popups ===== */
.greeting-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -54%);
  background: #fffbe6;
  border-radius: 28px;
  box-shadow: 0 10px 32px rgba(220,160,40,0.16), 0 2px 12px rgba(0,0,0,0.08);
  padding: 38px 22px 32px 22px;
  min-width: 320px;
  max-width: 92vw;
  z-index: 3000;
  text-align: left;
  font-size: 1.08em;
  display: none;
  border: 4px solid #ff99b7;
  animation: popUpShow 0.42s cubic-bezier(.6,1.3,.2,1) both;
}

.greeting-title {
  font-weight: bold;
  font-size: 1.35em;
  margin-bottom: 20px;
  letter-spacing: 1.2px;
  color: #d4b12d;
  text-shadow: 0 2px 12px #fff8c7, 0 1px 2px #fffde6;
  display: flex;
  align-items: center;
  gap: 12px;
}

.greeting-title::before {
  content: "⭐";
  font-size: 1.2em;
  margin-right: 2px;
}

.greeting-message {
  line-height: 1.82;
  color: #53461e;
  margin-bottom: 30px;
  font-size: 1.12em;
}

.close-modal-btn {
  display: block;
  margin: 0 auto;
  background: #ffe066;
  border: none;
  border-radius: 14px;
  padding: 12px 38px;
  font-size: 1.14em;
  font-weight: bold;
  color: #7d6100;
  box-shadow: 0 2px 10px rgba(250,240,170,0.15);
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.18s, color 0.15s, transform 0.13s;
}
.close-modal-btn:active {
  background: #fffbe6;
  color: #d4b12d;
  transform: scale(0.98);
}

/* Simple popup */
.simple-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  padding: 30px 16px 24px 16px;
  min-width: 270px;
  max-width: 95vw;
  z-index: 3000;
  text-align: left;
  font-size: 1em;
  display: none;
  border: 1.5px solid #dadada;
}

.simple-popup .greeting-title {
  color: #3d3d3d;
  font-size: 1.08em;
  font-weight: bold;
  margin-bottom: 14px;
  text-shadow: none;
  letter-spacing: 0.2px;
  display: block;
}
.simple-popup .greeting-title::before { content: none !important; }

.simple-popup .greeting-message {
  color: #444;
  line-height: 1.6;
  font-size: 0.98em;
  margin-bottom: 18px;
}

.simple-popup .close-modal-btn {
  background: #eee;
  color: #666;
  border-radius: 10px;
  padding: 7px 22px;
  font-size: 1em;
  border: none;
  box-shadow: none;
  font-weight: normal;
  letter-spacing: 1px;
  margin: 0 auto;
  display: block;
  cursor: pointer;
}
.simple-popup .close-modal-btn:active {
  background: #fafafa;
  color: #222;
}

.guide-popup,
.simple-popup {
  max-height: 70vh;
  overflow-y: auto;
}

/* ===== Animations ===== */
@keyframes popUpShow {
  from { opacity: 0; transform: scale(0.8) translate(-50%,-50%); }
  to   { opacity: 1; transform: scale(1) translate(-50%,-54%); }
}

/* ===== Intro Video (使う場合は維持) ===== */
#video-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1000;
}

#Ayaka-video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150%;
  height: auto;
  object-fit: cover;
}

/* ===== Responsive ===== */
@media (max-width: 430px) {
  .chat-header { height: 48px; }
  .container { top: 48px; height: calc(100vh - 108px); }
  .input-group { height: 48px; }
  .chat-title { font-size: 2.0rem; }
  #appMenu.menu-list { top: 50px; }
  .input-group .ainat-peek { width: 72px !important; height: 72px !important; }
}


/* PWAインストールボタンのスタイル */
.install-button {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%);
  background: #ffe066;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
  z-index: 110;
  transition: all 0.3s ease;
}

.install-button:hover {
  background: #ffdc33;
  transform: translateY(-50%) scale(1.05);
}

.install-button:active {
  transform: translateY(-50%) scale(0.95);
}

/* オフライン状態のスタイル */
.offline .chat-header {
  background: #ffebee;
  border-bottom-color: #ffcdd2;
}

.offline::before {
  content: "Off line";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: #f44336;
  color: white;
  text-align: center;
  padding: 4px;
  font-size: 0.8rem;
  z-index: 1000;
}

/* レスポンシブ対応 */
@media (max-width: 430px) {
  .install-button {
    right: 60px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}