:root {
  --bg-glass: rgba(255, 250, 248, 0.85);
  --bg-glass-strong: rgba(255, 252, 250, 0.96);
  --border-soft: rgba(235, 195, 185, 0.72);
  --text-main: #3f3649;
  --text-sub: #7a6b8a;
  --accent-pink: #ff8da1;
  --accent-mint: #6cd4ac;
  --shadow-soft: 0 10px 28px rgba(74, 63, 85, 0.15);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #dff6ff;
  color: var(--text-main);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  z-index: 1;
}

/* Soft Clay Crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

#crosshair::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 6px rgba(74, 63, 85, 0.35);
}

#crosshair::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ff8da1;
}

/* Interactive Object Prompt below Crosshair */
#interaction-prompt {
  position: fixed;
  top: calc(50% + 26px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 28px);
  background: rgba(35, 30, 45, 0.86);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1.5px solid rgba(255, 210, 140, 0.8);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 12;
  white-space: normal;
}

#interaction-prompt.hidden {
  display: none;
}

/* Clean Minimal Top Bar */
#top-bar {
  position: fixed;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}

.hud-card {
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 10px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-compact {
  gap: 5px;
}

.mini-stat {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.82);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.mini-stat.appeal-pill {
  background: linear-gradient(135deg, #fff3b0, #ffe5ec);
  border: 1px solid #ffd166;
}

.mini-stat.coin-pill {
  background: linear-gradient(135deg, #ffe5d9, #ffd6a5);
  border: 1px solid #ffb703;
}

.mini-stat.xp-mini {
  background: linear-gradient(135deg, #d8f3dc, #b7e4c7);
  color: #1b4332;
}

.mini-stat.save-pill {
  background: linear-gradient(135deg, #e0fbfc, #c2f8cb);
  border: 1px solid #6cd4ac;
  color: #1b4332;
  transition: transform 0.2s ease, background 0.2s ease;
}

.mini-stat.save-pill.saving {
  transform: scale(1.06);
  background: linear-gradient(135deg, #fff3b0, #8ce0b8);
}

/* Dedicated Floating Quest Guide Banner (Centered below Top Bar) */
#quest-banner {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 20px);
  background: rgba(255, 253, 245, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid #ffd166;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 6px 20px rgba(255, 183, 3, 0.22);
}

.quest-badge {
  background: linear-gradient(135deg, #ff9ebb, #ffb703);
  color: #3d2412;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

#quest-text {
  font-size: 0.82rem;
  font-weight: 800;
  color: #3f3649;
  line-height: 1.3;
  text-align: center;
}

.quest-progress {
  background: #fff3b0;
  color: #5c3d00;
  font-size: 0.74rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-actions {
  gap: 6px;
}

.clay-btn.gacha-highlight-btn {
  background: linear-gradient(135deg, #ffd166, #ff9ebb);
  border-color: #f4a261;
  color: #3d2412;
  box-shadow: 0 4px 12px rgba(255, 158, 187, 0.35);
}

.clay-select,
.clay-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid rgba(220, 185, 195, 0.8);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.clay-select:hover,
.clay-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(74, 63, 85, 0.1);
}

.clay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.clay-btn.active {
  background: linear-gradient(135deg, #8ce0b8, #72ddf7);
  border-color: #5bc299;
  color: #203b33;
}

/* Collapsible Quick Settings Drawer */
#settings-drawer {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 30;
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 76px);
  overflow-y: auto;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid var(--border-soft);
  border-radius: 24px;
  padding: 14px 16px;
  box-shadow: 0 16px 38px rgba(45, 35, 60, 0.24);
}

#settings-drawer.hidden {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.save-status-bar {
  background: linear-gradient(135deg, #e8f8f5, #fef9e7);
  border: 1.5px solid #6cd4ac;
  color: #1b4332;
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
  padding: 6px 10px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drawer-span-full {
  grid-column: 1 / -1;
}

.drawer-grid .clay-btn,
.drawer-grid .clay-select {
  width: 100%;
  text-align: center;
  border-radius: 14px;
  padding: 8px 6px;
  font-size: 0.76rem;
}

/* Real-time Item Pickup Feed */
#pickup-feed {
  position: fixed;
  bottom: 112px;
  right: 22px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.pickup-pill {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 235, 242, 0.94));
  border: 1.5px solid #ff9ebb;
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255, 141, 161, 0.25);
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.pickup-pill.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Bottom Hotbar & Current Block Banner */
#bottom-hud {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: max-content;
  max-width: calc(100vw - 16px);
}

.bottom-banner-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: calc(100vw - 16px);
}

.mini-build-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid rgba(220, 185, 195, 0.85);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(74, 63, 85, 0.12);
  transition: transform 0.14s ease, background 0.14s ease;
}

.mini-build-btn:hover {
  transform: translateY(-1px);
  background: #ffffff;
}

#current-block-banner {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--border-soft);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  max-width: 52vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#hotbar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 7px 10px;
  border-radius: 22px;
  border: 2px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.hotbar-slot {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 15px;
  border: 2px solid rgba(215, 190, 200, 0.6);
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease;
}

.hotbar-slot:hover {
  transform: translateY(-3px) scale(1.04);
}

.hotbar-slot.active {
  transform: translateY(-5px) scale(1.06);
  border-color: #ff758f;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(255, 117, 143, 0.35);
}

.hotbar-slot.empty-slot {
  opacity: 0.48;
}

.slot-key {
  position: absolute;
  top: 2px;
  left: 5px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-sub);
  z-index: 2;
}

.slot-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.92);
  padding: 0 4px;
  border-radius: 6px;
  z-index: 2;
}

.palette-icon {
  font-size: 1.3rem;
}

/* 2D Sprite Sheet Icon Box */
.sprite-icon-box {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sprite-icon-box.large {
  width: 50px;
  height: 50px;
}

.sprite-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.16));
}

/* Full Palette & Crafting Workshop Modal */
#palette-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(45, 35, 60, 0.44);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

#palette-modal.hidden {
  display: none;
}

.palette-dialog {
  background: var(--bg-glass-strong);
  border: 2.5px solid var(--border-soft);
  border-radius: 26px;
  max-width: 820px;
  width: 100%;
  max-height: min(86vh, calc(100dvh - 28px));
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  box-shadow: 0 22px 54px rgba(45, 35, 60, 0.3);
}

.palette-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.palette-header h2 {
  margin: 0 0 4px 0;
  font-size: 1.12rem;
}

.palette-subtitle {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-sub);
  line-height: 1.35;
}

.palette-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid rgba(225, 195, 205, 0.55);
  flex-shrink: 0;
}

.tab-pill {
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(220, 190, 200, 0.7);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.tab-pill:hover {
  background: #ffffff;
}

.tab-pill.active {
  background: linear-gradient(135deg, #ff9ebb, #ffd29d);
  border-color: #ff8da1;
  color: #3d2f47;
  box-shadow: 0 4px 12px rgba(255, 141, 161, 0.25);
}

#palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.palette-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1.5px solid rgba(220, 195, 205, 0.7);
  background: #ffffff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.palette-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-pink);
  box-shadow: 0 6px 16px rgba(255, 141, 161, 0.22);
}

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

.palette-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.palette-card-info strong {
  font-size: 0.84rem;
  color: var(--text-main);
}

.palette-card-info span {
  font-size: 0.71rem;
  color: var(--text-sub);
  line-height: 1.35;
}

.inv-count-pill {
  background: #f8edeb;
  color: #5e506c;
  font-size: 0.67rem !important;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Crafting Workshop Cards */
.craft-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1.5px solid rgba(220, 195, 205, 0.75);
  background: #ffffff;
}

.craft-card.locked {
  opacity: 0.72;
  background: rgba(250, 245, 245, 0.8);
}

.craft-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.craft-desc {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-sub);
  line-height: 1.35;
}

.ing-list {
  font-size: 0.73rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ing-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.ing-badge.ok {
  background: #d8f3dc;
  color: #2d6a4f;
}

.ing-badge.lack {
  background: #ffe5ec;
  color: #c9184a;
}

.craft-action-btn {
  white-space: nowrap;
  padding: 8px 14px;
  flex-shrink: 0;
}

/* Toast Notification */
#toast-message {
  position: fixed;
  top: 102px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: max-content;
  max-width: calc(100vw - 24px);
  background: var(--bg-glass-strong);
  border: 2px solid #ff9ebb;
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
  padding: 8px 16px;
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 35;
}

#toast-message.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Mobile Touch Controls */
#mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
}

#mobile-controls.hidden {
  display: none;
}

#joystick-zone {
  position: absolute;
  bottom: 104px;
  left: 20px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 24px rgba(74, 63, 85, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
}

#joystick-knob {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9ebb, #ffd29d);
  border: 2px solid #ffffff;
  box-shadow: 0 4px 12px rgba(74, 63, 85, 0.25);
  pointer-events: none;
}

/* Ergonomic 2-Row Triangle Cluster for Mobile Action Buttons (Never overlaps Joystick!) */
#mobile-action-pad {
  position: absolute;
  bottom: 100px;
  right: 18px;
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 8px;
  align-items: end;
  justify-items: end;
  pointer-events: auto;
  touch-action: none;
}

#btn-mobile-jump {
  justify-self: end;
}

#btn-mobile-down.hidden + #btn-mobile-jump {
  grid-column: 1 / -1;
}

.mobile-btn.hidden {
  display: none !important;
}

.mobile-btn.primary-down {
  background: linear-gradient(135deg, #e0aaff, #a2d2ff);
}

.mobile-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-main);
  font-weight: 900;
  font-size: 0.74rem;
  line-height: 1.15;
  text-align: center;
  padding: 2px;
  box-shadow: 0 8px 22px rgba(74, 63, 85, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
}

.mobile-btn.primary-place {
  background: linear-gradient(135deg, #9ef0c8, #72ddf7);
}

.mobile-btn.primary-break {
  background: linear-gradient(135deg, #ffb3c1, #ffd6a5);
}

.mobile-btn.primary-fwd-jump {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #ffd166, #ff9ebb);
}

.mobile-btn.active {
  transform: scale(0.94);
  border-color: #ff6b8b;
}

/* Tablet & Mobile Responsive Breakpoints */
@media (max-width: 768px) {
  .mini-stat.save-pill {
    display: none;
  }

  #top-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .hud-card {
    padding: 4px 8px;
    gap: 5px;
  }

  .mini-stat {
    font-size: 0.72rem;
    padding: 2px 7px;
  }

  #top-bar .clay-btn {
    font-size: 0.74rem;
    padding: 5px 9px;
  }

  #quest-banner {
    top: 50px;
    padding: 5px 12px;
    gap: 6px;
    border-radius: 16px;
  }

  .quest-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  #quest-text {
    font-size: 0.76rem;
  }

  .quest-progress {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  #toast-message {
    top: 94px;
    font-size: 0.76rem;
    padding: 7px 14px;
  }

  #pickup-feed {
    bottom: 245px;
    right: 14px;
  }

  .hotbar-slot {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .sprite-icon-box {
    width: 32px;
    height: 32px;
  }
}

/* Narrow Smartphone Portrait (360px ~ 480px) */
@media (max-width: 480px) {
  .mini-stat.xp-mini {
    display: none;
  }

  .hud-card {
    padding: 4px 6px;
    gap: 4px;
  }

  .mini-stat {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  #top-bar .clay-btn {
    font-size: 0.7rem;
    padding: 4px 7px;
  }

  #quest-banner {
    top: 46px;
    max-width: calc(100vw - 16px);
    padding: 4px 10px;
  }

  #quest-text {
    font-size: 0.72rem;
  }

  #joystick-zone {
    bottom: 96px;
    left: 12px;
    width: 98px;
    height: 98px;
  }

  #joystick-knob {
    width: 40px;
    height: 40px;
  }

  #mobile-action-pad {
    bottom: 94px;
    right: 12px;
    grid-template-columns: repeat(2, 56px);
    gap: 6px;
  }

  .mobile-btn {
    width: 56px;
    height: 56px;
    font-size: 0.68rem;
  }

  .mobile-btn.primary-fwd-jump {
    width: 60px;
    height: 60px;
  }

  #bottom-hud {
    bottom: 8px;
    gap: 4px;
  }

  #current-block-banner {
    font-size: 0.72rem;
    padding: 3px 12px;
  }

  #hotbar {
    gap: 5px;
    padding: 6px 8px;
    border-radius: 18px;
  }

  .hotbar-slot {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .sprite-icon-box {
    width: 28px;
    height: 28px;
  }

  .palette-dialog {
    padding: 14px;
    border-radius: 20px;
  }

  .palette-header h2 {
    font-size: 0.96rem;
  }

  .palette-subtitle {
    display: none;
  }

  #palette-grid {
    grid-template-columns: 1fr;
  }

  .craft-card {
    flex-wrap: wrap;
  }

  .craft-action-btn {
    width: 100%;
    text-align: center;
  }
}

/* Mobile Landscape Short Height (< 500px) */
@media (max-height: 500px) {
  #quest-banner {
    top: 46px;
    padding: 3px 10px;
  }

  #joystick-zone {
    bottom: 18px;
    left: 16px;
    width: 96px;
    height: 96px;
  }

  #mobile-action-pad {
    bottom: 18px;
    right: 16px;
  }

  #bottom-hud {
    bottom: 8px;
  }

  #current-block-banner {
    display: none;
  }

  .hotbar-slot {
    width: 42px;
    height: 42px;
  }
}

/* ==========================================================================
   🌟 Pastel Clay Intro & Title Screen Overlay
   ========================================================================== */
#title-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(
    circle at 50% 42%,
    rgba(255, 245, 250, 0.28) 0%,
    rgba(56, 44, 68, 0.48) 100%
  );
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#title-screen.hidden {
  display: none !important;
}

.title-card {
  width: min(560px, 95vw);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 253, 251, 0.96) 0%, rgba(255, 242, 246, 0.96) 100%);
  border: 3px solid #ffffff;
  border-radius: 32px;
  padding: 26px 24px 22px;
  text-align: center;
  box-shadow: 0 22px 54px rgba(58, 42, 72, 0.32), inset 0 2px 0 #ffffff;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.title-badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.title-pill {
  background: #ffe5ec;
  color: #c9184a;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid #ffb3c6;
  letter-spacing: 0.04em;
}

.title-pill.accent {
  background: #e0fbfc;
  color: #0077b6;
  border-color: #90e0ef;
}

.title-logo {
  font-size: clamp(1.7rem, 4.8vw, 2.45rem);
  font-weight: 900;
  color: #3d314a;
  text-shadow: 0 3px 0 #ffffff, 0 6px 16px rgba(255, 143, 163, 0.35);
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
}

.title-en-sub {
  font-size: 0.74rem;
  font-weight: 800;
  color: #ff758f;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

.title-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #5e506c;
  font-weight: 600;
  margin-bottom: 14px;
}

.title-feature-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.title-feature-chips span {
  background: #ffffff;
  border: 1.5px solid #f2d5df;
  color: #4a3f55;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(74, 63, 85, 0.06);
}

.title-loading-box {
  margin: 0 auto 14px;
  max-width: 400px;
}

.title-loading-bar {
  width: 100%;
  height: 10px;
  background: #f3e1e8;
  border-radius: 999px;
  overflow: hidden;
  border: 1.5px solid #ffffff;
  margin-bottom: 5px;
}

.title-loading-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #72ddf7, #ff8fa3, #ffd166);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.title-loading-text {
  font-size: 0.75rem;
  font-weight: 800;
  color: #6b5b7b;
}

.title-save-box {
  background: linear-gradient(135deg, #e8f8f5, #fef9e7);
  border: 1.5px solid #80ed99;
  color: #2b6e44;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
}

.title-save-box.hidden {
  display: none !important;
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.title-main-btn {
  appearance: none;
  width: 100%;
  padding: 13px 20px;
  border-radius: 20px;
  font-size: 1.02rem;
  font-weight: 900;
  cursor: pointer;
  border: 2.5px solid #ffffff;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.title-main-btn.hidden {
  display: none !important;
}

.title-main-btn.continue-btn {
  background: linear-gradient(135deg, #52b788, #2d6a4f);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(45, 106, 79, 0.32);
}

.title-main-btn.start-btn {
  background: linear-gradient(135deg, #ff758f, #ff9ebb);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(255, 117, 143, 0.35);
}

.title-main-btn:hover {
  transform: translateY(-2px);
}

.title-sub-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.title-sub-row .clay-select,
.title-sub-row .clay-btn {
  font-size: 0.78rem;
  padding: 8px 14px;
}

/* ==========================================================================
   🎉 Level-Up Fanfare Banner & Camera Shutter Flash
   ========================================================================== */
#camera-flash {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 95;
  pointer-events: none;
  opacity: 0.92;
  transition: opacity 0.35s ease;
}

#camera-flash.hidden {
  display: none !important;
}

#levelup-banner {
  position: fixed;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  background: linear-gradient(135deg, #fff8d6 0%, #ffe5ec 100%);
  border: 3px solid #ffb703;
  border-radius: 24px;
  padding: 12px 24px;
  text-align: center;
  box-shadow: 0 16px 38px rgba(255, 183, 3, 0.38);
  pointer-events: none;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#levelup-banner.hidden {
  display: none !important;
}

.levelup-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ffb703, #fb8500);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.levelup-title {
  font-size: 1.02rem;
  font-weight: 900;
  color: #3d314a;
}

.levelup-sub {
  font-size: 0.76rem;
  font-weight: 700;
  color: #6b5b7b;
  margin-top: 2px;
}

/* ==========================================================================
   📸 Polaroid Photo Studio Modal & 📖 Guide Modal
   ========================================================================== */
#photo-modal,
#guide-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(52, 41, 64, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#photo-modal.hidden,
#guide-modal.hidden {
  display: none !important;
}

.photo-dialog,
.guide-dialog {
  width: min(680px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-glass-strong);
  border: 3px solid #ffffff;
  border-radius: 28px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.polaroid-frame-wrap {
  background: #ffffff;
  padding: 12px;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(74, 63, 85, 0.16);
  margin: 12px 0 16px;
  text-align: center;
}

#photo-preview-img {
  max-width: 100%;
  max-height: 56vh;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}

.photo-actions {
  display: flex;
  justify-content: center;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.guide-card {
  background: #ffffff;
  border: 1.5px solid #f2d5df;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 4px 12px rgba(74, 63, 85, 0.06);
}

.guide-card h3 {
  font-size: 0.9rem;
  font-weight: 900;
  color: #c9184a;
  margin-bottom: 8px;
}

.guide-card p {
  font-size: 0.78rem;
  line-height: 1.5;
  color: #4a3f55;
  margin-bottom: 6px;
}

.guide-card code {
  background: #ffe5ec;
  color: #c9184a;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 800;
}

