/* =====================================================
   CSS: RODA NUSANTARA (level budaya-6)
   Redesain UI - Playful, Juicy, Mobile First
   ===================================================== */

/* Container Utama */
#screen-roda {
  position: relative;
  overflow: hidden; /* Konten di dalamnya yang scroll atau fixed */
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background-image: 
    url("../assets/images/backgrounds/bg_wawasan.webp"),
    radial-gradient(circle at top, #b2ebf2 0%, #26c6da 100%);
  background-position: center center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  background-attachment: scroll !important;
  padding: 16px 14px 24px;
}


/* Dekorasi Background Animasi */
.roda-bg-fx {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}
.roda-awan, .roda-bintang {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
}
.roda-awan {
  width: 120px; height: 60px;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg"><path d="M20,40 Q10,40 10,30 Q10,20 25,20 Q30,10 45,10 Q60,10 65,20 Q80,15 85,25 Q95,25 90,40 Z" fill="%23ffffff"/></svg>');
  animation: floatCloud 25s linear infinite;
}
.roda-awan:nth-child(2) { top: 15%; animation-duration: 35s; animation-delay: -10s; transform: scale(0.8); opacity: 0.5; }
.roda-awan:nth-child(3) { top: 40%; animation-duration: 20s; animation-delay: -5s; transform: scale(1.2); }
.roda-bintang {
  width: 30px; height: 30px;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="%23fff59d" d="M256,10 L318,175 L502,192 L363,313 L404,491 L256,403 L108,491 L149,313 L10,192 L194,175 Z"/></svg>');
  animation: floatStar 4s ease-in-out infinite alternate;
}
.roda-bintang:nth-child(4) { top: 25%; left: 10%; animation-delay: 0s; }
.roda-bintang:nth-child(5) { top: 60%; right: 15%; animation-delay: 1s; transform: scale(0.6); }

@keyframes floatCloud {
  from { left: -150px; }
  to { left: 110%; }
}
@keyframes floatStar {
  from { transform: translateY(0) scale(1) rotate(0deg); }
  to { transform: translateY(-15px) scale(1.2) rotate(15deg); }
}

/* Membatasi area konten utama ke lebar mobile */
.roda-content-wrapper {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: 20px;
  margin: 0 auto;
}

/* ================= TOPBAR & HUD ================= */
.roda-topbar { 
  display: flex; 
  align-items: center; 
  justify-content: center;
  gap: 16px; 
  flex-wrap: wrap; 
  background: rgba(255, 255, 255, 0.4);
  padding: 12px 24px;
  border-radius: 24px;
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  margin-bottom: 10px;
}
.roda-topbar h2 { 
  font-family: var(--font-judul); 
  font-size: 26px; 
  color: #004d40; 
  text-shadow: 1px 1px 0 #fff, 0px 2px 4px rgba(0,0,0,0.2);
  line-height: 1;
  text-align: center;
}
.roda-btn-quit {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 100;
  width: 44px; height: 44px; 
  border: 4px solid #fff; border-radius: 50%;
  background: var(--merah); color: #fff; font-size: 18px; font-weight: 900; 
  cursor: pointer; flex-shrink: 0;
  box-shadow: 0 4px 0 var(--merah-tua), 0 8px 10px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}
.roda-btn-quit:active { 
  transform: translateY(4px); 
  box-shadow: 0 0 0 var(--merah-tua), 0 4px 5px rgba(0,0,0,0.2); 
}
.roda-nyawa {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 12px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  font-size: 16px;
  letter-spacing: 2px;
  color: #ff5252;
  backdrop-filter: blur(5px);
}
.roda-chip {
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%); 
  border: 3px solid #fff; border-radius: 999px;
  padding: 6px 14px; font-weight: 900; color: var(--coklat);
  display: flex; align-items: center; gap: 6px; 
  box-shadow: 0 4px 0 #cfd8dc; white-space: nowrap;
}
/* Progress XP Bar Style */
.roda-bar-bg { 
  flex: 1; min-width: 100px; height: 18px; 
  background: rgba(0,0,0,0.2); 
  border-radius: 999px; overflow: hidden; 
  border: 2px solid #fff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.roda-bar-fill { 
  height: 100%; width: 0; 
  background: repeating-linear-gradient(
    45deg,
    #ffca28,
    #ffca28 10px,
    #ffb300 10px,
    #ffb300 20px
  ); 
  background-size: 28px 28px;
  animation: barStripe 1s linear infinite;
  transition: width 0.5s cubic-bezier(0.17, 0.89, 0.32, 1.28); 
  border-radius: 999px;
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.5);
}
@keyframes barStripe {
  0% { background-position: 0 0; }
  100% { background-position: 28px 0; }
}

/* ================= RODA AREA ================= */
.roda-area-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end; /* Duduk di bawah / panggung */
  flex-grow: 1;
  margin-top: 10px;
  margin-bottom: 20px;
}
/* Halo Cahaya Tipis di Belakang Roda */
.roda-area-wrap::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 140%; height: 140%;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 65%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
}

.roda-area { 
  position: relative; 
  width: 100%; max-width: clamp(220px, 70vw, 360px); 
  aspect-ratio: 1/1; 
  display: grid; place-items: center; 
  animation: rodaNapas 3s ease-in-out infinite;
}
.roda-area.berputar {
  animation: none;
}
@keyframes rodaNapas {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}


.roda-pointer {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%); z-index: 10;
  width: 32px; height: 45px; 
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 30 45" xmlns="http://www.w3.org/2000/svg"><path d="M15,45 L0,15 Q0,0 15,0 Q30,0 30,15 Z" fill="%23d32f2f" stroke="%23ffffff" stroke-width="3"/></svg>');
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.4));
  transform-origin: top center;
}
/* Pointer tick animation */
.roda-pointer.ticking {
  animation: tickTremble 0.1s alternate 2;
}
@keyframes tickTremble {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(15deg); }
}

#roda-svg {
  width: 100%; height: 100%;
  filter: drop-shadow(0 15px 25px rgba(0,0,0,0.3));
  border-radius: 50%;
  border: 8px solid #fff;
  background: #fff;
  box-sizing: content-box;
}
/* Inner shadow to wheel via after */
.roda-area::after {
  content: "";
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: inset 0 8px 12px rgba(0,0,0,0.3);
  z-index: 6;
}

#roda-svg path {
  stroke: #ffffff;
  stroke-width: 3;
}
#roda-svg text { font: 800 18px system-ui, sans-serif; fill: #fff; text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.roda-hub {
  position: absolute; width: 68px; height: 68px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #ffd54f);
  border: 6px solid #ff8f00; display: grid; place-items: center; font-size: 32px;
  z-index: 8; box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

/* ================= 3D TOMBOL PUTAR ================= */
.roda-btn-wrap {
  text-align: center;
  margin-bottom: 15px;
  position: relative;
  z-index: 10;
}
.roda-btn-putar {
  border: 0; border-radius: 28px; padding: 18px 45px;
  font: 900 24px var(--font-judul); 
  background: linear-gradient(180deg, #ffca28 0%, #ff8f00 100%);
  color: #fff; text-shadow: 1px 2px 0 #e65100;
  cursor: pointer; 
  box-shadow: 
    0 8px 0 #e65100, 
    0 15px 30px rgba(255, 143, 0, 0.5),
    inset 0 4px 0 rgba(255,255,255,0.4);
  transition: all 0.1s;
  animation: btnIdleBounce 1.4s infinite ease-in-out;
}
@keyframes btnIdleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.roda-btn-putar:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow: 
    0 2px 0 #e65100, 
    0 5px 10px rgba(255, 143, 0, 0.5),
    inset 0 4px 0 rgba(255,255,255,0.4);
}
.roda-btn-putar:disabled { 
  opacity: 0.65;
  filter: grayscale(0.5);
  animation: none;
  cursor: not-allowed;
  transform: translateY(0);
}

.roda-kat { 
  font-family: var(--font-judul); font-weight: 900; font-size: 22px; 
  min-height: 30px; opacity: 0; transition: opacity .3s, transform 0.3s; 
  color: #fff; text-shadow: 0 2px 5px rgba(0,0,0,0.5);
  margin-top: 15px; transform: translateY(10px);
}
.roda-kat.tampil { opacity: 1; transform: translateY(0); }

/* ================= KARTU SELESAI ================= */
.roda-cards-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 50px;
  position: relative;
  z-index: 10;
}
.roda-card-done {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #4caf50;
  border-radius: 20px;
  padding: 8px 14px;
  font-family: var(--font-judul);
  font-size: 20px;
  font-weight: 900;
  color: #2e7d32;
  box-shadow: 0 6px 15px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: cardPop 0.5s cubic-bezier(0.17, 0.89, 0.32, 1.28);
}
@keyframes cardPop {
  0% { transform: scale(0.2) translateY(-50px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}



/* toast (dipoles) */
.roda-toast {
  position: fixed; left: 50%; top: 20%; transform: translateX(-50%);
  font-family: var(--font-judul); font-size: 48px; font-weight: 900; color: #ffeb3b;
  text-shadow: 0 5px 10px rgba(0,0,0,0.5), 3px 3px 0 #e65100, -3px -3px 0 #e65100, 3px -3px 0 #e65100, -3px 3px 0 #e65100;
  pointer-events: none; z-index: 1200;
  animation: rodaNaik 1s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
}
.roda-toast.buruk { color: #ef5350; text-shadow: 0 5px 10px rgba(0,0,0,0.5), 3px 3px 0 #b71c1c, -3px -3px 0 #b71c1c, 3px -3px 0 #b71c1c, -3px 3px 0 #b71c1c; }
@keyframes rodaNaik {
  0% { opacity: 0; transform: translateX(-50%) scale(0.2) translateY(50px); }
  30% { opacity: 1; transform: translateX(-50%) scale(1.2) translateY(0); }
  60% { transform: translateX(-50%) scale(1) translateY(-20px); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.8) translateY(-60px); }
}

/* Confetti Wrapper */
#roda-confetti {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1150;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 12px;
  height: 24px;
  background-color: #ffca28;
  opacity: 0;
}
@keyframes confettiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* Segment Win Blink */
.roda-segmen-win {
  animation: segmenBlink 0.4s alternate infinite;
}
@keyframes segmenBlink {
  from { filter: brightness(1) saturate(1); }
  to { filter: brightness(1.6) saturate(1.5) drop-shadow(0 0 10px rgba(255,255,255,0.8)); }
}

@media (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
  #screen-roda { padding: 6px 8px; }
  .roda-content-wrapper { padding: 0; gap: 4px; }
  .roda-topbar { padding: 6px 16px; margin-bottom: 2px; }
  .roda-topbar h2 { font-size: 18px; }
  .roda-area-wrap { margin-top: 2px; margin-bottom: 6px; }
  .roda-area { max-width: clamp(150px, 40vh, 210px); }
  .roda-btn-wrap { margin-bottom: 4px; }
  .roda-btn-putar { padding: 8px 24px; font-size: 16px; border-radius: 20px; }
  .roda-cards-container { min-height: 36px; gap: 6px; }
  .roda-card-done { font-size: 14px; padding: 4px 10px; }
}