/* ================= GLOBAL ================= */
body {
  background:#aecc6e;
  color:white;
  font-family: monospace;
  margin:0;
}

a {
  text-decoration: none;
  color: inherit;
}

/* APP CENTERING ONLY */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Move paragraph slightly up inside the card */
.card .para-wrapper {
  margin-top: 30px; 
  transform: translateY(-30px);
}

/* ================= PARAGRAPH ================= */
#para {
  font-size:27px;
  line-height:49px;
  user-select:none;
  margin-top:38px;
  text-align:center;
  max-width:825px;
}

#para span { color:#000000; }
#para span.correct { color:white; }
#para span.wrong,
#para span.extra { color:#ff6b6b; }
#para span.skipped {
  text-decoration: underline 2px red;
}

/* Cursor */
#para span.current {
  border-left:2px solid white;
  animation: blink 1s step-start infinite;
}
@keyframes blink {
  50% { border-color: transparent; }
}

/* ================= TIMER ================= */
#timerBox {
  font-size:24px;
  margin-top:10px;
}

/* ================= MODAL ================= */
#levelModal {
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.55);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  opacity:0;
  pointer-events:none;
  transition:opacity .3s ease;
}

#levelModal:not(.hidden) {
  opacity:1;
  pointer-events:auto;
}

#levelModal .modal-box {
  background:#1e1e2f;
  padding:30px 40px;
  border-radius:16px;
  text-align:center;
  font-size: 19px;
  width:90%;
  max-width:450px;
  box-shadow:0 15px 45px rgba(0,0,0,.7);
  transform:scale(.85);
  animation:popupIn .35s forwards;
}

@keyframes popupIn {
  to { transform:scale(1); }
}

#levelModal.success h2::after {
  content:"✔";
  margin-left:10px;
  color:#4caf50;
  animation:checkAppear .5s .3s forwards;
  opacity:0;
}

@keyframes checkAppear {
  from { transform:scale(.3) rotate(-45deg); opacity:0; }
  to   { transform:scale(1) rotate(0); opacity:1; }
}

#levelModal.error {
  animation: shake .5s;
}

@keyframes shake {
  25% { transform:translateX(-10px); }
  50% { transform:translateX(10px); }
  75% { transform:translateX(-10px); }
}

.modal-actions {
  display:flex;
  justify-content:center;
  gap:67px;
}

#retryBtn {
  background:#ff4d4f;
  color:white;
}

#nextBtn {
  background:#4caf50;
  color:white;
}

#levelModal button {
  border:none;
  padding:10px 20px;
  border-radius:8px;
  font-weight:600;
  cursor:pointer;
  transition:transform .2s;
}
#levelModal button:hover { transform:translateY(-2px); }

/* ================= LEVEL CARD DECK ================= */
#levelDeck {
  position:relative;
  width: 900px;
  height: 350px;
  perspective:1400px;
}

/* ================= CARD BASE ================= */
#levelDeck .card {
  position:absolute;
  inset:0;
  background:#a2b145;
  border-radius:14px;
  padding:9px;
  box-shadow:0 25px 50px rgba(0,0,0,.45);
  transition:transform .7s cubic-bezier(.25,.8,.25,1),
             opacity .6s ease;
  transform-style:preserve-3d;
}

/* ================= CARD STATES ================= */
.active-card {
  z-index:3;
  transform:translateY(0) scale(1);
  opacity:1;
}

.next-card {
  z-index:2;
  transform:translateY(26px) scale(.94);
  opacity:.7;
}

.buffer-card {
  z-index:1;
  transform:translateY(50px) scale(.88);
  opacity:0;
}

/* ================= EXIT ================= */
.slide-out {
  transform:translateX(-120%) rotateY(25deg) scale(.9);
  opacity:0;
}

/* PARA WRAPPER SCROLLABLE */
.para-wrapper {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 12px;
  margin-top: 20px;
  scroll-behavior: smooth;
}

.para-wrapper::-webkit-scrollbar {
  width: 6px;
}
.para-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 6px;
}

.para-wrapper {
  mask-image: linear-gradient(
    to bottom,
    transparent,
    black 12%,
    black 88%,
    transparent
  );
}

/* ******** Completed Panels ******** */
#completedPanel {
  position: relative;
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(345deg, #000000, #737f39);
  border-radius: 14px;
  font-family: Arial, sans-serif;
  box-shadow: 
    0 8px 25px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 1000;
}

#completedPanel:hover {
  transform: scale(1.05);
}

#completedHeader {
  cursor: pointer;
  padding: 12px;
  font-weight: bold;
  background: rgba(255,255,255,0.04);
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#completedBody {
  display: block;
  max-height: 0;
  overflow-y: auto;
  padding: 0 10px;
  transition: max-height 0.3s ease;
}

#completedPanel.open #completedBody {
  max-height: 155px;
  padding: 10px;
}

#completedList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#completedList li {
  padding: 7px 0;
  border-bottom: 1px solid #333;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  color: #ddd;
}

#completedList li:last-child {
  border-bottom: none;
}

#completedBody .empty {
  opacity: 0.6;
  font-size: 13px;
}

#completedPanel.open #completedBody {
  scrollbar-width: auto;
}

#resetProgressBtn {
  position: absolute;
  font-family: Arial, sans-serif;
  font-weight: bold;
  width: 140px;
  right: 260px;
  top: 175px;
  height: 48px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(345deg, #000000, #737f39);
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}

#resetProgressBtn:hover {
  background: #758e2c;
  transform: scale(1.05);
}

#streakBox {
  position: absolute;
  width: 149px;
  left: 306px;
  top: 175px;
  height: 20px;
  padding: 14px 8px;
  background: linear-gradient(345deg, #000000, #737f39);
  color: #fff;
  border-radius: 8px;
  font-family: Arial, sans-serif;
  cursor: default;
  user-select: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

#streakBox:hover {
  background: #758e2c;
  color: #111;
  transform: scale(1.05);
}

/* -------- Confetti Burst --------- */
.josh-confetti {
  position: fixed;
  width: 6px;
  height: 14px;
  pointer-events: none;
  opacity: 1;
  z-index: 9999;
  animation: joshFly 1.4s cubic-bezier(.1,.8,.3,1) forwards;
}

@keyframes joshFly {
  0% {
    transform: translate(0,0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform:
      translate(var(--x), var(--y))
      rotate(1080deg)
      scale(0.8);
    opacity: 0;
  }
}

/* ===== Card Animations ===== */
.card.anim-fade-zoom { animation: fadeZoom 0.5s ease; }
@keyframes fadeZoom {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.card.anim-slide-up { animation: slideUp 0.45s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(25px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card.anim-flip { animation: flipIn 0.6s ease; }
@keyframes flipIn {
  from { opacity: 0; transform: rotateX(90deg); }
  to   { opacity: 1; transform: rotateX(0); }
}

.card.anim-pop { animation: popIn 0.4s cubic-bezier(.25,.8,.25,1); }
@keyframes popIn {
  0%   { transform: scale(0.6); }
  80%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.card.anim-shake { animation: shakeIn 0.55s ease; }
@keyframes shakeIn {
  0%   { transform: translateX(-10px); }
  25%  { transform: translateX(10px); }
  50%  { transform: translateX(-6px); }
  75%  { transform: translateX(6px); }
  100% { transform: translateX(0); }
}

/* ===== Milestone Banner ===== */
#milestoneBanner {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
  color: #fff;
  padding: 14px 26px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  opacity: 0;
  z-index: 9999;
  pointer-events: none;
}

#milestoneBanner.show {
  animation: bannerFlyUp 4s ease forwards;
}

@keyframes bannerFlyUp {
  0%   { transform: translate(-50%, 120px); opacity: 0; }
  15%  { transform: translate(-50%, 0); opacity: 1; }
  70%  { transform: translate(-50%, -40vh); opacity: 1; }
  100% { transform: translate(-50%, -50vh); opacity: 0; }
}

.icon-btn {
  background: #1f1f1f;
  border: 1px solid #333;
  color: #fff;
  border-radius: 35px;
  cursor: pointer;
  font-size: 26px;
  transition: 
    transform 0.3s ease,
    box-shadow 0.3s ease,
    background 0.3s ease;
}

.refresh-btn { position: relative; }

.refresh-btn:hover {
  transform: translateY(-3px) rotate(180deg);
  box-shadow: 0 6px 18px rgba(9, 76, 109, 0.598);
}

.refresh-btn:active {
  transform: translateY(0) rotate(180deg) scale(0.95);
  box-shadow: 0 3px 8px rgba(9, 76, 109, 0.598);
}

.refresh-btn i { display: inline-block; transition: transform 0.4s ease; }
.refresh-btn:hover i { transform: rotate(360deg); }

/* ===== Level Info Icon & Banner ===== */
#levelInfoIcon {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 25px;
  cursor: pointer;
  opacity: 0.6;
  transition: transform 0.2s, opacity 0.2s;
  z-index: 5;
}
#levelInfoIcon:hover { opacity: 1; transform: scale(1.15); }

#levelInfoBanner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  z-index: 9999;
  font-size: 20px;
}

#levelInfoBanner.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-content {
  background: #111;
  color: #fff;
  padding: 18px 29px 28px;
  border-radius: 27px;
  width: 462px;
  animation: fadeUp 0.4s ease;
}

.info-content ul { padding-left: 0; list-style: none; }

.info-content li { margin: 8px 0; font-size: 18px; }

.info-hint {
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
}

@keyframes fadeUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ===== Live Stats ===== */
.live-stats {
  position: absolute;
  top: 2px;
  left: 47%;
  transform: translateX(-50%);
  width: 67%;
  height: 53px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid #000000;
  border-radius: 14px;
  font-size: 14px;
  z-index: 5;
}

.live-stats div { text-align: center; }
.live-stats span { display: block; font-size: 18px; font-weight: 600; }
.live-stats small { opacity: 0.7; font-size: 15px; }

.hidden { display: none; }

.live-toggle {
  position: absolute;
  top: 14px;
  right: 50px;
  background: none;
  border: none;
  color: #ddd;
  cursor: pointer;
  font-size: 14px;
}

.live-toggle.active { color: #00ffcc; }

/* ===== Future Slot Block ===== */
.future-slot {
  margin-top: 60px;
  width: 90%;
  max-width: 880px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(0,0,0,0.75);
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: #111;
  font-size: 26px;
  font-family: monospace;
  letter-spacing: 2px;
  box-shadow:
    0 10px 30px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* ================= MOBILE LAYOUT ================= */
@media (max-width: 768px) {
  #streakBox,
  #resetProgressBtn,
  #completedPanel {
    position: static !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
  }

  #sideProgress button,
  #streakBox {
    height: 40px;
    padding: 0 14px;
    min-width: 150px;
    font-size: 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .progress-row { gap: 10px; }

  #mainLayout {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  #sideProgress {
    order: -1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  #streakBox,
  #resetProgressBtn {
    flex: 1;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    border-radius: 8px;
  }

  #completedPanel {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
  }

  #completedHeader {
    width: 100%;
    padding: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #completedBody { width: 100%; text-align: left; }

  #levelDeck { width: 100%; max-width: 420px; }
  .future-slot { width: 100%; max-width: 420px; }

  #completedList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    column-gap: 16px;
    row-gap: 10px;
    padding: 0;
    margin: 0;
  }

  #completedList li {
    list-style: none;
    font-size: 14px;
    padding: 6px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  #completedPanel.open #completedBody { max-height: 200px; }

  .live-stats { width: 56%; margin: 0 auto; left: 47%; }
  .live-toggle { right: 20px; }

  body { overflow-x: hidden; }

  #mainLayout,
  .content-section,
  .info-section,
  .completed-levels-section {
    max-width: 100%;
    overflow-x: hidden;
  }
}

@media (min-width: 769px) {
  #sideProgress {
    position: absolute;
    top: 95px;
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  #streakBox { position: static; min-width: 180px; }

  .progress-row { display: flex; gap: 15px; align-items: center; }

  #resetProgressBtn { position: static; min-width: 160px; }

  #completedPanel { position: static; width: 220px; }

  #streakBox,
  #resetProgressBtn,
  #completedPanel { flex-shrink: 0; }
}
