body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  margin: 0;
  background-color: #ffffff;
}

.arrows {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 48px;
  height: 100vh;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
  padding: 0 20px;
  pointer-events: none;
}

.arrows .arrow {
  pointer-events: auto;
  user-select: none;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.arrows .arrow:hover {
  cursor: pointer;
  transform: scale(1.08);
  opacity: 0.85;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
  background-color: #ffffff;
}

#map > img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
  display: block;
}

#map > img:not([src]) {
  visibility: hidden;
}

.pie-container {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 5;
  cursor: pointer;
  user-select: none;
  width: 50px;
  height: 50px;
  transition: transform 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  padding: 2px;
}

.pie-container:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.pie-container:has(img[src]) {
  background-color: transparent;
  padding: 0;
}

.pie-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pie-image:not([src]) {
  display: none;
}

.interactive-item {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 8;
  user-select: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3px;
  border: 2px solid #1d1d1d;
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #1d1d1d;
}

.key-item {
  width: 46px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: transparent;
  overflow: visible;
}

.key-item::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 0;
  top: 0;
  border-radius: 50%;
  box-sizing: border-box;
  border: 4px solid #e7bc4f;
  background: transparent;
}

.key-item::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 6px;
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: #e7bc4f;
  box-shadow: 12px 4px 0 #e7bc4f, 18px 4px 0 #e7bc4f;
}

.door-item {
  width: 52px;
  height: 86px;
  padding: 0;
  border-radius: 6px 6px 2px 2px;
  border: 3px solid #4f2e17;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 30%),
    repeating-linear-gradient(90deg, #8b5a32 0 12px, #7a4d2b 12px 24px);
  box-shadow: inset 0 0 0 2px #a46f43, 0 6px 12px rgba(0, 0, 0, 0.35);
  color: transparent;
  overflow: hidden;
}

.door-item::before {
  content: "";
  position: absolute;
  left: 8px; right: 8px; top: 12px; bottom: 14px;
  border: 2px solid rgba(58, 32, 16, 0.45);
  border-radius: 4px;
}

.door-item::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  right: 8px; top: 44px;
  border-radius: 50%;
  background: #f2c86d;
  border: 1px solid #7a5a1f;
}

.door-item-open {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0) 40%),
    repeating-linear-gradient(90deg, #6b8c5a 0 12px, #5a7a4a 12px 24px) !important;
  border-color: #2e5a1e !important;
  box-shadow: inset 0 0 0 2px #7ab06a, 0 0 18px 4px rgba(80,200,60,0.35), 0 6px 12px rgba(0,0,0,0.35) !important;
  cursor: pointer !important;
}

.door-glow {
  box-shadow: inset 0 0 0 2px #ffe06a, 0 0 18px 6px rgba(255,200,40,0.55), 0 6px 12px rgba(0,0,0,0.35) !important;
  border-color: #e7bc4f !important;
}

#cursor-item {
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  pointer-events: none;
  transform: none;
}

.cursor-item { position: fixed; pointer-events: none; z-index: 300; transform: translate(-50%, -50%); }
.cursor-item-hidden { display: none; }
.cursor-key { width: 46px; height: 16px; position: fixed; }
.cursor-key::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 0; top: 0;
  border-radius: 50%;
  box-sizing: border-box;
  border: 4px solid #e7bc4f;
  background: transparent;
}
.cursor-key::after {
  content: "";
  position: absolute;
  left: 14px; top: 6px;
  width: 28px; height: 4px;
  border-radius: 2px;
  background: #e7bc4f;
  box-shadow: 12px 4px 0 #e7bc4f, 18px 4px 0 #e7bc4f;
}

.cursor-owlfood, .cursor-fishingrod {
  width: 32px; height: 32px;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  position: fixed;
}
.cursor-owlfood::before    { content: "🍖"; }
.cursor-fishingrod::before { content: "🎣"; }

.book-item {
  font-size: 28px;
  background: none;
  border: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}

.mixing-bowl-item {
  font-size: 28px;
  background: none;
  border: none;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}

.owl-item {
  font-size: 26px;
  background: transparent;
  border: none;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: transform 0.2s ease;
}
.owl-item:hover { transform: translate(-50%,-50%) scale(1.15); }

.store-counter-item {
  font-size: 14px;
  background: rgba(255,255,255,0.9);
  border: 2px solid #666;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

/* CODE button on map */
.code-btn-item {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
  background: rgba(10, 10, 30, 0.88);
  color: #a0e8ff;
  border: 2px solid #3af;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(60,170,255,0.7);
  box-shadow: 0 0 10px rgba(40,140,255,0.3);
}

/* ─── INDEX BUTTON ─────────────────────────────────────────────────────────── */
#index-btn {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 11px 22px;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  color: #1c1b1a;
  background: linear-gradient(135deg, #ffd88a, #ffb347);
  border: 2px solid #7a4b00;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(70, 40, 0, 0.35);
  pointer-events: auto;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#index-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 12px 26px rgba(70, 40, 0, 0.45);
}

/* ─── INDEX MODAL ──────────────────────────────────────────────────────────── */
#index-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: radial-gradient(circle at 20% 10%, rgba(255,198,113,0.25), rgba(0,0,0,0.82));
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  animation: modalFadeIn 0.24s ease;
}

.modal-hidden { display: none !important; }

.modal-content {
  width: min(1020px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  border-radius: 16px;
  padding: 24px 24px 28px;
  color: #2e2214;
  background: linear-gradient(180deg, #fff8eb 0%, #ffeac8 100%);
  border: 2px solid #d59b45;
  box-shadow: 0 25px 55px rgba(0,0,0,0.4);
  animation: popIn 0.24s ease;
}

.modal-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding-right: 34px;
  margin-bottom: 8px;
}

.modal-header h2 { margin: 0; font-size: 30px; line-height: 1; }

#collection-stats {
  margin: 0;
  font-weight: 700;
  font-size: 14px;
  color: #6f4d1a;
  background: rgba(255,255,255,0.7);
  border: 1px solid #d7a45c;
  border-radius: 999px;
  padding: 6px 10px;
}

/* Search bar */
#pie-search-wrap {
  margin-bottom: 10px;
}

#pie-search {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 14px;
  font-size: 14px;
  border: 1.5px solid #d59b45;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  color: #2e2214;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#pie-search:focus {
  border-color: #c07800;
  box-shadow: 0 0 0 3px rgba(192,120,0,0.18);
}
#pie-search::placeholder { color: #a07840; }

#image-credit-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6f4d1a;
  opacity: 0.9;
}

#close-modal {
  position: absolute;
  top: 10px; right: 18px;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  color: #8d5921;
  transition: transform 0.18s ease, color 0.18s ease;
}
#close-modal:hover { color: #6f4317; transform: scale(1.1); }

#pies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

#detail-view { animation: popIn 0.2s ease; }

#back-to-index {
  background: #fff;
  color: #6f4317;
  border: 1px solid #d59b45;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  cursor: pointer;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.detail-header h2 { margin: 8px 0; }

#detail-owned-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #ffe2b5;
  border: 1px solid #d59b45;
}

.detail-main {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  margin: 10px 0 16px;
  align-items: start;
}

.detail-preview-wrap {
  width: 180px; height: 180px;
  border-radius: 12px;
  background: radial-gradient(circle at 35% 30%, #ffffff, #ffeccf);
  border: 1px solid #e4b671;
  display: flex; align-items: center; justify-content: center;
}

#detail-image {
  width: auto; height: auto;
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}

.detail-info p { margin: 0 0 8px; }

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  font-size: 13px;
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(196,136,50,0.35);
  box-shadow: 0 8px 15px rgba(76,49,7,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  animation: cardIn 0.34s ease forwards;
}
.grid-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 13px 24px rgba(76,49,7,0.2);
  border-color: rgba(184,120,30,0.68);
}
.grid-item.missing { background: rgba(255,255,255,0.42); }
.grid-item.locked { cursor: default; }
.grid-item.locked:hover {
  transform: none;
  box-shadow: 0 8px 15px rgba(76,49,7,0.1);
  border-color: rgba(196,136,50,0.35);
}

.grid-img-wrap {
  width: 82px; height: 82px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #ffffff, #ffeccf);
  border: 1px solid #e4b671;
  border-radius: 10px;
  margin-bottom: 2px;
}

.grid-img {
  width: auto; height: auto;
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}

.grid-item.missing .grid-img,
.grid-item.missing .grid-text-fallback { filter: grayscale(100%); opacity: 0.38; }

.grid-question-mark {
  font-size: 44px; line-height: 1;
  font-weight: 800; color: #8e6b35; opacity: 0.72;
}

.difficulty-tag {
  font-size: 11px;
  margin-top: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  background-color: #f5d7a5;
  border: 1px solid #d99a44;
}

#reset-btn {
  background: linear-gradient(180deg, #ff6d5d, #d53a2d);
  color: white;
  border: 1px solid #9e2318;
  padding: 8px 14px;
  font-weight: bold;
  border-radius: 999px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: transform 0.16s ease, filter 0.16s ease;
}
#reset-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }

/* ─── DIFFICULTY COLORS ────────────────────────────────────────────────────── */
.diff-harder {
  background: #ffe0f0; border-color: #e03090; color: #6b0030;
  font-weight: 900;
  animation: harderPulse 2.4s ease-in-out infinite;
}
@keyframes harderPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,0,100,0); }
  50%      { box-shadow: 0 0 0 4px rgba(220,0,100,0.3); }
}

/* Portal buttons (ocean, cave, rooftop) */
.portal-btn-item {
  font-size: 12px;
  font-weight: 800;
  background: rgba(10, 10, 40, 0.82);
  color: #c0dfff;
  border: 2px solid #4488cc;
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 0 8px rgba(30, 100, 200, 0.3);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.portal-btn-item:hover {
  background: rgba(20, 30, 80, 0.92);
  box-shadow: 0 0 14px rgba(60, 140, 255, 0.5);
}

/* Owl food item */
.owl-food-item {
  font-size: 22px;
  background: none;
  border: none;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.owl-food-item:hover { transform: translate(-50%, -50%) scale(1.1); }
.diff-easy   { background: #d4f5d0; border-color: #5db85a; color: #245a22; }
.diff-normal { background: #d0e8ff; border-color: #5a9bd8; color: #1a3e6e; }
.diff-medium { background: #fff3c0; border-color: #d4a017; color: #5a3e00; }
.diff-hard   { background: #ffd5c2; border-color: #d45a2a; color: #6b1f00; }
.diff-insane {
  background: #f0ccff; border-color: #9b3dc8; color: #3a0060;
  font-weight: 900;
  animation: insanePulse 1.8s ease-in-out infinite;
}
.diff-crazy {
  background: #1a0020; border-color: #ff00cc; color: #ff88ff;
  font-weight: 900;
  animation: crazyPulse 0.9s ease-in-out infinite;
  text-shadow: 0 0 6px #ff00cc;
}
.diff-secret {
  background: #111; border-color: #444; color: #555;
  font-weight: 900;
  letter-spacing: 1px;
}

@keyframes insanePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(155,61,200,0); }
  50%      { box-shadow: 0 0 0 4px rgba(155,61,200,0.35); }
}
@keyframes crazyPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,0,204,0); border-color: #ff00cc; }
  50%      { box-shadow: 0 0 0 5px rgba(255,0,204,0.45); border-color: #ff66ff; }
}

/* ─── TOAST ────────────────────────────────────────────────────────────────── */
#game-toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,12,0,0.88);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px; font-weight: 600;
  z-index: 200;
  pointer-events: none; opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw; text-align: center;
}
#game-toast.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#game-toast.toast-hidden  { opacity: 0; transform: translateX(-50%) translateY(20px); }

/* ─── ANIMATIONS ───────────────────────────────────────────────────────────── */
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .modal-content { padding: 18px 14px 20px; }
  .modal-header h2 { font-size: 24px; }
  #collection-stats { font-size: 12px; padding: 5px 8px; }
  #pies-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .detail-main { grid-template-columns: 1fr; }
  .detail-preview-wrap { width: 100%; max-width: 180px; }
}
