@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  --ink: #17324d;
  --muted: #6a8193;
  --cream: #fffaf0;
  --paper: #fffefb;
  --blue: #bdeaff;
  --blue-deep: #56b9e8;
  --navy: #1d4563;
  --mint: #bfeccc;
  --mint-deep: #56b981;
  --orange: #ffb34f;
  --coral: #ff8e80;
  --lavender: #d8ceff;
  --shadow: 0 22px 50px rgba(52, 91, 118, 0.14);
  --soft-shadow: 0 10px 22px rgba(59, 93, 115, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f9f2e6;
  color: var(--ink);
  font-family: 'Tajawal', 'Tahoma', Arial, sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  padding: 34px clamp(14px, 4vw, 60px) 54px;
  overflow: hidden;
}

.app-shell::before {
  content: '';
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    radial-gradient(circle at 10% 9%, rgba(255, 210, 127, .36) 0 4%, transparent 4.2%),
    radial-gradient(circle at 92% 77%, rgba(190, 231, 255, .55) 0 13%, transparent 13.2%),
    linear-gradient(145deg, #fff9eb 0%, #f4fbfd 55%, #e9f6ef 100%);
}

.app-shell::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 620px;
  height: 620px;
  left: -240px;
  bottom: -330px;
  border-radius: 48%;
  background: rgba(255,255,255,.48);
  transform: rotate(18deg);
}

.sun-ray { position: absolute; border-radius: 999px; background: #ffd889; opacity: .5; z-index: -1; transform: rotate(38deg); }
.sun-ray-one { width: 110px; height: 10px; top: 86px; right: 11%; }
.sun-ray-two { width: 68px; height: 10px; top: 118px; right: 8%; }

.hero-panel, .game-card, .last-result { max-width: 1160px; margin-inline: auto; }
.hero-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 8px 26px; }
.brand-lockup { display: flex; align-items: center; gap: 15px; }
.brand-mark { width: 61px; height: 61px; border-radius: 20px 20px 24px 8px; background: var(--navy); color: white; display: grid; place-items: center; position: relative; box-shadow: 7px 7px 0 rgba(86, 185, 232, .38); transform: rotate(-5deg); }
.brand-mark span:first-child { font-size: 31px; transform: rotate(5deg) translate(4px, -2px); }
.brand-mark span:last-child { font-size: 17px; position: absolute; left: 11px; bottom: 8px; color: #ffb34f; }
.eyebrow { margin: 0 0 4px; color: #4b9abf; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(29px, 4vw, 46px); line-height: 1; letter-spacing: -.04em; font-weight: 900; }
.hero-copy { max-width: 400px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.how-to { display: flex; align-items: center; gap: 8px; padding: 11px 15px; background: rgba(255,255,255,.58); border: 1px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 8px 20px rgba(53, 94, 114, .06); font-size: 12px; white-space: nowrap; }
.how-to-step { display: flex; gap: 6px; align-items: center; color: #456274; }
.how-to-step b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 8px; background: #fff; color: var(--blue-deep); font-size: 12px; }
.how-to-arrow { color: #a4bcc9; font-weight: 900; }

.game-card { background: rgba(255, 254, 251, .88); border: 1px solid rgba(255,255,255,.85); border-radius: 34px; box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(12px); }
.game-topbar { display: flex; align-items: center; gap: 22px; padding: 21px clamp(20px, 4vw, 44px); border-bottom: 1px solid #edf1ee; }
.progress-wrap { flex: 1; max-width: 360px; }
.progress-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: #8a9aa7; font-size: 12px; font-weight: 700; }
.progress-label strong { color: var(--ink); }
.progress-track { height: 9px; border-radius: 9px; background: #e8f0f2; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #78d8b1, #6cc5e7); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.score-pill { display: flex; align-items: center; gap: 7px; min-width: 103px; height: 42px; padding: 0 14px; border-radius: 14px; background: #fff3cf; color: #8f681b; font-weight: 900; }
.score-star { font-size: 22px; line-height: 1; color: #f7ad2f; text-shadow: 1px 2px 0 #ffd978; }
.score-pill small { font-size: 11px; margin-right: auto; font-weight: 700; color: #b08d4d; }
.icon-button { width: 42px; height: 42px; border: 0; background: #edf8fc; border-radius: 14px; font-size: 18px; transition: transform .2s, background .2s; }
.icon-button:hover { transform: translateY(-2px); background: #dff2fb; }

.game-area { padding: 30px clamp(18px, 5vw, 64px) 36px; }
.play-intro { display: flex; align-items: baseline; gap: 13px; flex-wrap: wrap; margin-bottom: 20px; }
.intro-badge { padding: 7px 11px; background: #fff0cf; color: #ba7a1e; border-radius: 10px; font-size: 11px; font-weight: 800; }
.play-intro h2 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.03em; }
.play-intro p { margin: 1px 0 0; color: var(--muted); font-size: 13px; }

.food-tray { display: flex; flex-wrap: wrap; gap: 11px; align-items: stretch; padding: 14px; margin-bottom: 26px; border-radius: 22px; background: #fbf7ee; border: 1px dashed #ded8c9; min-height: 102px; }
.food-tray:empty::after { content: 'كل الأطعمة في أماكنها!'; width: 100%; text-align: center; align-self: center; color: #92a899; font-size: 14px; font-weight: 700; }
.food-card { appearance: none; border: 1px solid rgba(255,255,255,.92); background: white; min-width: 93px; flex: 1 0 93px; max-width: 126px; min-height: 91px; padding: 8px 7px 7px; border-radius: 16px; box-shadow: 0 5px 12px rgba(70, 86, 80, .08); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; transition: transform .18s ease, box-shadow .18s ease, border-color .18s; user-select: none; touch-action: manipulation; }
.food-card:hover, .food-card.selected { transform: translateY(-5px) rotate(-1deg); border-color: #6fc4e8; box-shadow: 0 11px 20px rgba(72, 164, 203, .2); }
.food-card.selected { outline: 3px solid rgba(103, 201, 236, .25); }
.food-card.dragging { opacity: .5; transform: scale(.94); }
.food-card.correct { animation: placed .5s ease both; }
.food-emoji { font-size: 38px; line-height: 1; filter: drop-shadow(0 4px 2px rgba(38,74,93,.1)); }
.food-name { font-size: 12px; font-weight: 800; }
.food-type-hint { color: #9aabb1; font-size: 10px; font-weight: 600; }

.fridge-scene { display: grid; grid-template-columns: minmax(86px, 1fr) minmax(210px, 290px) minmax(86px, 1.15fr); align-items: center; gap: clamp(12px, 3vw, 26px); min-height: 295px; }
.fridge-shell { position: relative; height: 290px; border-radius: 27px 27px 19px 19px; background: linear-gradient(90deg, #acdced, #e6f7fc 22%, #d5f0f8 80%, #94cfe5); box-shadow: inset -8px 0 0 rgba(101, 169, 195, .2), 0 14px 25px rgba(64, 130, 153, .18); border: 4px solid #80c0d9; overflow: hidden; }
.fridge-top { height: 197px; position: relative; padding: 17px 14px 11px; background: linear-gradient(180deg, rgba(251,254,255,.94), rgba(218,245,250,.7)); border-bottom: 7px solid #83c3da; }
.fridge-bottom { height: 84px; padding: 14px; background: linear-gradient(180deg, #c9edf5, #b4e0ed); }
.fridge-handle { position: absolute; z-index: 3; left: -9px; top: 82px; width: 12px; height: 65px; border-radius: 12px; background: #5ca9c7; box-shadow: 2px 0 #e7fbff; }
.fridge-light { position: absolute; top: 12px; right: 17px; width: 9px; height: 9px; border-radius: 50%; background: #ff796d; box-shadow: 0 0 0 4px rgba(255,121,109,.16); }
.fridge-shelf { height: 48px; border-bottom: 5px solid rgba(113, 177, 196, .35); display: flex; align-items: end; justify-content: space-around; padding: 0 18px 5px; }
.fridge-shelf i { display: block; width: 19px; height: 23px; border-radius: 8px 8px 3px 3px; background: #f7ca83; opacity: .82; }
.fridge-shelf i:nth-child(2) { height: 16px; background: #ef9c94; }
.fridge-shelf i:nth-child(3) { height: 27px; background: #9bd3a4; }
.freezer-door { position: absolute; bottom: -69px; right: 13px; display: flex; align-items: center; gap: 7px; color: #488da8; background: #a9ddea; border: 2px solid rgba(97,166,192,.4); border-radius: 12px 12px 0 0; padding: 7px 12px; transform: rotate(-1deg); }
.freezer-door span { font-size: 20px; }
.freezer-door small { font-size: 10px; font-weight: 800; }
.drawer-line { height: 11px; width: 80%; margin: 4px auto 17px; border-radius: 10px; background: rgba(102, 170, 192, .33); }
.drawer-line-low { width: 65%; margin-bottom: 0; background: rgba(102, 170, 192, .2); }
.fridge-side-note { align-self: start; margin-top: 8px; color: #75a1b2; font-size: 13px; line-height: 1.4; font-weight: 800; text-align: center; }
.fridge-side-note span { color: #a9b7b9; font-size: 10px; font-weight: 600; }

.drop-zones { display: flex; flex-direction: column; gap: 14px; }
.drop-zone { position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto 1fr; align-items: center; gap: 1px 11px; width: 100%; min-height: 126px; padding: 14px 15px; border: 2px dashed transparent; border-radius: 21px; text-align: right; transition: transform .2s, box-shadow .2s, border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.active { transform: translateX(-4px); box-shadow: var(--soft-shadow); }
.drop-zone.active { border-color: currentColor; }
.freezer-zone { background: #e8f7ff; color: #3c90b8; border-color: #b9e5f6; }
.cooler-zone { background: #effbea; color: #4a9e70; border-color: #c7e9ce; }
.zone-icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: rgba(255,255,255,.72); font-size: 23px; }
.zone-title { font-size: 15px; font-weight: 900; }
.zone-help { font-size: 10px; color: #86a0a7; font-weight: 600; }
.zone-items { grid-column: 1 / -1; display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; min-height: 27px; }
.zone-items .mini-food { font-size: 20px; padding: 2px 4px; animation: popIn .35s ease both; }
.selection-hint { min-height: 22px; margin: 15px 0 0; text-align: center; color: #86a0aa; font-size: 12px; font-weight: 700; }

.last-result { margin-top: 20px; padding: 12px 18px; border-radius: 17px; background: rgba(255,255,255,.66); color: #80919a; text-align: center; font-size: 12px; }
.last-result strong { color: var(--ink); }
.hidden { display: none !important; }

.feedback { position: fixed; z-index: 30; top: 24px; left: 50%; transform: translate(-50%, -130px); width: min(90vw, 370px); padding: 14px 20px; border-radius: 17px; text-align: center; color: white; font-size: 14px; font-weight: 900; box-shadow: 0 15px 35px rgba(39,74,91,.22); pointer-events: none; opacity: 0; transition: transform .35s, opacity .35s; }
.feedback.show { transform: translate(-50%, 0); opacity: 1; }
.feedback.good { background: linear-gradient(100deg, #45b87c, #66cda0); }
.feedback.bad { background: linear-gradient(100deg, #eb7d6c, #f4a071); }

.modal-layer { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(36, 68, 84, .3); backdrop-filter: blur(8px); animation: fadeIn .25s ease; }
.welcome-modal, .finish-modal { width: min(100%, 500px); padding: 42px 38px 36px; border-radius: 30px; text-align: center; background: #fffdf8; box-shadow: 0 24px 70px rgba(31, 63, 76, .24); }
.welcome-illustration { position: relative; width: 122px; height: 105px; margin: 0 auto 5px; }
.welcome-fridge { display: block; font-size: 83px; line-height: 1; transform: rotate(-7deg); filter: drop-shadow(7px 10px 0 rgba(86,185,232,.2)); }
.welcome-spark { position: absolute; color: #f5b535; font-size: 27px; animation: twinkle 1.7s infinite alternate ease-in-out; }
.spark-a { top: 5px; right: 7px; }
.spark-b { left: 4px; bottom: 6px; animation-delay: .5s; }
.welcome-modal h2, .finish-modal h2 { margin: 9px 0 10px; font-size: 28px; letter-spacing: -.04em; }
.welcome-modal > p:not(.eyebrow), .final-message { margin: 0 auto 24px; max-width: 340px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.primary-button, .secondary-button { border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 900; transition: transform .2s, box-shadow .2s; }
.primary-button { color: white; background: var(--navy); box-shadow: 0 7px 0 #102e43; }
.primary-button:hover { transform: translateY(-3px); box-shadow: 0 10px 0 #102e43; }
.primary-button:active { transform: translateY(2px); box-shadow: 0 3px 0 #102e43; }
.primary-button span { display: inline-block; margin-right: 9px; font-size: 17px; }
.secondary-button { margin-top: 13px; color: #5e7b87; background: #edf6f3; }
.secondary-button:hover { background: #e1f1ec; transform: translateY(-2px); }
.trophy { font-size: 62px; animation: bob 2s ease-in-out infinite; }
.final-score { display: inline-flex; align-items: baseline; gap: 5px; padding: 7px 17px; margin: 3px 0 14px; border-radius: 15px; color: #a87313; background: #fff2c7; }
.final-score span { font-size: 32px; font-weight: 900; }
.final-score small { font-size: 11px; font-weight: 800; }
.save-form { margin: 15px auto 0; max-width: 380px; padding: 16px; border-radius: 18px; background: #f7faf6; text-align: right; }
.save-form label { display: block; margin-bottom: 8px; color: #69808a; font-size: 12px; font-weight: 800; }
.name-row { display: flex; gap: 8px; }
.name-row input { min-width: 0; flex: 1; border: 1px solid #dce7e5; border-radius: 12px; padding: 10px 12px; color: var(--ink); background: #fff; outline: 0; }
.name-row input:focus { border-color: #75c5b0; box-shadow: 0 0 0 3px rgba(117,197,176,.18); }
.name-row .primary-button { padding-inline: 14px; font-size: 12px; white-space: nowrap; }
.saved-notice { margin-top: 13px; color: #3d9a6d; font-size: 13px; font-weight: 800; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes twinkle { from { transform: scale(.8) rotate(-12deg); opacity: .4; } to { transform: scale(1.12) rotate(12deg); opacity: 1; } }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes placed { 35% { transform: scale(1.16) rotate(3deg); } 100% { transform: scale(.8); opacity: .6; } }
@keyframes popIn { from { transform: scale(.2) rotate(-15deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake .38s ease; }

@media (max-width: 860px) {
  .hero-panel { align-items: flex-start; flex-wrap: wrap; }
  .hero-copy { max-width: 480px; }
  .how-to { margin-right: auto; }
  .fridge-scene { grid-template-columns: 1fr; gap: 16px; }
  .fridge-side-note { display: none; }
  .fridge-shell { width: min(290px, 80vw); margin: 0 auto; order: 2; }
  .drop-zones { order: 1; flex-direction: row; }
  .drop-zone { min-height: 114px; }
}

@media (max-width: 590px) {
  .app-shell { padding: 21px 10px 35px; }
  .hero-panel { padding-inline: 7px; }
  .brand-mark { width: 49px; height: 49px; border-radius: 16px 16px 20px 7px; }
  .brand-mark span:first-child { font-size: 25px; }
  .brand-mark span:last-child { font-size: 14px; left: 8px; bottom: 6px; }
  h1 { font-size: 30px; }
  .hero-copy { width: 100%; font-size: 13px; }
  .how-to { width: 100%; justify-content: space-between; gap: 4px; padding: 9px 8px; font-size: 10px; }
  .how-to-arrow { font-size: 9px; }
  .game-card { border-radius: 24px; }
  .game-topbar { gap: 9px; padding: 15px; }
  .progress-wrap { min-width: 0; }
  .score-pill { min-width: 72px; padding-inline: 9px; gap: 4px; }
  .score-pill small { display: none; }
  .icon-button { width: 37px; height: 37px; }
  .game-area { padding: 22px 13px 27px; }
  .play-intro { display: block; margin-bottom: 15px; }
  .intro-badge { display: inline-block; margin-bottom: 8px; }
  .play-intro h2 { font-size: 23px; }
  .play-intro p { line-height: 1.7; }
  .food-tray { gap: 7px; padding: 9px; }
  .food-card { min-width: 74px; flex-basis: 74px; min-height: 77px; border-radius: 13px; }
  .food-emoji { font-size: 29px; }
  .food-name { font-size: 10px; }
  .food-type-hint { display: none; }
  .drop-zones { gap: 8px; }
  .drop-zone { grid-template-columns: 29px 1fr; gap: 1px 6px; padding: 10px 8px; border-radius: 16px; min-height: 103px; }
  .zone-icon { width: 29px; height: 29px; font-size: 17px; border-radius: 10px; }
  .zone-title { font-size: 11px; }
  .zone-help { font-size: 8px; line-height: 1.2; }
  .zone-items .mini-food { font-size: 16px; }
  .welcome-modal, .finish-modal { padding: 33px 20px 27px; border-radius: 24px; }
  .welcome-modal h2, .finish-modal h2 { font-size: 24px; }
  .name-row { flex-direction: column; }
  .name-row .primary-button { width: 100%; }
}

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