/* ── 1. CSS CUSTOM PROPERTIES (:root) ── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700;800&display=swap');

:root {
  --bg:        #F9F8F6;
  --ink:       #2D2B2A;
  --matcha:    #8A9A5B;
  --matcha-lt: #C8D5A3;
  --danger:    #D9534F;
  --white:     #FFFFFF;
  --yellow:    #F5C542;
  --orange:    #E8834A;
}

/* ── 2. RESET & BASE ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ── 3. TYPOGRAPHY ── */
body {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 800;
}

/* ── 4. LAYOUT ── */
#app {
  width: 100vw;
  height: 100vh;
  position: relative;
  background-color: var(--bg);
  background-image: radial-gradient(#2D2B2A28 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  overflow: hidden;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ── LOADING SCREEN ── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

#loading-screen.hide {
  opacity: 0;
  pointer-events: none;
}

#loading-box {
  text-align: center;
  border: 4px solid var(--white);
  box-shadow: 6px 6px 0px var(--matcha);
  background: var(--ink);
  padding: 36px 48px;
}

#loading-text {
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-top: 16px;
  margin-bottom: 20px;
}

#loading-bar-wrap {
  width: 200px;
  height: 10px;
  border: 3px solid var(--white);
  box-shadow: 3px 3px 0px var(--matcha);
  background: transparent;
  margin: 0 auto;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: var(--matcha);
  transition: width 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── INTRO HIDDEN STATES ── */
#deco-layer         { opacity: 0; }
#main-header        { opacity: 0; transform: translateY(32px); transition: opacity 0.4s ease, transform 0.4s ease; }
#btn-microscope     { opacity: 0; transform: translateX(-40px); transition: opacity 0.4s ease, transform 0.4s ease; }
#btn-matcha         { opacity: 0; transform: translateX(40px); transition: opacity 0.4s ease, transform 0.4s ease; }
#btn-books          { opacity: 0; transform: translateY(40px); transition: opacity 0.4s ease, transform 0.4s ease; }
#btn-trash          { opacity: 0; transform: translateY(20px); transition: opacity 0.4s ease, transform 0.4s ease; }
#footer-credit      { opacity: 0; transition: opacity 0.4s ease; }
.sticker            { opacity: 0; transform: scale(0.6); transition: opacity 0.4s ease, transform 0.4s ease; }
.secret-hint        { opacity: 0; transition: opacity 0.6s ease; }

/* ── INTRO VISIBLE STATE ── */
.intro-visible {
  opacity: 1 !important;
  transform: none;
}

.desk-item.intro-visible.float-ready {
  transform: unset;
}

.sticker.intro-visible {
  transform: rotate(var(--sticker-rotate, 0deg)) !important;
}

/* ── TYPEWRITER CURSOR ── */
.cursor {
  animation: blink 0.7s step-end infinite;
  font-weight: 400;
  color: var(--matcha);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

#center-zone {
  position: relative;
  z-index: 1;
}

#floating-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2;
}

#floating-zone .desk-item {
  pointer-events: auto;
}

/* ── DECO LAYER ── */
#deco-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.deco {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.deco-square {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0px var(--ink);
}

.deco-diamond {
  width: 20px;
  height: 20px;
  border: 3px solid var(--ink);
  transform: rotate(45deg);
  background: transparent;
}

.deco-line {
  width: 48px;
  height: 6px;
  background: var(--ink);
  border-radius: 0;
}

.sticker {
  position: absolute;
  background: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0px var(--ink);
  padding: 5px 10px;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 1;
  white-space: nowrap;
}

/* ── 5. HEADER CARD ── */
#main-header {
  max-width: 480px;
  width: 92%;
  padding: 36px;
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0px var(--ink);
  border-radius: 0;
  position: relative;
  z-index: 5;
}

.header-cake-icon {
  display: block;
  margin: 0 auto 16px auto;
  text-align: center;
  line-height: 1;
}

.header-cake-icon ph-cake {
  font-size: 48px;
  color: var(--matcha);
}

.header-row1 {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header-name-letter {
  background: var(--matcha);
  color: var(--white);
  padding: 10px 20px;
  border: 3px solid var(--ink);
  font-size: 2.6rem;
  font-weight: 800;
  display: inline-block;
  border-radius: 0;
  line-height: 1.1;
}

.header-badge {
  margin-left: auto;
  background: var(--matcha);
  color: var(--white);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0px var(--ink);
  border-radius: 0;
  white-space: nowrap;
}

.header-subtitle {
  margin-top: 16px;
  /* border-left: 5px solid var(--danger); */
  padding-left: 0px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink);
}

.secret-hint {
  display: block;
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--matcha);
  font-style: italic;
  opacity: 0.75;
}

/* ── 6. DESK ITEM BUTTONS ── */
.desk-item {
  width: 130px;
  height: 130px;
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0px var(--ink);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  position: absolute;
  font-family: 'Space Grotesk', sans-serif;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.desk-item ph-microscope,
.desk-item ph-coffee,
.desk-item ph-books {
  font-size: 68px;
  color: var(--ink);
}

#btn-microscope { background: var(--yellow); }
#btn-matcha     { background: var(--orange); }
#btn-books      { background: var(--matcha-lt); }

.desk-item .desk-item-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#btn-microscope {
  left: calc(50% - 380px);
  top: calc(50% - 100px);
}

#btn-matcha {
  right: calc(50% - 380px);
  left: auto;
  top: calc(50% - 100px);
}

#btn-books {
  left: 50%;
  margin-left: -65px;
  bottom: calc(50% - 370px);
  top: auto;
}

.float-ready#btn-microscope { animation: float 3.2s ease-in-out 0s infinite !important; }
.float-ready#btn-matcha     { animation: float 2.8s ease-in-out 0.6s infinite !important; }
.float-ready#btn-books      { animation: float 3.5s ease-in-out 1.1s infinite !important; }

.desk-item:hover {
  animation-play-state: paused;
  box-shadow: 2px 2px 0px var(--ink);
}

#btn-microscope:hover,
#btn-matcha:hover {
  transform: scale(1.08) translateY(-4px);
}

#btn-books:hover {
  transform: scale(1.08) translateY(-4px);
}

/* ── 7. TRASH CAN ── */
#btn-trash {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  width: 72px;
  height: 72px;
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0px var(--ink);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s ease;
}

#btn-trash ph-trash {
  font-size: 36px;
  color: var(--danger);
}

#btn-trash .trash-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
}

#btn-trash:hover {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0px var(--ink);
}

/* ── 8. SECRET INDICATOR DOTS ── */
#secret-indicator {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 200;
  height: 6px;
}

.secret-dot {
  width: 6px;
  height: 6px;
  background: var(--matcha);
  border-radius: 50%;
  transition: opacity 0.2s ease;
}

/* ── 9. CURSOR TRAIL DOTS ── */
.trail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.8;
}

@media (pointer: coarse) {
  .trail-dot {
    display: none !important;
  }
}

/* ── 10. FOOTER ── */
#footer-credit {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--matcha);
  letter-spacing: 0.08em;
  z-index: 40;
  white-space: nowrap;
}

/* ── 11. MODAL BASE ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 43, 42, 0.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: var(--white);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0px var(--ink);
  max-width: 360px;
  width: 90%;
  padding: 28px;
  border-radius: 0;
  position: relative;
  animation: modal-in 0.25s ease-out;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--danger);
  color: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0px var(--ink);
  padding: 4px 10px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border-radius: 0;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s ease;
  z-index: 5;
  line-height: 1;
}

.modal-close:hover {
  transform: translate(3px, 3px);
  box-shadow: none;
}

/* ── 12. MODAL VARIANTS ── */

/* Info Modal */
.modal-info-icon {
  text-align: center;
  margin-bottom: 4px;
}

.modal-info-icon ph-microscope,
.modal-info-icon ph-books {
  font-size: 48px;
  color: var(--ink);
}

.modal-info-title {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  margin: 12px 0;
}

.modal-info-body {
  font-size: 0.92rem;
  line-height: 1.7;
  text-align: center;
}

/* Video/Phone Modal */
.modal-phone {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.phone-frame {
  background: #1C1C1E;
  border: 6px solid var(--ink);
  box-shadow: 8px 8px 0px var(--ink);
  width: 220px;
  padding: 16px 10px 20px;
  border-radius: 0;
}

.phone-notch {
  width: 70px;
  height: 10px;
  background: var(--ink);
  margin: 0 auto 12px;
  display: block;
  border-radius: 0;
}

.phone-frame video {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
  border-radius: 0;
  background: #000;
}

.phone-close-btn {
  width: 220px;
  background: var(--danger);
  color: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
  padding: 10px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 0;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s ease;
}

.phone-close-btn:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* Gacha Spin Modal */
.gacha-spin-content {
  text-align: center;
  padding: 32px 16px;
}

.gacha-spin-icon {
  display: inline-block;
  animation: spin-fast 0.35s linear infinite;
}

.gacha-spin-icon ph-coffee {
  font-size: 72px;
  color: var(--matcha);
}

.gacha-spin-text {
  font-weight: 700;
  font-size: 1rem;
  margin-top: 16px;
  color: var(--ink);
}

/* Gacha Result Modal */
.gacha-result-box {
  padding: 0 !important;
  overflow: hidden;
}

/* ── 13. GACHA RESULT ACCENT STRIPS ── */
.gacha-accent-strip {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.3rem;
}

.gacha-accent-strip.zonk {
  background: var(--danger);
  color: var(--white);
}

.gacha-accent-strip.truth {
  background: var(--yellow);
  color: var(--ink);
}

.gacha-accent-strip.dare {
  background: var(--orange);
  color: var(--white);
}

.gacha-accent-strip ph-confetti,
.gacha-accent-strip ph-fire {
  font-size: 24px;
}

.gacha-result-body {
  padding: 16px 28px 28px;
}

.gacha-result-image {
  width: 150px;
  height: 150px;
  object-fit: cover;
  display: block;
  margin: 16px auto 0;
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
  border-radius: 0;
}

.gacha-result-text {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-top: 12px;
  text-align: center;
}

.gacha-result-subnote {
  font-weight: 800;
  color: var(--danger);
  margin-top: 10px;
  text-align: center;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.gacha-result-subnote ph-camera {
  font-size: 16px;
}

.gacha-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* Secret Modal */
.modal-secret-box {
  border: 4px solid var(--matcha) !important;
  box-shadow: 8px 8px 0px var(--matcha) !important;
  max-width: 320px;
  padding: 32px !important;
  text-align: center;
}

#modal-secret ph-confetti {
  display: inline-block;
  animation: confetti-wiggle 0.8s ease-in-out infinite;
  display: block;
  margin: 0 auto;
}

.secret-heart-icon ph-heart {
  font-size: 48px;
  color: var(--danger);
}

.secret-message {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
  margin: 20px 0;
  white-space: pre-line;
}

.secret-signature {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--matcha);
  font-style: italic;
  margin-top: 20px;
}

/* ── 14. BUTTONS ── */
.btn {
  display: block;
  width: 100%;
  padding: 10px 24px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 0;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s ease;
  text-align: center;
  text-decoration: none;
}

.btn-matcha {
  background: var(--matcha);
  color: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
}

.btn-matcha:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
  background: var(--matcha-lt);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
}

.btn-danger:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.btn-outline {
  background: var(--white);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0px var(--ink);
}

.btn-outline:hover {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.btn-ink {
  background: var(--ink);
  color: var(--white);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0px var(--ink);
}

.btn-ink:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* ── 15. ANIMATIONS ── */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-8px); }
}

@keyframes float-books {
  0%, 100% { transform: translateY(0px) translateX(0px); }
  50%      { transform: translateY(-12px) translateX(0px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

.is-shaking {
  animation: shake 0.3s ease !important;
}

@keyframes modal-in {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes spin-fast {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes confetti-wiggle {
  0%   { transform: rotate(-15deg) scale(1); }
  25%  { transform: rotate(15deg) scale(1.1); }
  50%  { transform: rotate(-10deg) scale(0.95); }
  75%  { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(-15deg) scale(1); }
}

/* ── DECO POP ANIMATION ── */
@keyframes deco-pop {
  from { opacity: 0; transform: scale(0.4) rotate(var(--deco-rotate, 0deg)); }
  to   { opacity: 1; transform: scale(1) rotate(var(--deco-rotate, 0deg)); }
}

#deco-layer.intro-visible { opacity: 1; transition: none; }

#deco-layer.intro-visible .deco-square,
#deco-layer.intro-visible .deco-diamond,
#deco-layer.intro-visible .deco-line {
  animation: deco-pop 0.35s ease forwards;
}

#deco-layer .deco { opacity: 0; }

.deco:nth-child(1)  { animation-delay: 0ms !important; }
.deco:nth-child(2)  { animation-delay: 60ms !important; }
.deco:nth-child(3)  { animation-delay: 120ms !important; }
.deco:nth-child(4)  { animation-delay: 180ms !important; }
.deco:nth-child(5)  { animation-delay: 240ms !important; }
.deco:nth-child(6)  { animation-delay: 300ms !important; }
.deco:nth-child(7)  { animation-delay: 360ms !important; }
.deco:nth-child(8)  { animation-delay: 420ms !important; }
.deco:nth-child(9)  { animation-delay: 480ms !important; }
.deco:nth-child(10) { animation-delay: 540ms !important; }

/* ── 16. RESPONSIVE ── */
@media (max-width: 900px) {
  #btn-microscope {
    left: calc(50% - 300px);
  }
  #btn-matcha {
    right: calc(50% - 300px);
    left: auto;
  }
}

@media (max-width: 480px) {
  html, body {
    overflow: auto;
  }

  #deco-layer {
    display: none;
  }

  #app {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: flex-start; */
    justify-content: center;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    /* padding: 24px 16px 120px 16px; */
    padding: 24px 16px;
    gap: 24px;
  }

  #center-zone {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  #main-header {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    order: 1;
  }

  .header-name-letter {
    font-size: 1.5rem;
    padding: 6px 12px;
  }

  .header-subtitle {
    font-size: 0.77rem;
  }

  .header-badge {
    font-size: 0.5rem;
  }

  /* Reflow floating zone into grid below header card */
  #floating-zone {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 8px;
    order: 2;
  }

  /* Reset all absolute positioning on mobile */
  #btn-microscope,
  #btn-matcha,
  #btn-books {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none;
    width: 100% !important;
    height: 90px !important;
    margin: 0 !important;
  }

  .desk-item ph-microscope,
  .desk-item ph-coffee,
  .desk-item ph-books {
    font-size: 36px;
  }

  .desk-item .desk-item-label {
    font-size: 8px;
  }

  #btn-trash {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 60px;
    height: 60px;
    z-index: 50;
  }

  #btn-trash ph-trash {
    font-size: 28px;
  }

  #footer-credit {
    position: fixed;
    bottom: 20px;
    left: 16px;
    right: auto;
    transform: none;
    font-size: 11px;
  }

  .modal-box {
    max-width: 320px;
  }

  .trail-dot {
    display: none !important;
  }

}
