* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: #0f0716;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #333;
}

.bg-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #2e1065 0%, #0f0716 100%);
  z-index: 1;
}

/* 全体レイアウト */
.app-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 10;
}

.book-container {
  position: relative;
  width: 380px;
  height: 520px;
  perspective: 1500px;
}

/* 表紙 */
.binder-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #3b0764, #1e0038);
  border-radius: 16px;
  padding: 32px 24px;
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(192, 132, 252, 0.2);
  border-left: 10px solid #2e1065;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.binder-cover.open {
  transform: rotateY(-140deg);
  pointer-events: none;
}

.cover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.logo-triangle {
  width: 0;
  height: 0;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-bottom: 52px solid #a855f7;
  filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.5));
}

.title-main {
  font-size: 22px;
  letter-spacing: 3px;
  color: #f3e8ff;
  font-weight: 700;
}

.title-sub {
  font-size: 11px;
  letter-spacing: 4px;
  color: #c084fc;
}

.parrot-icon {
  width: 90px;
  height: 90px;
}

.open-prompt {
  margin-top: 20px;
  padding: 8px 20px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.4);
  border-radius: 20px;
  color: #e9d5ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
}

/* メイン画面 */
.inner-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 5;
}

/* ナビタブ */
.page-nav {
  display: flex;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.nav-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: bold;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab.active {
  background: #ffffff;
  color: #6b21a8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* ページコンテンツ切替 */
.page-content {
  display: none;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}

.page-content.active {
  display: flex;
}

.app-header h2 {
  font-size: 16px;
  color: #1e1035;
}

.app-header p {
  font-size: 11px;
  color: #6b7280;
}

.album-hint {
  font-size: 10px;
  color: #8b5cf6;
}

#map {
  width: 100%;
  height: 310px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  z-index: 1;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #7e22ce, #6b21a8);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.hint-text {
  font-size: 10px;
  color: #8b5cf6;
  text-align: center;
}

/* 2ページ目: 自由配置キャンバス台紙 */
.album-board {
  flex: 1;
  position: relative;
  background-color: #fafaf9;
  background-image: radial-gradient(#e7e5e4 1px, transparent 1px);
  background-size: 16px 16px;
  border: 2px dashed #d6d3d1;
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}

.empty-album-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #a8a29e;
  text-align: center;
  pointer-events: none;
}

/* 台紙の上に貼られたシール */
.placed-sticker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #f0f0f0;
  cursor: grab;
  touch-action: none;
  transform: translate(-50%, -50%);
  transition: box-shadow 0.2s, transform 0.1s;
  z-index: 10;
}

.placed-sticker:active {
  cursor: grabbing;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 100;
}

.placed-sticker img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #f3e8ff;
  pointer-events: none;
}

.placed-sticker span {
  font-size: 9px;
  font-weight: bold;
  color: #44403c;
  max-width: 65px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* 本の外側に配置されたシールトレー */
.sticker-tray-section {
  width: 380px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
  color: #e9d5ff;
}

.count-badge {
  background: #a855f7;
  color: white;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 10px;
}

.sticker-tray {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 2px;
  align-items: center;
  min-height: 80px;
}

.empty-tray-msg {
  font-size: 11px;
  color: #c084fc;
  width: 100%;
  text-align: center;
}

.tray-sticker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
  transition: transform 0.15s;
}

.tray-sticker-item:hover {
  transform: translateY(-3px);
}

.tray-sticker-item img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #a855f7;
  pointer-events: none;
}

.tray-sticker-item span {
  font-size: 9px;
  font-weight: bold;
  color: #374151;
  max-width: 55px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ポップアップ内スタイル */
.popup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  max-width: 180px;
}

.popup-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #7e22ce;
}

.popup-get-btn {
  width: 100%;
  padding: 6px 12px;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}

.popup-get-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.owner-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

.edit-btn {
  flex: 1;
  padding: 4px 8px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
}

.delete-btn {
  flex: 1;
  padding: 4px 8px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 16px;
  width: 310px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content h3 {
  font-size: 15px;
  color: #2e1065;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 11px;
  color: #4b5563;
}

.form-group input {
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.cancel-btn {
  padding: 6px 12px;
  background: #f3f4f6;
  color: #4b5563;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

.submit-btn {
  padding: 6px 12px;
  background: #7e22ce;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

/* シール操作メニュー (ダブルタップ時) */
.sticker-action-menu {
  position: fixed;
  z-index: 2000;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #e9d5ff;
  animation: popupFade 0.15s ease-out;
}

@keyframes popupFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.sticker-action-menu button {
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.sticker-action-menu .return-btn {
  color: #6b21a8;
}

.sticker-action-menu .return-btn:hover {
  background: #f3e8ff;
}

.sticker-action-menu .trash-btn {
  color: #ef4444;
}

.sticker-action-menu .trash-btn:hover {
  background: #fef2f2;
}
