@media (min-width: 768px) {
  .blog-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100vw;
  }
  .flashcard-carousel {
    margin-left: 1.3rem !important;
    margin-right: auto !important;
    left: 0;
    right: 0;
    position: relative;
    max-width: 420px;
  }
  .flashcard-controls {
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: center;
  }
  .flashcard-indicators {
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: center;
  }
}
/* Flashcard link button */
.flashcard-link {
  display: inline-block;
  margin-top: 1.1rem;
  padding: 0.55rem 1.2rem;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(167,139,250,.10);
  transition: background 0.18s, color 0.18s, transform 0.18s;
  border: none;
  cursor: pointer;
}
.flashcard-link:hover {
  background: linear-gradient(90deg, #8b5cf6, var(--accent));
  color: #232b4a;
  transform: scale(1.04);
}
@media (max-width:520px){
  .flashcard-carousel {
    max-width: 98vw;
    min-width: 0;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }
  .flashcard {
    max-width: 98vw;
    width: 100%;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    min-width: 0;
    box-sizing: border-box;
  }
}
/* Switch/Slider for AM/PM 24H toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  margin: 0 6px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #64748b;
  transition: .4s;
  border-radius: 22px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 2px; bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
/* Center footer and flashcard carousel */
footer {
  text-align: center;
  margin: 2.5rem auto 1.2rem auto;
  width: 100%;
  color: var(--muted);
}
.blog-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flashcard-carousel {
  margin-left: auto;
  margin-right: auto;
}
/* Flashcard Carousel Styles */
.flashcard-carousel {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 1.5rem auto 0;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flashcard {
  width: 100%;
  min-height: 220px;
  background: linear-gradient(120deg, #232b4a 80%, #a78bfa 100%);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(80,80,120,0.18);
  color: #fff;
  font-size: 1.08rem;
  padding: 2rem 1.2rem;
  display: block;
  position: absolute;
  left: 0; right: 0; margin: auto;
  top: 0;
  transition: transform 0.45s cubic-bezier(.23,1.12,.32,1), opacity 0.3s;
  will-change: transform, opacity;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  backface-visibility: hidden;
}
.flashcard h3 {
  color: #a78bfa;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}
.flashcard.flipped {
  transform: rotateY(180deg);
  background: linear-gradient(120deg, #a78bfa 80%, #232b4a 100%);
  color: #232b4a;
}
.flashcard.swipe-left {
  animation: flashcard-swipe-left 0.3s forwards;
}
.flashcard.swipe-right {
  animation: flashcard-swipe-right 0.3s forwards;
}
@keyframes flashcard-swipe-left {
  to { transform: translateX(-120%) rotate(-18deg); opacity: 0; }
}
@keyframes flashcard-swipe-right {
  to { transform: translateX(120%) rotate(18deg); opacity: 0; }
}
.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: .7rem;
  margin-top: 1.2rem;
}
.flashcard-indicators {
  display: flex;
  justify-content: center;
  gap: .3rem;
  margin-top: .7rem;
}
.flashcard-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a78bfa44;
  display: inline-block;
  transition: background 0.2s;
}
.flashcard-dot.active {
  background: #a78bfa;
}
/* Carousel Modal Modernization */
.carousel-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(10,16,30,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}
.carousel-modal .carousel {
  position: relative;
  width: 340px;
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: linear-gradient(135deg, #181f3a 60%, #232b4a 100%);
  border-radius: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  padding: 0;
}
.carousel-modal .card {
  position: absolute;
  left: 0; right: 0; margin: auto;
  width: 300px;
  height: 380px;
  background: linear-gradient(120deg, #232b4a 80%, #a78bfa 100%);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(80,80,120,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  padding: 2rem 1.2rem;
  transition: transform 0.45s cubic-bezier(.23,1.12,.32,1), opacity 0.3s;
  will-change: transform, opacity;
  cursor: grab;
  user-select: none;
}
.carousel-modal .card h3 {
  color: #a78bfa;
  margin-bottom: 1rem;
}
.carousel-modal .card.swiping {
  transition: none;
  cursor: grabbing;
  opacity: 0.7;
}
.carousel-modal .close-modal {
  position: absolute;
  top: 18px;
  right: 24px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}
.carousel-modal .close-modal:hover {
  background: rgba(255,255,255,0.18);
}
:root {
  --bg: #0a0f1a;
  --muted: #94a3b8;
  --accent: #a78bfa;
}

/* base */
html, body {
  height: 100%;
  margin: 0;
  font-family: 'Poppins', system-ui, Segoe UI, Roboto, Helvetica, Arial;
  color: #f1f5f9;
}

body:not(.daymode) {
  background: var(--bg);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* top bar */
.top-bar {
  max-width: 1000px;
  margin: 1rem auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 1rem;
}
.datetime {
  background: rgba(15, 23, 42, 0.45);
  padding: .35rem .75rem;
  border-radius: 999px;
  font-size: .95rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
}
.time-format-toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 600;
  color: #f8fafc;
}
body.daymode .time-format-toggle {
  color: #1e293b;
}

/* container */
main.container {
  max-width: 420px;
  margin: 10rem auto;
  padding: 2rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  box-shadow: 0 12px 35px rgba(2,6,23,.6);
  backdrop-filter: blur(8px);
}
header h1 {
  margin: .25rem 0 .4rem;
  font-size: 1.25rem;
  color: var(--accent);
}
header p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .95rem;
}

/* mode */
.mode-toggle {
  display: flex;
  gap: .6rem;
  justify-content: center;
  margin-bottom: .8rem;
}
.mode-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: .6rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: all .18s;
}
.mode-toggle button.active {
  background: linear-gradient(90deg,var(--accent),#8b5cf6);
  color: #0b0720;
  transform: scale(1.03);
}

/* time section */
.time-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1rem;
}
.time-wrapper {
  display: flex;
  align-items: center;
  gap: .8rem;
}
input[type="time"] {
  appearance: none;
  background: #111827;
  color: #f8fafc;
  padding: .72rem 1rem;
  border-radius: 12px;
  border: 2px solid #24303a;
  font-size: 1.02rem;
  text-align: center;
  width: 150px;
}
select#ampmSelect {
  appearance: none;
  padding: .7rem 1.1rem;
  border-radius: 12px;
  border: 2px solid #24303a;
  background: #111827;
  color: #f8fafc;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='%23f8fafc'><path d='M7 10l5 5 5-5z'/></svg>");
  background-position: right .6rem center;
  background-repeat: no-repeat;
}

/* calculate & results */
#calculateBtn {
  width: 100%;
  padding: .85rem;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg,var(--accent),#8b5cf6);
  color: #0b0720;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(167,139,250,.12);
}
.results {
  margin-top: 1rem;
  background: rgba(255,255,255,0.02);
  padding: 1rem;
  border-radius: 12px;
  color: #e6eef8;
  line-height: 1.45;
}

/* nav */
nav.small-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 1rem auto 0;
  max-width: 420px;
  overflow: hidden;
  box-sizing: border-box;
  padding-left: 20px;
  padding-right: 20px;
}
nav.small-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: .45rem .75rem;
  border-radius: 999px;
  background: transparent;
  font-size: .95rem;
  box-sizing: border-box;
}
nav.small-nav a.active {
  color: #081020;
  background: linear-gradient(90deg,var(--accent),#8b5cf6);
}

/* carousel */
.carousel-container {
  display: flex;
  justify-content: center;
  margin: 1.25rem 0;
}
.blog-wrap {
  width: 100%;
  max-width: 420px;
}
.carousel {
  position: relative;
  display: flex;
  gap: 18px;
  overflow-x: auto; /* Use auto for better user experience on mobile */
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  padding: 1rem 0;
  scroll-snap-type: x mandatory; /* Snap to cards */
}
.card {
  min-width: 260px;
  height: 170px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(2,6,23,.6);
  flex-shrink: 0;
  transform-origin: center;
  transition: transform .35s, box-shadow .35s;
  scroll-snap-align: center; /* Center the cards in the carousel */
}
.card h3 {
  margin: .15rem 0 .45rem;
  font-size: 1.03rem;
  color: var(--accent);
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}
.carousel-controls {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin-top: .8rem;
}
.ctrl {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.05);
  padding: .5rem;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg,rgba(2,6,23,.7),rgba(2,6,23,.85));
  z-index: 1000;
  padding: 1rem;
}
.modal .panel {
  max-width: 820px;
  width: 100%;
  background: linear-gradient(180deg,#021026, #081028);
  padding: 1.25rem;
  border-radius: 12px;
  color: #e8f0ff;
  box-shadow: 0 20px 60px rgba(2,6,23,.6);
}
.modal .close {
  float: right;
  cursor: pointer;
  padding: .3rem .5rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}

/* Cloud container */
.clouds {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  overflow: visible;
}

/* Each cloud */
.cloud {
  position: absolute;
  width: 120px;
  height: 70px;
  background: #fff;
  opacity: 0.6;
  border-radius: 50%;
  filter: blur(10px);
  box-shadow:
    60px 0 #fff,
    30px 0 #fff,
    90px 10px #fff;
}
  
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 2px; bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* Light blue sky for day mode */
/* No background here, handled by .daytime-sky element */

/* Clouds container */
.clouds {
  position: fixed;
  width: 100vw;
  height: 100vh;
  overflow: visible;
  z-index: -1;
  pointer-events: none;
}

/* Cloud shapes */
.cloud {
  position: absolute;
  width: 120px;
  height: 70px;
  background: #ffffff;
  opacity: 0.6;
  border-radius: 50%;
  filter: blur(12px);
  box-shadow:
    50px 10px #ffffff,
    100px 20px rgba(255, 255, 255, 0.9),
    150px 5px rgba(255, 255, 255, 0.85);
}


/* Cloud positions and animation are now handled by JS for full-screen coverage */

/* Movement animation */
@keyframes cloudMove {
  from { transform: translateX(-200px); }
  to { transform: translateX(120vw); }
}
/* daymode UI overrides */
  
body.daymode main.container {
  background: #ffffff34;
  color: #1e293b;
}
body.daymode .results {
  background: #f1f5f980;
  color: #16202b;
}
body.daymode .card {
  background: linear-gradient(180deg,#ffffff,#f6f9ff);
  color: #0b1220;
}
body.daymode {
  color: #1e293b;
}

/* Daytime blue sky background for day mode */
/* Only show blue sky in day mode */
.daytime-sky {
  display: none;
}
body.daymode .daytime-sky {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  background: linear-gradient(to top, #aad8f3 100%, #eaf6ff1a 10%);
  pointer-events: none;
}
body.daymode .card h3 {
  color: #3b2fb8;
}
body.daymode input[type="time"], 
body.daymode select#ampmSelect {
  background: #fff;
  border-color: #d1d5db;
  color: #0b1220;
}
body.daymode select#ampmSelect option {
  color: #0b1220;
  background: #fff;
}
body.daymode #calculateBtn {
  background: linear-gradient(90deg,#6366f1,#a78bfa);
  color: #fff;
}
/* Responsive adjustments for carousel */
@media (max-width:520px){
  main.container{margin:1rem}
  .card{min-width:220px;height:150px}
  .time-wrapper{gap:.5rem}
  nav.small-nav{padding-left:44px;padding-right:44px;}
  nav.small-nav a{padding-left:.2rem;padding-right:.2rem;}
  .carousel{
    justify-content: flex-start; /* Reset justify-content for scroll behavior */
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
  }
}