/* =========================================================
   尋物日常 (Daily Finds Puzzle) - Chiikawa Cozy Aesthetic CSS
   ========================================================= */

:root {
  --bg-warm: #faf5ee;
  --card-bg: #ffffff;
  --text-main: #4a4036;
  --text-muted: #8b7e71;
  --border-color: #e5dacd;
  --brand-primary: #f39c12;
  --brand-pink: #ffb4c2;
  --brand-soft-blue: #a0c4ff;
  --accent-gold: #fdcb6e;
  --error-soft: #ff7675;
  --error-bg: #ffeaa7;

  /* Morandi Region Colors (Soft, high readability, low eye fatigue) */
  --reg-0: #ffdfba; /* Soft Peach */
  --reg-1: #baffc9; /* Mint Sage */
  --reg-2: #bae1ff; /* Sky Mist */
  --reg-3: #ffffba; /* Butter Cream */
  --reg-4: #e8d7ff; /* Soft Lavender */
  --reg-5: #ffc6ff; /* Pale Rose */
  --reg-6: #c8d6e5; /* Pebble Blue */

  --shadow-sm: 0 4px 12px rgba(74, 64, 54, 0.06);
  --shadow-md: 0 8px 24px rgba(74, 64, 54, 0.09);
  --shadow-lg: 0 16px 36px rgba(74, 64, 54, 0.14);
}

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

body {
  font-family: 'Zen Maru Gothic', 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-warm);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 20px;
  background-image: 
    radial-gradient(#ebdccf 1px, transparent 1px),
    radial-gradient(#ebdccf 1px, var(--bg-warm) 1px);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
}

.game-container {
  width: 100%;
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ================= HEADER & SPRITE ================= */
.game-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-zone {
  text-align: center;
}

.game-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #3d332a;
  text-shadow: 2px 2px 0px #fff, 4px 4px 0px rgba(230, 218, 204, 0.6);
}

.game-subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Chiikawa Sprite Companion Card */
.sprite-card {
  background: var(--card-bg);
  border: 3px solid #ebdccf;
  border-radius: 20px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.3s ease;
}

.sprite-avatar {
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.06));
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sprite-avatar:hover {
  transform: scale(1.08) rotate(-4deg);
}

.sprite-avatar.bounce {
  animation: spriteBounce 0.5s ease;
}

.sprite-avatar.shake {
  animation: spriteShake 0.4s ease;
}

@keyframes spriteBounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px) scale(1.05); }
  60% { transform: translateY(-4px); }
}

@keyframes spriteShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-3deg); }
  75% { transform: translateX(6px) rotate(3deg); }
}

.sprite-bubble {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bubble-tag {
  align-self: flex-start;
  font-size: 0.85rem;
  font-weight: 900;
  background: #ffecb3;
  color: #b7791f;
  padding: 3px 10px;
  border-radius: 12px;
}

.bubble-text {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.5;
  color: #4a4036;
}

/* ================= STAGE & LEVEL NAVIGATION ================= */
.stage-nav {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 14px 16px;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stage-tabs {
  display: flex;
  gap: 10px;
  flex: 1;
}

.album-trigger-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fffaea;
  border: 2px solid #fed330;
  border-radius: 14px;
  color: #d35400;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.18);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  white-space: nowrap;
}

.album-trigger-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: #fff3c4;
  box-shadow: 0 6px 14px rgba(243, 156, 18, 0.28);
}

.album-trigger-btn:active {
  transform: scale(0.96);
}

.album-trigger-icon {
  font-size: 1.2rem;
}

.album-new-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #eb3b5a;
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 12px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(235, 59, 90, 0.4);
  z-index: 35 !important;
  animation: badgePulse 1.2s infinite alternate;
  display: none; /* Shown when new item is unlocked */
}

.album-new-badge.active {
  display: inline-block;
}

@keyframes badgePulse {
  from { transform: scale(0.9); }
  to { transform: scale(1.18); }
}

.stage-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #f4eee6;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stage-btn .stage-icon {
  font-size: 1.25rem;
}

.stage-btn:hover {
  background: #ede3d7;
}

.stage-btn.active {
  background: #fffae8;
  border-color: #f1c40f;
  color: #795548;
  box-shadow: 0 4px 10px rgba(241, 196, 15, 0.2);
}

.stage-btn.locked {
  opacity: 0.55;
  filter: grayscale(0.5);
  cursor: not-allowed;
  background: #ede6dc;
}

.level-pills-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.level-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

.level-pills {
  display: flex;
  gap: 7px;
}

.level-pill {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 2px solid #e5dacd;
  background: #fff;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.level-pill:hover:not(.locked) {
  background: #f7ede2;
  transform: translateY(-2px);
}

.level-pill.active {
  background: #4a4036;
  border-color: #4a4036;
  color: #fff;
  box-shadow: 0 3px 8px rgba(74, 64, 54, 0.25);
}

.level-pill.locked {
  background: #eee8de;
  border-color: #dfd4c5;
  color: #a49483;
  cursor: not-allowed;
  opacity: 0.65;
}

.level-pill.cleared::after {
  content: '✓';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.75rem;
  background: #2ed573;
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

/* ================= RULE QUICK GLANCE ================= */
.rule-hint-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  border: 1.5px dashed #cbbcae;
  box-shadow: 0 2px 8px rgba(74, 64, 54, 0.04);
  font-size: 1.15rem;
  font-weight: 900;
  color: #4a4036;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rule-item span {
  font-size: 1.35rem;
  line-height: 1;
}

.rule-item.highlight {
  color: #d35400;
}

/* ================= MAIN BOARD AREA (2-COLUMN) ================= */
.board-area {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 20px;
  border: 3px solid #ebdccf;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 275px 1fr;
  gap: 22px;
  align-items: start;
}

/* Left: Sticker Tray Panel */
.sticker-tray-panel {
  background: #fbf6ee;
  border-radius: 18px;
  padding: 16px 14px;
  border: 2px dashed #e5dacd;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tray-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid #ebdccf;
}

.tray-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #4a4036;
}

.tray-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  color: #8b7e71;
}

.sticker-tray {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Draggable Sticker Card */
.sticker-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 15px;
  border: 2.5px solid #ffffff;
  box-shadow: 0 3px 8px rgba(74, 64, 54, 0.1);
  cursor: grab;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  user-select: none;
}

.sticker-card:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 6px 14px rgba(74, 64, 54, 0.16);
}

.sticker-card:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.sticker-card.selected {
  outline: 3px dashed #f39c12;
  outline-offset: 2px;
  animation: stickerWiggle 0.4s ease infinite alternate;
}

@keyframes stickerWiggle {
  from { transform: rotate(-2deg) scale(1.02); }
  to { transform: rotate(2deg) scale(1.02); }
}

.sticker-card.placed {
  opacity: 0.45;
  filter: grayscale(0.5);
  cursor: pointer;
  box-shadow: none;
  border-color: #ebdccf;
}

/* Flow as flex item to completely eliminate text overlap */
.sticker-card.placed::after {
  content: '✓ 已安置';
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 900;
  color: #27ae60;
  background: rgba(255, 255, 255, 0.92);
  padding: 3px 8px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sticker-card.is-starter::after {
  content: '📌 初始線索' !important;
  color: #d35400 !important;
  background: #fff8e1 !important;
  border: 1px solid #f39c12 !important;
  margin-left: auto !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  font-size: 0.8rem !important;
  font-weight: 900 !important;
  padding: 3px 8px !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

.sticker-card.is-starter {
  cursor: default !important;
  opacity: 0.75 !important;
}

.sticker-card-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(74, 64, 54, 0.1));
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sticker-card:hover .item-svg {
  transform: scale(1.12) rotate(5deg);
}

.sticker-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.sticker-card-name {
  font-size: 1.02rem;
  font-weight: 900;
  color: #4a4036;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticker-card-region-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(74, 64, 54, 0.75);
}

/* Color assignments for stickers */
.sticker-card[data-region="0"] { background-color: var(--reg-0); }
.sticker-card[data-region="1"] { background-color: var(--reg-1); }
.sticker-card[data-region="2"] { background-color: var(--reg-2); }
.sticker-card[data-region="3"] { background-color: var(--reg-3); }
.sticker-card[data-region="4"] { background-color: var(--reg-4); }
.sticker-card[data-region="5"] { background-color: var(--reg-5); }
.sticker-card[data-region="6"] { background-color: var(--reg-6); }

/* Right: Grid Section */
.grid-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.board-status-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-badge {
  font-size: 1.08rem;
  font-weight: 800;
  background: #fbf5ec;
  padding: 8px 16px;
  border-radius: 14px;
  border: 2px solid #e9dfd2;
}

.progress-badge strong {
  color: #e67e22;
  font-size: 1.3rem;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #e0d4c5;
  background: #fff;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: #f7ede2;
  border-color: #d1c0ae;
  transform: translateY(-2px);
}

.icon-btn.active {
  background: #fff8e1;
  border-color: #f39c12;
  color: #d35400;
  box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.icon-btn:disabled,
.icon-btn.disabled {
  background: #f0ebe4;
  border-color: #ded6cb;
  color: #b5a898;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none !important;
  box-shadow: none !important;
}

/* ================= STAR BATTLE GRID ================= */
.grid-wrapper {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.puzzle-grid {
  width: 100%;
  height: 100%;
  display: grid;
  background: #4a4036;
  border: 4px solid #4a4036;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(74, 64, 54, 0.15);
}

/* Grid Cells */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  perspective: 600px;
  /* Thin inner borders by default */
  border: 1px solid rgba(74, 64, 54, 0.15);
}

/* Thick outer borders where region boundaries differ */
.cell.border-top { border-top: 3.5px solid #4a4036 !important; }
.cell.border-bottom { border-bottom: 3.5px solid #4a4036 !important; }
.cell.border-left { border-left: 3.5px solid #4a4036 !important; }
.cell.border-right { border-right: 3.5px solid #4a4036 !important; }

/* Region Background Colors */
.cell[data-region="0"] { background-color: var(--reg-0); }
.cell[data-region="1"] { background-color: var(--reg-1); }
.cell[data-region="2"] { background-color: var(--reg-2); }
.cell[data-region="3"] { background-color: var(--reg-3); }
.cell[data-region="4"] { background-color: var(--reg-4); }
.cell[data-region="5"] { background-color: var(--reg-5); }
.cell[data-region="6"] { background-color: var(--reg-6); }

.cell:hover {
  filter: brightness(1.04);
}

.cell:active {
  transform: scale(0.96);
}

/* Cell Content (Star, Dot, Object) */
.cell-inner {
  width: 80%;
  height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
}

/* Star Placeholder (⭐) */
.cell.has-star .cell-inner {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.35);
  animation: starPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.has-star .star-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(243, 156, 18, 0.5));
}

@keyframes starPop {
  0% { transform: scale(0.3) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.18) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* X Exclude Marker (✕) */
.cell.has-dot .cell-inner::after,
.cell.has-cross .cell-inner::after {
  content: '✕';
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(74, 64, 54, 0.42);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popX 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Auto-Blocked Rule X (Helper) */
.cell.auto-blocked:not(.has-star):not(.has-dot) .cell-inner::after {
  content: '✕';
  font-size: 1.4rem;
  font-weight: 800;
  color: rgba(142, 128, 113, 0.38);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popX 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.auto-blocked {
  background-image: radial-gradient(rgba(74, 64, 54, 0.08) 1px, transparent 1px);
  background-size: 8px 8px;
}

@keyframes popX {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Conflict / Error State */
.cell.conflict {
  animation: conflictShake 0.4s ease;
  background-color: var(--error-soft) !important;
}

.cell.conflict .cell-inner {
  background: rgba(255, 235, 238, 0.95);
  box-shadow: 0 0 12px rgba(231, 76, 60, 0.6);
}

@keyframes conflictShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* 3D Flip to Revealed Life Object */
.cell.revealed .cell-inner {
  transform: rotateY(180deg);
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
  border: 2px solid #fdcb6e;
}

.cell.revealed .revealed-icon {
  font-size: 1.9rem;
  transform: rotateY(180deg);
  display: inline-block;
}

/* Placed Sticker in Grid Cell */
.cell.has-sticker .cell-inner,
.cell.has-star .cell-inner {
  background: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 10px rgba(74, 64, 54, 0.18);
  animation: stickerDrop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Locked Starter Clue Anchor */
.cell.is-starter-clue .cell-inner {
  border: 2.5px solid #f39c12 !important;
  box-shadow: 0 0 14px rgba(243, 156, 18, 0.5) !important;
}

.cell.is-starter-clue::before {
  content: '📌';
  position: absolute;
  top: -5px;
  right: -3px;
  font-size: 0.95rem;
  z-index: 12;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  animation: pinPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pinPop {
  0% { transform: scale(0) translateY(-10px); }
  100% { transform: scale(1) translateY(0); }
}

.cell .sticker-in-cell {
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes stickerDrop {
  0% { transform: scale(1.4) rotate(-10deg); opacity: 0.6; }
  60% { transform: scale(0.92) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Drag & Drop Feedback on Grid Cells */
.cell.drop-valid {
  outline: 3.5px dashed #27ae60 !important;
  outline-offset: -3px;
  background-color: rgba(46, 204, 113, 0.25) !important;
  transform: scale(1.04);
  z-index: 10;
}

.cell.drop-invalid {
  outline: 3px dashed #e74c3c !important;
  outline-offset: -3px;
  background-color: rgba(231, 76, 60, 0.2) !important;
}

/* Instruction Bar */
.board-instruction-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: #fbf6ee;
  border-radius: 14px;
  border: 1.5px solid #ebdccf;
  font-size: 1.05rem;
  font-weight: 800;
  color: #5d4037;
}

.board-instruction-bar .instruction-icon {
  font-size: 1.25rem;
}

.board-instruction-bar strong {
  color: #d35400;
}

/* Responsive Media Queries (Mobile & Tablet) */
@media (max-width: 680px) {
  /* Compact container padding */
  body {
    padding: 12px 10px 16px;
  }

  .game-container {
    gap: 10px;
  }

  /* Compact brand title */
  .game-title {
    font-size: 2rem;
    letter-spacing: 1px;
  }

  .game-subtitle {
    font-size: 0.88rem;
  }

  /* Compact Chiikawa companion */
  .sprite-card {
    padding: 10px 12px;
    gap: 12px;
    border-radius: 16px;
  }

  .sprite-avatar {
    width: 56px;
    height: 56px;
  }

  .bubble-tag {
    font-size: 0.78rem;
    padding: 2px 8px;
  }

  .bubble-text {
    font-size: 0.92rem;
    line-height: 1.42;
  }

  /* Stage Nav & Expandable Tabs (當前階段展開文字，其他階段縮為 Icon) */
  .stage-nav {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 16px;
  }

  .stage-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
  }

  .stage-tabs {
    display: flex;
    gap: 5px;
    flex: 1;
    min-width: 0;
  }

  /* Inactive tab: compact icon only */
  .stage-btn {
    flex: 0 0 auto;
    padding: 7px 9px;
    gap: 0;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .stage-btn .stage-icon {
    font-size: 1.15rem;
  }

  .stage-btn .stage-label {
    display: none;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Active tab: expand with full label */
  .stage-btn.active {
    flex: 1;
    min-width: 0;
    gap: 4px;
    padding: 7px 10px;
  }

  .stage-btn.active .stage-label {
    display: inline-block;
    max-width: 160px;
    opacity: 1;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  /* Album button: 常駐最右側並排 */
  .album-trigger-btn {
    padding: 7px 11px;
    font-size: 0.86rem;
    border-radius: 12px;
    flex-shrink: 0;
    gap: 4px;
    margin-right: 8px;
    position: relative;
  }

  .album-trigger-icon {
    font-size: 1.05rem;
  }

  .album-new-badge {
    top: -9px;
    right: -9px;
    padding: 2px 6px;
    font-size: 0.72rem;
    pointer-events: none;
  }

  /* Compact level pills */
  .level-pills-wrap {
    gap: 6px;
    padding-bottom: 2px;
  }

  .level-label {
    font-size: 0.86rem;
  }

  .level-pill {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    border-radius: 10px;
  }

  /* Compact Rule bar */
  .rule-hint-bar {
    padding: 8px 12px;
    font-size: 0.88rem;
    gap: 6px 12px;
    border-radius: 12px;
    justify-content: space-around;
  }

  .rule-item {
    gap: 5px;
  }

  .rule-item span {
    font-size: 1.1rem;
  }

  /* Compact Board area */
  .board-area {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
    border-radius: 20px;
  }

  .sticker-tray-panel {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .tray-header {
    margin-bottom: 6px;
  }

  .tray-title {
    font-size: 0.95rem;
  }

  .tray-subtitle {
    font-size: 0.78rem;
  }

  .sticker-tray {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .sticker-card {
    padding: 6px 10px;
    border-radius: 12px;
  }

  .sticker-card-icon {
    font-size: 1.3rem;
  }

  .sticker-card-name {
    font-size: 0.85rem;
  }

  .grid-section {
    gap: 8px;
  }

  .board-status-row {
    margin-bottom: 2px;
  }

  .progress-badge {
    font-size: 1rem;
    padding: 6px 12px;
  }

  .icon-btn {
    padding: 6px 12px;
    font-size: 0.88rem;
  }

  .grid-wrapper {
    max-width: 330px;
  }

  .board-instruction-bar {
    padding: 8px 10px;
    font-size: 0.82rem;
    margin-top: 4px;
  }
}

/* ================= MODAL DIALOG ================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(45, 38, 32, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 28px;
  border: 4px solid #ebdccf;
  padding: 30px 26px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  position: relative;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

/* Success Stamp */
.stamp-animation {
  position: absolute;
  top: 14px;
  right: 18px;
  transform: rotate(-12deg);
}

.stamp-circle {
  width: 80px;
  height: 80px;
  border: 3.5px dashed #e74c3c;
  border-radius: 50%;
  color: #e74c3c;
  font-size: 0.95rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  animation: stampSlam 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

@keyframes stampSlam {
  0% { transform: scale(2.5); opacity: 0; }
  100% { transform: scale(1); opacity: 0.9; }
}

.modal-stars {
  font-size: 1.7rem;
}

.modal-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: #3d332a;
}

.modal-desc {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Streamlined Badges Grid in Clear Modal (No long quotes!) */
.clear-badges-panel {
  width: 100%;
  background: #faf7f2;
  border: 2px dashed #ebdccf;
  border-radius: 18px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.clear-badges-hint {
  font-size: 0.95rem;
  font-weight: 800;
  color: #795548;
}

.clear-badges-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.clear-badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 2px solid #ebdccf;
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 4px 10px rgba(74, 64, 54, 0.08);
  animation: badgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes badgePop {
  0% { transform: scale(0.6) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.clear-badge-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-badge-name {
  font-size: 0.95rem;
  font-weight: 900;
  color: #3d332a;
}

.clear-album-note {
  font-size: 0.88rem;
  font-weight: 800;
  color: #e67e22;
  background: #fff8e1;
  padding: 4px 12px;
  border-radius: 10px;
}

.modal-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: #f39c12;
  color: white;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #e67e22;
  transform: translateY(-2px);
}

.btn-secondary {
  width: 100%;
  padding: 11px;
  background: #f4eee6;
  color: var(--text-muted);
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #ebdccf;
}

.btn-danger {
  width: 100%;
  padding: 13px;
  background: #eb3b5a;
  color: white;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(235, 59, 90, 0.35);
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #d63031;
  transform: translateY(-2px);
}

.reset-confirm-card {
  border: 4px solid #ff7675 !important;
  max-width: 440px !important;
}

/* ================= GRADUATION CERTIFICATE MODAL ================= */
.grad-card {
  border: 4px double #f1c40f !important;
  background: #fffdf9 !important;
  padding: 32px 26px !important;
}

.cert-stamp {
  border-color: #27ae60 !important;
  color: #27ae60 !important;
}

.cert-stars {
  font-size: 1.6rem;
}

.cert-body {
  width: 100%;
}

.cert-paper {
  background: #fffaea;
  border: 2px dashed #e67e22;
  border-radius: 18px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.cert-title {
  font-size: 1.28rem;
  font-weight: 900;
  color: #c0392b;
  letter-spacing: 1px;
}

.cert-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #5d4037;
  line-height: 1.6;
}

.cert-rank-display {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
  border: 1.5px solid #fed330;
}

.rank-title {
  font-size: 1.12rem;
  font-weight: 900;
  color: #d35400;
}

.rank-reward {
  font-size: 0.92rem;
  font-weight: 800;
  color: #27ae60;
}

.cert-unlock-note {
  font-size: 0.95rem;
  font-weight: 900;
  color: #2980b9;
}

/* ================= FOOTER ================= */
.game-footer {
  text-align: center;
  padding: 10px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.text-link-btn {
  background: none;
  border: none;
  color: #a49483;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.text-link-btn:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}

.footer-copyright {
  font-size: 0.78rem;
  color: #a89a8c;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.copyright-main {
  font-weight: 800;
  color: #8c7d6f;
  margin: 0 0 2px 0;
}

.copyright-sub {
  font-size: 0.74rem;
  color: #b5a99c;
  margin: 0;
  padding: 0;
}

/* ================= ILLUSTRATED BOOK / COLLECTION ALBUM (3D FLIP CARDS) ================= */
.album-modal-card {
  max-width: 680px !important;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 22px !important;
  background: #fffdf9 !important;
  border: 4px solid #ebdccf !important;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #e0d4c5;
  background: #ffffff;
  color: #795548;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: #ff7675;
  color: white;
  border-color: #ff7675;
  transform: rotate(90deg);
}

.album-book-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: center;
}

.album-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.album-header-icon {
  font-size: 1.8rem;
}

.album-modal-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #3d332a;
}

.album-modal-desc {
  font-size: 0.95rem;
  font-weight: 700;
  color: #795548;
}

.album-stage-tabs {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.album-tab {
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid #e5dacd;
  background: #f8f1e7;
  color: #795548;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s ease;
}

.album-tab:hover {
  background: #eee1d0;
}

.album-tab.active {
  background: #f39c12;
  border-color: #f39c12;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(243, 156, 18, 0.3);
}

/* 3D Flip Card Grid */
.album-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 14px;
  width: 100%;
  padding: 6px 2px;
}

/* Individual Polaroid Card */
.album-polaroid-card {
  aspect-ratio: 0.76;
  perspective: 1000px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

/* Hover floats the entire card container - does NOT touch inner 3D rotation */
.album-polaroid-card:hover:not(.locked) {
  transform: translateY(-4px);
}

.polaroid-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(74, 64, 54, 0.1);
}

/* Flipped state (only triggered by click) */
.album-polaroid-card.flipped .polaroid-inner {
  transform: rotateY(180deg) !important;
}

/* Front & Back Faces */
.polaroid-front, .polaroid-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  padding: 10px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 2.5px solid #ebdccf;
}

/* Front: Polaroid Photo Face */
.polaroid-front {
  background: #ffffff;
}

.polaroid-img-box {
  width: 100%;
  flex: 1;
  background: #faf6f0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  position: relative;
  overflow: hidden;
  font-size: 3.2rem;
}

.polaroid-img-box .item-svg {
  width: 84%;
  height: 84%;
  max-width: 90px;
  max-height: 90px;
  filter: drop-shadow(0 3px 6px rgba(74, 64, 54, 0.08));
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.album-polaroid-card:hover:not(.locked) .polaroid-img-box .item-svg {
  transform: scale(1.08);
}

.polaroid-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: #3d332a;
  margin-top: 6px;
  white-space: nowrap;
}

.polaroid-action-hint {
  font-size: 0.72rem;
  font-weight: 800;
  color: #b2bec3;
}

/* Card States: Locked / Unopened / Opened */
.album-polaroid-card.locked {
  cursor: not-allowed;
  opacity: 0.65;
}

.album-polaroid-card.locked .polaroid-img-box {
  background: #ede6dc;
}

.album-polaroid-card.locked .polaroid-img-box .item-svg {
  filter: grayscale(1) brightness(0.4);
  opacity: 0.22;
}

.locked-lock-icon {
  position: absolute;
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  z-index: 5;
}

.album-polaroid-card.locked .polaroid-title {
  color: #a49483;
}

/* Unopened (New!) glowing card */
.album-polaroid-card.is-unopened .polaroid-front {
  border-color: #f39c12;
  box-shadow: 0 0 14px rgba(243, 156, 18, 0.45);
  animation: cardPulse 1.5s infinite alternate;
}

@keyframes cardPulse {
  from { box-shadow: 0 0 8px rgba(243, 156, 18, 0.3); }
  to { box-shadow: 0 0 18px rgba(243, 156, 18, 0.65); }
}

.unopened-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff4757;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 10px;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 8px rgba(255, 71, 87, 0.5);
  animation: badgeWiggle 0.6s infinite alternate;
  z-index: 35 !important;
  pointer-events: none;
}

@keyframes badgeWiggle {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg); }
}

/* Back: Story & Quote Face */
.polaroid-back {
  background: #fff9e6;
  border-color: #f1c40f;
  transform: rotateY(180deg);
  padding: 12px 10px;
  justify-content: center;
  gap: 8px;
}

.back-quote-title {
  font-size: 0.82rem;
  font-weight: 900;
  color: #d35400;
}

.back-quote-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #5d4037;
  line-height: 1.4;
  font-style: italic;
}

.back-stamp {
  font-size: 0.68rem;
  font-weight: 900;
  color: #27ae60;
  border: 1.5px dashed #27ae60;
  padding: 2px 6px;
  border-radius: 8px;
  transform: rotate(-6deg);
}

/* ================= PLAYER NICKNAME & IMMERSIVE STYLES ================= */
.bubble-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.player-badge-btn {
  background: #ffffff;
  border: 1.5px solid #e0d5c5;
  border-radius: 14px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #5d4037;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 6px rgba(74, 64, 54, 0.08);
  font-family: inherit;
}

.player-badge-btn:hover {
  transform: translateY(-1.5px) scale(1.03);
  border-color: #f39c12;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.22);
  background: #fffdf7;
}

.player-icon {
  font-size: 0.75rem;
}

.player-name-text {
  color: #d35400;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-icon {
  font-size: 0.7rem;
  opacity: 0.75;
}

/* Nickname Modal */
.nickname-modal-card {
  max-width: 440px;
  text-align: center;
}

.nickname-form-wrap {
  margin: 18px 0 10px;
  text-align: left;
}

.nickname-input-group {
  display: flex;
  align-items: center;
  background: #fffbf0;
  border: 2px solid #f1c40f;
  border-radius: 14px;
  padding: 4px 12px;
  box-shadow: inset 0 2px 4px rgba(74, 64, 54, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nickname-input-group:focus-within {
  border-color: #e67e22;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.25);
  background: #ffffff;
}

.nickname-input-prefix {
  font-weight: 800;
  color: #d35400;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nickname-input {
  border: none;
  background: transparent;
  font-size: 0.96rem;
  font-weight: 800;
  color: #4a4036;
  width: 100%;
  outline: none;
  padding: 8px 6px;
  font-family: inherit;
}

.nickname-input::placeholder {
  color: #b2bec3;
  font-weight: 600;
}

.nickname-suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.suggest-label {
  font-size: 0.76rem;
  color: #8c7b6c;
  font-weight: 800;
}

.suggest-pill {
  background: #f7efe6;
  border: 1px solid #dcd2c4;
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #5d4037;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.suggest-pill:hover {
  background: #fed330;
  border-color: #f39c12;
  transform: translateY(-1px);
}

.cert-recipient {
  font-size: 1.05rem;
  font-weight: 800;
  color: #d35400;
  margin: 6px 0 12px;
  text-align: center;
  background: #fff8e7;
  padding: 5px 12px;
  border-radius: 10px;
  display: inline-block;
  border: 1px dashed #f1c40f;
}

