:root {
  --ink: #17324d;
  --ink-soft: #536579;
  --paper: #f8f3e8;
  --surface: #fffdf8;
  --sun: #f6b83f;
  --sun-dark: #d99112;
  --coral: #ef705f;
  --mint: #84c9b1;
  --line: #d9d8d0;
  --shadow: 0 16px 44px rgb(23 50 77 / 12%);
  font-family: Lexend, "Public Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 12%, rgb(246 184 63 / 18%) 0 7rem, transparent 7.1rem),
    radial-gradient(circle at 94% 86%, rgb(132 201 177 / 17%) 0 9rem, transparent 9.1rem),
    var(--paper);
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { width: min(1500px, 100%); min-height: 100vh; margin: auto; padding: 0 clamp(16px, 3vw, 48px); }

.topbar { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgb(23 50 77 / 12%); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: clamp(1.05rem, 2vw, 1.35rem); font-weight: 750; text-decoration: none; letter-spacing: -.03em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--ink); font-size: 1.45rem; transform: rotate(-3deg); }
.topbar-actions { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 30px); }
.level-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid rgb(23 50 77 / 16%); border-radius: 999px; background: rgb(255 255 255 / 55%); font-size: .84rem; font-weight: 700; }
.level-badge span:first-child { color: var(--sun-dark); font-size: 1.1rem; }
.toggle-control { display: inline-flex; min-height: 48px; align-items: center; gap: 9px; cursor: pointer; font-size: .9rem; font-weight: 650; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { position: relative; width: 48px; height: 27px; border-radius: 999px; background: #bcc3c5; transition: background .2s ease; }
.toggle::after { content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgb(0 0 0 / 18%); transition: transform .2s ease; }
.toggle-control input:checked + .toggle { background: var(--mint); }
.toggle-control input:checked + .toggle::after { transform: translateX(21px); }
.toggle-control input:focus-visible + .toggle { outline: 3px solid var(--coral); outline-offset: 3px; }

.mission { position: relative; display: grid; grid-template-columns: minmax(120px, .55fr) minmax(280px, 2fr) minmax(120px, .55fr); align-items: center; gap: clamp(20px, 4vw, 64px); padding: clamp(32px, 6vw, 78px) clamp(4px, 2vw, 26px); }
.letter-tag { position: relative; justify-self: center; display: flex; width: clamp(118px, 14vw, 172px); aspect-ratio: .78; flex-direction: column; align-items: center; justify-content: center; border: 3px solid var(--ink); border-radius: 20px 20px 26px 26px; background: var(--sun); box-shadow: 9px 10px 0 var(--ink); transform: rotate(-3deg); }
.tag-hole { position: absolute; top: 13px; width: 15px; height: 15px; border: 3px solid var(--ink); border-radius: 50%; background: var(--paper); }
.tag-label { margin-top: 15px; font-size: clamp(.65rem, 1vw, .78rem); font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
#letter { font-size: clamp(4.2rem, 8vw, 7.2rem); line-height: .95; letter-spacing: -.08em; }
.mission-copy { max-width: 750px; }
.eyebrow { margin: 0 0 8px; color: var(--coral); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2rem, 4.5vw, 4.4rem); line-height: 1.03; letter-spacing: -.055em; }
.mission-copy > p:not(.eyebrow) { max-width: 590px; margin: 18px 0 24px; color: var(--ink-soft); font-size: clamp(1rem, 1.5vw, 1.17rem); line-height: 1.55; }
.primary-button { min-height: 52px; border: 2px solid var(--ink); border-radius: 15px; padding: 0 22px; background: var(--ink); color: white; box-shadow: 5px 5px 0 var(--sun); cursor: pointer; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease; }
.primary-button:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--sun); }
.primary-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--sun); }
.primary-button:focus-visible, .item-card:focus-visible, .suitcase:focus-visible { outline: 4px solid var(--coral); outline-offset: 4px; }
.score-card { justify-self: end; display: grid; min-width: 126px; min-height: 126px; place-items: center; align-content: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--surface); box-shadow: 7px 7px 0 var(--mint); transform: rotate(2deg); }
.score-label { font-size: .72rem; font-weight: 700; color: var(--ink-soft); }
#score { font-size: 2.8rem; line-height: 1; }
.score-star { color: var(--sun-dark); }

.play-area { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .72fr); gap: clamp(18px, 3vw, 38px); padding-bottom: 42px; }
.objects-panel, .suitcase-panel { border: 1px solid rgb(23 50 77 / 13%); border-radius: 28px; background: rgb(255 253 248 / 88%); box-shadow: var(--shadow); }
.objects-panel { min-height: 510px; padding: clamp(22px, 3vw, 38px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
h2 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.8rem); letter-spacing: -.035em; }
.progress-pill { flex: none; margin: 0; padding: 8px 12px; border-radius: 999px; background: #edf3f1; color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.empty-state { display: grid; min-height: 330px; place-items: center; align-content: center; color: var(--ink-soft); text-align: center; }
.empty-state span { display: grid; width: 64px; height: 64px; place-items: center; border: 2px dashed var(--line); border-radius: 50%; font-size: 2rem; }
.item-grid { display: grid; grid-template-columns: repeat(5, minmax(92px, 1fr)); gap: clamp(10px, 1.6vw, 18px); }
.item-card { position: relative; display: grid; min-height: 124px; place-items: center; align-content: center; gap: 5px; border: 2px solid #e2e0d7; border-radius: 20px; background: white; box-shadow: 0 5px 0 #e4e1d8; cursor: grab; touch-action: none; user-select: none; transition: border .15s ease, transform .15s ease, box-shadow .15s ease, opacity .2s ease; }
.item-card:hover { z-index: 1; border-color: var(--sun-dark); transform: translateY(-4px) rotate(-1deg); box-shadow: 0 9px 0 #e4e1d8; }
.item-card.selected { border-color: var(--coral); box-shadow: 0 0 0 4px rgb(239 112 95 / 18%), 0 5px 0 #e4e1d8; }
.item-card.dragging { z-index: 20; cursor: grabbing; opacity: .9; transition: none; }
.item-card.correct { animation: fly-away .4s ease forwards; }
.item-card.wrong { animation: shake .35s ease; border-color: var(--coral); }
.item-icon { font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; font-size: clamp(2.5rem, 4vw, 3.7rem); line-height: 1; filter: drop-shadow(0 3px 2px rgb(23 50 77 / 10%)); }
.item-name { display: none; max-width: 100%; padding: 0 7px; font-size: .77rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-labels .item-name { display: block; }

.suitcase-panel { display: flex; min-height: 510px; flex-direction: column; align-items: center; padding: clamp(22px, 3vw, 34px); overflow: hidden; }
.suitcase-panel h2 { margin-bottom: 48px; text-align: center; }
.suitcase { position: relative; width: min(100%, 360px); min-height: 300px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.handle { position: absolute; z-index: 0; width: 45%; height: 48px; top: -28px; left: 27.5%; border: 12px solid var(--ink); border-bottom: 0; border-radius: 18px 18px 0 0; }
.case-lid { position: absolute; z-index: 1; width: 92%; height: 110px; left: 4%; top: 8px; border: 3px solid var(--ink); border-radius: 26px 26px 12px 12px; background: var(--coral); box-shadow: inset 0 -10px 0 rgb(23 50 77 / 8%); transform-origin: bottom; transform: perspective(300px) rotateX(-14deg); transition: transform .25s ease; }
.suitcase:hover .case-lid, .suitcase.drop-ready .case-lid { transform: perspective(300px) rotateX(-28deg) translateY(-6px); }
.travel-sticker { position: absolute; display: grid; place-items: center; color: var(--ink); font-size: 1rem; }
.sticker-one { width: 34px; height: 34px; left: 18%; top: 24px; border-radius: 50%; background: var(--sun); transform: rotate(-12deg); }
.sticker-two { right: 20%; top: 31px; color: white; transform: rotate(10deg); }
.case-inside { position: absolute; z-index: 3; display: flex; width: 100%; min-height: 168px; left: 0; top: 96px; align-items: center; justify-content: center; border: 4px solid var(--ink); border-radius: 22px; padding: 18px; background: #e7c58e; box-shadow: inset 0 0 0 8px rgb(255 255 255 / 24%); }
.case-base { position: absolute; z-index: 2; width: 100%; height: 94px; left: 0; top: 194px; border: 4px solid var(--ink); border-radius: 0 0 23px 23px; background: #d39a51; }
.case-base::before, .case-base::after { content: ""; position: absolute; bottom: -13px; width: 34px; height: 13px; border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 7px 7px; background: var(--ink); }
.case-base::before { left: 28px; } .case-base::after { right: 28px; }
.case-hint { color: rgb(23 50 77 / 62%); font-size: .9rem; font-weight: 750; }
.packed-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; font-size: 1.75rem; }
.tap-hint { max-width: 280px; margin: auto 0 0; color: var(--ink-soft); font-size: .77rem; line-height: 1.5; text-align: center; }

footer { display: flex; min-height: 68px; align-items: center; justify-content: center; gap: 10px; border-top: 1px solid rgb(23 50 77 / 12%); color: var(--ink-soft); font-size: .76rem; font-weight: 600; }
.feedback { position: fixed; z-index: 50; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); min-width: 210px; padding: 13px 18px; border-radius: 999px; background: var(--ink); color: white; box-shadow: var(--shadow); font-weight: 750; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: opacity .2s ease, transform .2s ease; }
.feedback.visible { opacity: 1; transform: translate(-50%, 0); }
.feedback.good { background: #23775f; } .feedback.bad { background: #b7443a; }
.modal-backdrop { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(23 50 77 / 55%); backdrop-filter: blur(6px); }
.modal-backdrop[hidden] { display: none; }
.success-card { position: relative; width: min(430px, 100%); border: 3px solid var(--ink); border-radius: 28px; padding: 48px 32px 34px; background: var(--surface); box-shadow: 10px 10px 0 var(--sun); text-align: center; animation: pop-in .35s ease both; }
.success-card > p:not(.eyebrow) { color: var(--ink-soft); line-height: 1.6; }
.success-burst { position: absolute; display: grid; width: 72px; height: 72px; top: -36px; left: calc(50% - 36px); place-items: center; border: 3px solid var(--ink); border-radius: 50%; background: var(--sun); font-size: 2rem; }
.final-score { display: inline-flex; align-items: baseline; gap: 7px; margin: 12px 0 24px; padding: 12px 22px; border-radius: 999px; background: #edf3f1; font-weight: 750; }
.final-score span { font-size: 1.8rem; }

@keyframes shake { 25% { transform: translateX(-8px) rotate(-2deg); } 50% { transform: translateX(8px) rotate(2deg); } 75% { transform: translateX(-5px); } }
@keyframes fly-away { to { opacity: 0; transform: translate(80px, 80px) scale(.4) rotate(10deg); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85) rotate(-2deg); } }

@media (max-width: 1050px) and (min-width: 721px) {
  .app-shell { padding-inline: 22px; }
  .mission { grid-template-columns: 120px 1fr 96px; gap: 24px; padding: 28px 8px; }
  .letter-tag { width: 112px; }
  #letter { font-size: 4.8rem; }
  .score-card { min-width: 94px; min-height: 94px; }
  #score { font-size: 2.2rem; }
  .play-area { grid-template-columns: minmax(0, 1.75fr) minmax(220px, .75fr); gap: 18px; }
  .objects-panel, .suitcase-panel { min-height: 0; padding: 22px; }
  .item-grid { grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 11px; }
  .item-card { min-height: 100px; }
  .item-icon { font-size: 2.7rem; }
  .suitcase-panel h2 { margin-bottom: 42px; }
  .suitcase { max-width: 280px; }
}

@media (max-height: 900px) and (min-width: 721px) {
  .app-shell { display: grid; height: 100dvh; min-height: 0; grid-template-rows: 58px minmax(0, 1fr) 28px; padding-inline: clamp(18px, 2.5vw, 34px); }
  .topbar { min-height: 58px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 1.15rem; }
  .level-badge { min-height: 34px; }
  main { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .mission { grid-template-columns: 88px minmax(280px, 1fr) 78px; gap: 20px; padding: 10px 6px 14px; }
  .letter-tag { width: 76px; border-width: 2px; border-radius: 13px 13px 17px 17px; box-shadow: 5px 5px 0 var(--ink); }
  .tag-hole { top: 8px; width: 10px; height: 10px; border-width: 2px; }
  .tag-label { margin-top: 11px; font-size: .49rem; }
  #letter { font-size: 3.25rem; }
  .mission-copy .eyebrow { margin-bottom: 3px; font-size: .58rem; }
  h1 { font-size: clamp(1.55rem, 3.3vw, 2.75rem); }
  .mission-copy > p:not(.eyebrow) { margin: 5px 0 8px; font-size: .78rem; line-height: 1.35; }
  .primary-button { min-height: 42px; border-radius: 11px; padding-inline: 16px; font-size: .78rem; box-shadow: 3px 3px 0 var(--sun); }
  .score-card { min-width: 72px; min-height: 72px; box-shadow: 4px 4px 0 var(--mint); }
  .score-label { font-size: .55rem; }
  #score { font-size: 1.8rem; }
  .score-star { display: none; }
  .play-area { min-height: 0; grid-template-columns: minmax(0, 1.85fr) minmax(220px, .65fr); gap: 14px; padding-bottom: 8px; }
  .objects-panel, .suitcase-panel { min-height: 0; border-radius: 18px; padding: 12px; }
  .section-heading { margin-bottom: 8px; }
  .section-heading .eyebrow, .suitcase-panel > .eyebrow { margin-bottom: 2px; font-size: .56rem; }
  h2 { font-size: clamp(.95rem, 1.6vw, 1.2rem); }
  .progress-pill { padding: 5px 8px; font-size: .61rem; }
  .empty-state { min-height: 0; height: calc(100% - 46px); }
  .empty-state span { width: 44px; height: 44px; font-size: 1.4rem; }
  .empty-state p { margin: 8px 0; font-size: .75rem; }
  .item-grid { grid-template-columns: repeat(5, minmax(60px, 1fr)); gap: 7px; }
  .item-card { min-height: min(10.5vh, 80px); border-radius: 13px; box-shadow: 0 3px 0 #e4e1d8; }
  .item-icon { font-size: clamp(1.8rem, 4.5vh, 2.5rem); }
  .item-name { font-size: .58rem; }
  .suitcase-panel h2 { margin-bottom: 26px; }
  .suitcase { width: min(100%, 290px); transform: scale(.76); transform-origin: top center; margin-bottom: -72px; }
  .tap-hint { display: none; }
  footer { min-height: 28px; font-size: .62rem; }
}

@media (max-width: 720px) {
  .app-shell { padding: 0 13px; }
  .topbar { min-height: 72px; }
  .play-area { grid-template-columns: 1fr; }
  .level-badge span:last-child, .toggle-control > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mission { grid-template-columns: 102px 1fr; gap: 24px 18px; padding: 30px 6px 36px; }
  .mission-copy .eyebrow { display: none; }
  .score-card { position: absolute; min-width: 75px; min-height: 75px; right: 5px; bottom: -22px; }
  .score-label { font-size: .58rem; } #score { font-size: 2rem; } .score-star { display: none; }
  .letter-tag { width: 96px; box-shadow: 5px 6px 0 var(--ink); }
  .tag-label { font-size: .54rem; } #letter { font-size: 4rem; }
  h1 { font-size: clamp(1.65rem, 7.5vw, 2.35rem); }
  .mission-copy > p:not(.eyebrow) { margin: 12px 0 18px; font-size: .88rem; }
  .primary-button { min-height: 48px; padding: 0 14px; font-size: .86rem; }
  .objects-panel, .suitcase-panel { border-radius: 22px; }
  .objects-panel { min-height: 480px; padding: 20px 13px; }
  .section-heading { align-items: start; }
  .section-heading h2 { max-width: 230px; }
  .progress-pill { padding: 7px 9px; font-size: .68rem; }
  .item-grid { grid-template-columns: repeat(4, 1fr); gap: 9px; }
  .item-card { min-width: 0; min-height: 94px; border-radius: 15px; box-shadow: 0 4px 0 #e4e1d8; }
  .item-icon { font-size: clamp(2rem, 10vw, 3rem); }
  .item-name { font-size: .62rem; }
  .suitcase-panel { min-height: 445px; }
  .suitcase-panel h2 { margin-bottom: 42px; }
}

@media (max-width: 390px) {
  .brand { font-size: 1rem; } .brand-mark { width: 36px; height: 36px; font-size: 1.2rem; }
  .mission { grid-template-columns: 87px 1fr; gap: 14px; }
  .letter-tag { width: 82px; } #letter { font-size: 3.4rem; }
  .item-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
