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

body {
  font-family: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', serif;
  overflow: hidden;
  background: #1a1410;
}

.gallery {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.gallery-wall {
  position: absolute;
  inset: 0;
  display: flex;
}
.wall-panel { flex: 1; height: 100%; }
.wall-panel.left {
  background: linear-gradient(180deg, #3d2b1f 0%, #2a1f15 50%, #1f1810 100%);
  border-right: 2px solid #5a4a3a;
}
.wall-panel.center { background: linear-gradient(180deg, #4a3728 0%, #3d2b1f 50%, #2a1f15 100%); }
.wall-panel.right {
  background: linear-gradient(180deg, #3d2b1f 0%, #2a1f15 50%, #1f1810 100%);
  border-left: 2px solid #5a4a3a;
}

.gallery-header {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 24px 20px 8px;
  color: #f5e6d3;
}
.gallery-header h1 { font-size: 2.3rem; text-shadow: 2px 2px 8px rgba(0,0,0,0.5); letter-spacing: 4px; }
.gallery-header .subtitle { font-size: 1.1rem; color: #c4a882; margin-top: 8px; letter-spacing: 1px; }

.artwork-count, .session-state {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 20px;
  font-size: 0.95rem;
  color: #d4c4a8;
  border: 1px solid rgba(196,168,130,0.3);
}
.session-state { margin-left: 8px; }

.gallery-frames {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  align-content: start;
  padding: 20px 30px 50px;
  height: calc(100vh - 170px);
  overflow: auto;
}

.frame {
  position: relative;
  animation: frameAppear 0.8s ease forwards;
  opacity: 0;
  transform: scale(0.6) translateY(18px);
}
@keyframes frameAppear { to { opacity: 1; transform: scale(1) translateY(0); } }

.frame.hidden-frame { display: none; }

.frame-border {
  padding: 12px;
  background: linear-gradient(135deg, #D4AF37, #B8860B, #DAA520, #B8860B);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -1px 0 rgba(0,0,0,0.2);
}
.frame-inner { padding: 8px; background: #f5f0e8; box-shadow: inset 0 0 10px rgba(0,0,0,0.1); }
.frame-artwork {
  width: 100%;
  aspect-ratio: 4 / 5;
  position: relative;
  overflow: hidden;
  background: #fff;
}
.frame-artwork img { width: 100%; height: 100%; object-fit: cover; display: block; }

.frame-artwork .smile-overlay {
  position: absolute;
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 20px;
  pointer-events: none;
  opacity: 0;
  animation: smileAnim 4s ease-in-out infinite;
}
@keyframes smileAnim {
  0%, 30% { opacity: 0; transform: translateX(-50%) scaleY(0.5); }
  40%, 60% { opacity: 0.6; transform: translateX(-50%) scaleY(1.2); }
  70%, 100% { opacity: 0; transform: translateX(-50%) scaleY(0.5); }
}

.frame-artwork.smiling img { animation: portraitSmile 4s ease-in-out infinite; }
@keyframes portraitSmile {
  0%, 30% { transform: scaleY(1); }
  40% { transform: scaleY(1.01) translateY(-1px); }
  50%, 60% { transform: scaleY(1.02) translateY(-2px); }
  70%, 100% { transform: scaleY(1); }
}

.frame-label {
  text-align: center;
  margin-top: 8px;
  color: #d4c4a8;
  font-size: 0.9rem;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}
.frame-label .name { font-weight: bold; font-size: 1rem; color: #f5e6d3; }

.waiting-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align: center;
  transition: opacity 0.5s;
}
.waiting-message.hidden { opacity: 0; pointer-events: none; }
.waiting-content { color: #c4a882; }
.waiting-content .palette-icon { font-size: 5rem; animation: bounce 2s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.waiting-content h2 { font-size: 2rem; margin-top: 20px; color: #f5e6d3; }
.waiting-content p { font-size: 1.2rem; margin-top: 10px; color: #a89070; }

.new-artwork-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, #D4AF37, #B8860B);
  color: #1a1410;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: bold;
  z-index: 100;
  animation: toastIn 0.4s ease, toastOut 0.4s ease 3s forwards;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(100%); opacity: 0; } }
