* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #d7e5f3;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

.app {
  max-width: 430px;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #8fb7dc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  height: 64px;
  background: #27384a;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}
.chat-header,
.tab-bar,
.input-area {
  flex-shrink: 0;
}

.chat-log,
.search-page {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}


.chat-name { font-weight: 700; font-size: 18px; }
.chat-status { font-size: 12px; opacity: .75; }

.menu-button {
  border: none;
  background: transparent;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

.chat-log {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}

.message-row {
  display: flex;
  margin: 8px 0;
}

.message-row.akari { justify-content: flex-start; }
.message-row.player { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.akari .bubble {
  background: white;
  color: #222;
  border-bottom-left-radius: 4px;
}

.player .bubble {
  background: #9be66d;
  color: #111;
  border-bottom-right-radius: 4px;
}

.system-message {
  text-align: center;
  margin: 14px 0;
  color: rgba(0,0,0,.55);
  font-size: 12px;
  white-space: pre-wrap;
}

.typing-row {
  display: flex;
  justify-content: flex-start;
  margin: 8px 0;
}

.typing-bubble {
  background: rgba(255,255,255,.85);
  color: #555;
  padding: 8px 12px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing-dots span {
  animation: blink 1.2s infinite;
  opacity: .25;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}

.input-area {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #f7f7f7;
}

#playerInput {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 15px;
}

#sendButton {
  border: none;
  border-radius: 18px;
  padding: 0 16px;
  background: #31c75b;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

#sendButton:disabled,
#playerInput:disabled {
  opacity: .55;
  cursor: not-allowed;
}


.tab-bar {
  display: flex;
  background: #1f2e3f;
  border-top: 1px solid rgba(255,255,255,.08);
}

.tab-button {
  flex: 1;
  border: none;
  padding: 10px 0;
  color: rgba(255,255,255,.7);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.tab-button.active {
  color: white;
  background: rgba(255,255,255,.12);
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
}

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

.search-page {
  flex: 1;
  background: #f7f7f7;
  padding: 28px 16px;
  overflow-y: auto;
}

.search-logo {
  text-align: center;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: .03em;
  color: #27384a;
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

#searchInput {
  flex: 1;
  border: 1px solid #cfcfcf;
  border-radius: 22px;
  padding: 12px 14px;
  font-size: 15px;
  background: white;
}

#searchButton {
  border: none;
  border-radius: 22px;
  padding: 0 18px;
  background: #27384a;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-help,
.no-result {
  color: #666;
  text-align: center;
  font-size: 14px;
}

.result-card {
  background: white;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.result-title {
  color: #1a4fa3;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-url {
  color: #188038;
  font-size: 12px;
  margin-bottom: 8px;
}

.result-snippet {
  color: #333;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}


.result-card {
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}

.result-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

.detail-page {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.back-button {
  border: none;
  border-radius: 18px;
  background: #e7edf5;
  color: #27384a;
  font-weight: 700;
  padding: 8px 14px;
  margin-bottom: 14px;
  cursor: pointer;
}

.detail-title {
  font-size: 20px;
  font-weight: 800;
  color: #222;
  margin-bottom: 6px;
}

.detail-url {
  color: #188038;
  font-size: 12px;
  margin-bottom: 16px;
}

.detail-body {
  line-height: 1.75;
  white-space: pre-wrap;
  color: #222;
  font-size: 15px;
}

.blackout {
  background: #111;
  color: #111;
  border-radius: 2px;
  padding: 0 .2em;
}


.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(390px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: #f8f8f8;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.3);
}

.modal-header {
  height: 52px;
  padding: 0 12px 0 16px;
  background: #27384a;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px 16px 0 0;
}

.modal-title {
  font-weight: 800;
}

.modal-close {
  border: none;
  background: transparent;
  color: white;
  font-size: 26px;
  cursor: pointer;
}

.modal-body {
  padding: 14px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-item,
.slot-button,
.confirm-button {
  border: none;
  border-radius: 12px;
  padding: 14px;
  background: white;
  color: #222;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.menu-item:hover,
.slot-button:hover,
.confirm-button:hover {
  background: #eef4fb;
}

.menu-item.danger {
  color: #9a1f1f;
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slot-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.slot-meta {
  color: #555;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.empty-slot {
  color: #888;
}

.notice-box {
  background: white;
  border-radius: 12px;
  padding: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.confirm-button {
  text-align: center;
  flex: 1;
}

.confirm-button.primary {
  background: #27384a;
  color: white;
}

.confirm-button.cancel {
  background: #e9e9e9;
}


.detail-body {
  min-height: 360px;
}

.detail-body:has(+ *) {
  margin-bottom: 0;
}


.ending-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  opacity: 0;
  transition: opacity 1.4s ease;
}

.ending-overlay.hidden {
  display: none;
}

.ending-overlay.show {
  opacity: 1;
}

.ending-overlay.bad {
  background: #000;
  color: #fff;
}

.ending-overlay.good {
  background: #fff;
  color: #111;
}

.ending-card {
  width: min(390px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 22px;
  border-radius: 18px;
  text-align: center;
  transform: translateY(10px);
  opacity: 0;
  transition: opacity 1.2s ease .7s, transform 1.2s ease .7s;
}

.ending-overlay.show .ending-card {
  transform: translateY(0);
  opacity: 1;
}

.ending-overlay.bad .ending-card {
  background: rgba(12, 12, 12, .92);
  box-shadow: 0 0 28px rgba(255,255,255,.08);
}

.ending-overlay.good .ending-card {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 0 28px rgba(0,0,0,.13);
}

.ending-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .08em;
  margin-bottom: 24px;
}

.ending-overlay.bad .ending-title {
  color: #d8d8d8;
}

.ending-overlay.good .ending-title {
  color: #27384a;
}

.ending-body {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 15px;
  text-align: left;
  margin-bottom: 26px;
}

.ending-share-button {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 13px 16px;
  background: #111;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 12px;
}

.ending-overlay.bad .ending-share-button {
  background: #fff;
  color: #111;
}

.ending-actions {
  display: flex;
  gap: 10px;
}

.ending-sub-button {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 700;
}

.ending-overlay.bad .ending-sub-button {
  background: #222;
  color: #ddd;
  border: 1px solid #444;
}

.ending-overlay.good .ending-sub-button {
  background: #e8eef6;
  color: #27384a;
}


.detail-page.dark-detail {
  background: #080808;
  color: #e6e6e6;
  border: 1px solid #222;
}

.detail-page.dark-detail .detail-title {
  color: #f1f1f1;
}

.detail-page.dark-detail .detail-url {
  color: #9ebd9e;
}

.detail-page.dark-detail .detail-body {
  color: #e0e0e0;
}

.detail-page.dark-detail .back-button {
  background: #1b1b1b;
  color: #e6e6e6;
  border: 1px solid #333;
}


.akari-icon {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; margin-right: 7px; align-self: flex-end; background: #fff;
}
.chat-image {
  display:block; width:min(92%,360px); max-height:360px; object-fit:cover; border-radius:14px; margin:8px auto 0; box-shadow:0 2px 10px rgba(0,0,0,.18);
}
.ending-image {
  display:block; width:100%; max-height:260px; object-fit:cover; border-radius:14px; margin:0 0 22px;
}
.ending-image.hidden { display:none; }
.search-detail-image {
  display:block; width:100%; max-height:360px; object-fit:contain; border-radius:10px; margin:12px 0 16px; background:rgba(0,0,0,.08);
}
.image-modal {
  position: fixed;
  inset: 0;

  background: rgba(0,0,0,0.85);

  display: flex;
  justify-content: center;
  align-items: center;

  z-index: 9999;

  cursor: zoom-out;
}

.image-modal img {
  max-width: 92vw;
  max-height: 92vh;

  object-fit: contain;

  border-radius: 10px;
}
