@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
body {
  background: #fffdf7;
  font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 24px 16px;
}

.container {
  width: 100%;
  max-width: 480px;
  position: relative;
}

/* ── Screens ───────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ── Start Screen ──────────────────────────────────────────────────────── */
.start-logo {
  font-size: 80px;
  margin-top: 16px;
  animation: float 3s ease-in-out infinite;
}

.game-title {
  font-size: 40px;
  font-weight: 900;
  color: #e94560;
  letter-spacing: -1px;
}

.game-subtitle {
  font-size: 16px;
  color: #b5546a;
  text-align: center;
  max-width: 320px;
}

/* ── How to Play ───────────────────────────────────────────────────────── */
.how-to {
  width: 100%;
  background: #fff0f3;
  border: 2px solid #ffd6e0;
  border-radius: 16px;
  padding: 18px 20px;
}

.how-to h3 {
  font-size: 17px;
  font-weight: 900;
  color: #e94560;
  margin-bottom: 10px;
  text-align: center;
}

.how-to ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.how-to li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: #6b5560;
}

.how-to li span {
  flex-shrink: 0;
  font-size: 16px;
}

.how-to li b {
  color: #e94560;
}

.link-back {
  font-size: 14px;
  font-weight: 700;
  color: #a18cd1;
  text-decoration: none;
  padding: 4px;
}

.link-back:hover {
  color: #e94560;
}

/* ── Section Title ─────────────────────────────────────────────────────── */
.section-title {
  font-size: 24px;
  font-weight: 900;
  color: #e94560;
}

/* ── Game Header ───────────────────────────────────────────────────────── */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.game-title-small {
  font-size: 17px;
  font-weight: 900;
  color: #e94560;
}

.scores {
  display: flex;
  gap: 8px;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #e94560, #ff8a5c);
  border-radius: 8px;
  padding: 6px 14px;
  min-width: 60px;
}

.score-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  line-height: 1.2;
}

/* ── Game Meta Row ─────────────────────────────────────────────────────── */
.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: #6b5560;
}

.hearts {
  font-size: 14px;
  letter-spacing: -1px;
  white-space: nowrap;
}

.hearts.hearts--lost {
  animation: heart-lost 0.4s ease;
}

#hud-progress { color: #a18cd1; white-space: nowrap; }
#hud-combo    { color: #ff8a5c; white-space: nowrap; animation: combo-flame 0.9s ease-in-out infinite; }

/* ── Customers ─────────────────────────────────────────────────────────── */
.customers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-height: 168px;
}

.customer {
  background: #fff;
  border: 2px solid #ffd6e0;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: customer-in 0.35s ease;
}

.customer.customer--done  { animation: order-complete-pop 0.4s ease forwards; }
.customer.customer--fail  { animation: wrong-shake 0.4s ease; border-color: #dc2626; }

.customer-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.customer-face {
  font-size: 30px;
  line-height: 1;
  flex-shrink: 0;
}

.customer-dish {
  font-size: 16px;
  font-weight: 900;
  color: #e94560;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ── Patience Bar ──────────────────────────────────────────────────────── */
.patience {
  width: 100%;
  height: 9px;
  background: #fff0f3;
  border-radius: 6px;
  overflow: hidden;
}

.patience-fill {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #6bcb77, #ffd93d);
  transition: background 0.3s;
}

.patience-fill.patience--low {
  background: linear-gradient(90deg, #ff8a5c, #e94560);
}

/* ── Order Parts (the ingredient list) ─────────────────────────────────── */
.parts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.part {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 62px;
  padding: 6px 2px;
  background: #fff0f3;
  border: 2px solid #ffd6e0;
  border-radius: 11px;
}

.part-emoji {
  font-size: 25px;
  line-height: 1.1;
}

.part-name {
  font-size: 11px;
  font-weight: 700;
  color: #6b5560;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
}

.part-check {
  position: absolute;
  top: -7px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6bcb77;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  display: none;
  align-items: center;
  justify-content: center;
}

.part.part--done {
  background: #e8f8ea;
  border-color: #6bcb77;
  opacity: 0.6;
}

.part.part--done .part-check {
  display: flex;
  animation: correct-pop 0.35s ease;
}

/* ── Conveyor Belt ─────────────────────────────────────────────────────── */
.belt-label {
  width: 100%;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #a18cd1;
  text-transform: uppercase;
}

.belt {
  position: relative;
  width: 100%;
  height: 92px;
  background: repeating-linear-gradient(
    90deg,
    #f3e9f7 0 18px,
    #ece0f2 18px 36px
  );
  border: 2px solid #e4d4ee;
  border-radius: 14px;
  overflow: hidden;
}

.belt-tile {
  position: absolute;
  top: 8px;
  left: 0;
  width: 72px;
  height: 72px;
  min-height: 0;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: #fff;
  border: 2px solid #ffd6e0;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  font-family: inherit;
  cursor: pointer;
  will-change: transform;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

/* Never animate `transform` on a belt tile — it is used for belt movement. */
.belt-tile:hover {
  background: #fff0f3;
  border-color: #e94560;
  box-shadow: 0 4px 14px rgba(233, 69, 96, 0.25);
}

.belt-tile.tile--hit {
  background: #d6f5db;
  border-color: #6bcb77;
  box-shadow: 0 0 16px rgba(107, 203, 119, 0.8);
}

.belt-tile.tile--miss {
  background: #ffe0e0;
  border-color: #dc2626;
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.6);
}

.tile-emoji {
  font-size: 30px;
  line-height: 1.05;
  pointer-events: none;
}

.tile-name {
  font-size: 11px;
  font-weight: 700;
  color: #6b5560;
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: rgba(43, 24, 32, 0.9);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  padding: 9px 18px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  animation: toast-rise 0.9s ease forwards;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
button {
  background: linear-gradient(135deg, #e94560, #ff8a5c);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  width: 100%;
  min-height: 48px;
}

button:hover  { filter: brightness(1.07); transform: translateY(-1px); }
button:active { transform: translateY(0); }

.btn-leave {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 14px 24px;
  background: #fff0f3;
  color: #e94560;
  border: 2px solid #ffd6e0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-leave:hover { background: #ffe0e8; }

/* ── Overlays ──────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 24, 32, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 24px;
}

.overlay-box {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.result-emoji { font-size: 56px; }

.overlay-box h2 {
  font-size: 24px;
  font-weight: 900;
  color: #e94560;
  text-align: center;
}

.overlay-box p {
  font-size: 15px;
  font-weight: 700;
  color: #6b5560;
  text-align: center;
}

#lc-earned { color: #6bcb77; font-size: 20px; font-weight: 900; }

.overlay-box button { margin-top: 6px; }

/* ── Level Card ────────────────────────────────────────────────────────── */
.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: level-card-pop 0.5s ease;
}

.level-word {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 10px;
  color: #ffd6e0;
  text-indent: 10px;
}

.level-num {
  font-size: 130px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 6px 30px rgba(233, 69, 96, 0.7);
}

/* ── Game Over Screen ──────────────────────────────────────────────────── */
.gameover-icon {
  font-size: 72px;
  margin-top: 24px;
}

#gameover-score {
  font-size: 22px;
  font-weight: 900;
  color: #e94560;
}

#gameover-level {
  font-size: 15px;
  font-weight: 700;
  color: #6b5560;
  margin-bottom: 6px;
}

/* ── Keyframe Animations ───────────────────────────────────────────────── */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@keyframes level-card-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes customer-in {
  0%   { transform: translateY(-12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes order-complete-pop {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}

@keyframes correct-pop {
  0%   { transform: scale(0.3); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  60%      { transform: translateX(7px); }
}

@keyframes heart-lost {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(1.25); }
}

@keyframes combo-flame {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

@keyframes toast-rise {
  0%   { opacity: 0; transform: translate(-50%, 14px); }
  25%  { opacity: 1; transform: translate(-50%, 0); }
  75%  { opacity: 1; transform: translate(-50%, -6px); }
  100% { opacity: 0; transform: translate(-50%, -22px); }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
  body { padding: 12px 10px; }
  .game-title { font-size: 30px; }
  .start-logo { font-size: 60px; }
  .game-title-small { font-size: 14px; }
  .score-value { font-size: 16px; }
  .score-box { padding: 5px 10px; min-width: 50px; }
  .game-meta { font-size: 13px; }
  .hearts { font-size: 12px; }
  .part { width: 56px; }
  .part-emoji { font-size: 22px; }
  .part-name { font-size: 10px; }
  .level-num { font-size: 100px; }
  .level-word { font-size: 26px; letter-spacing: 7px; text-indent: 7px; }
}
