/* ==========================================================================
   PDIKM Adventure Flow — clue, question, end (page-shell aligned)
   ========================================================================== */

/* game/base.css locks body overflow — unlock for scrollable game pages (mobile+) */
body.pdikm-app:has(.pdikm-page--game),
html:has(.pdikm-page--game) body.pdikm-app {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100%;
  min-height: 100dvh;
}

.pdikm-page--game {
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(40px, calc(24px + env(safe-area-inset-bottom, 0px)));
  -webkit-overflow-scrolling: touch;
}

.pdikm-page--game .pdikm-glass-card {
  animation: pdikmFadeUp 0.55s 0.08s ease-out both;
}

.pdikm-page--game .pdikm-game-choices,
.pdikm-page--game .pdikm-game-form > .pdikm-footer-bar {
  animation: pdikmFadeUp 0.55s 0.12s ease-out both;
}

/* Timer badge */
.pdikm-game-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 202, 40, 0.12);
  border: 1px solid rgba(255, 202, 40, 0.35);
  color: #ffd54f;
  font-family: var(--pdikm-font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 72px;
}

.pdikm-game-timer::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffca28;
  box-shadow: 0 0 8px rgba(255, 202, 40, 0.8);
  animation: pdikmGamePulse 1.2s ease-in-out infinite;
}

@keyframes pdikmGamePulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.85);
  }
}

/* Clue card */
.pdikm-game-clue-title {
  margin: 0 0 16px;
  font-family: var(--pdikm-font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffca28;
  line-height: 1.45;
}

.pdikm-game-image-wrap {
  margin: 0 0 18px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.pdikm-game-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.pdikm-game-clue-body {
  text-align: left;
}

/* Question */
.pdikm-game-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pdikm-game-question {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  text-align: left;
}

.pdikm-game-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.pdikm-game-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}

.pdikm-game-choice:hover {
  border-color: rgba(255, 202, 40, 0.25);
  background: rgba(255, 255, 255, 0.06);
}

.pdikm-game-choice:has(.pdikm-game-choice-input:checked) {
  border-color: rgba(255, 202, 40, 0.55);
  background: rgba(255, 202, 40, 0.08);
  box-shadow: 0 0 0 1px rgba(255, 202, 40, 0.15);
}

.pdikm-game-choice-input {
  flex-shrink: 0;
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #ffca28;
  cursor: pointer;
}

.pdikm-game-choice-text {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.pdikm-page--question .pdikm-footer-bar {
  margin-top: 4px;
}

/* End / stats */
.pdikm-game-stats {
  padding-top: 24px;
}

.pdikm-game-congrats {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(255, 202, 40, 0.35));
}

.pdikm-game-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
}

.pdikm-game-stat-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.pdikm-game-stat-value {
  font-family: var(--pdikm-font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffd54f;
}

.pdikm-game-stat-divider {
  height: 1px;
  margin: 4px 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.pdikm-page--end .pdikm-footer-bar .btn-eticket {
  max-width: 100%;
}

/* Start / level selection */
.pdikm-page--start .pdikm-hero {
  margin-bottom: 16px;
}

.pdikm-alert {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  font-weight: 500;
  animation: pdikmFadeUp 0.45s ease-out both;
}

.pdikm-alert--error {
  background: rgba(183, 28, 28, 0.18);
  border: 1px solid rgba(244, 67, 54, 0.35);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pdikm-start-levels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  animation: pdikmFadeUp 0.55s 0.08s ease-out both;
}

.pdikm-level-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: 16px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

.pdikm-level-card-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px 10px 14px 16px;
  text-decoration: none;
  color: inherit;
}

.pdikm-level-card:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.pdikm-level-card:active {
  transform: scale(0.99);
}

.pdikm-level-info {
  flex-shrink: 0;
  align-self: center;
  width: 36px;
  height: 36px;
  margin-right: 12px;
  border: 1px solid rgba(255, 202, 40, 0.45);
  border-radius: 50%;
  background: rgba(255, 202, 40, 0.1);
  color: #ffd54f;
  font-family: var(--pdikm-font-display);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pdikm-level-info:hover {
  background: rgba(255, 202, 40, 0.2);
  border-color: rgba(255, 202, 40, 0.65);
}

.pdikm-level-info:active {
  transform: scale(0.94);
}

.pdikm-level-card--easy {
  border-color: rgba(102, 187, 106, 0.28);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16), inset 3px 0 0 rgba(102, 187, 106, 0.75);
}

.pdikm-level-card--easy:hover {
  border-color: rgba(102, 187, 106, 0.45);
}

.pdikm-level-card--medium {
  border-color: rgba(255, 202, 40, 0.28);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16), inset 3px 0 0 rgba(255, 202, 40, 0.85);
}

.pdikm-level-card--medium:hover {
  border-color: rgba(255, 202, 40, 0.45);
}

.pdikm-level-card--hard {
  border-color: rgba(239, 83, 80, 0.28);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16), inset 3px 0 0 rgba(239, 83, 80, 0.8);
}

.pdikm-level-card--hard:hover {
  border-color: rgba(239, 83, 80, 0.45);
}

.pdikm-level-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pdikm-level-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdikm-level-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.pdikm-level-label {
  font-family: var(--pdikm-font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.pdikm-level-desc {
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

/* Level cards: full-width tap on mobile */
@media (max-width: 767px) {
  .pdikm-page--start {
    padding-bottom: max(28px, calc(16px + env(safe-area-inset-bottom, 0px)));
  }

  .pdikm-start-levels {
    gap: 10px;
  }

  .pdikm-level-card-main {
    padding: 12px 12px 12px 14px;
    gap: 12px;
  }

  .pdikm-level-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }

  .pdikm-page--question .pdikm-footer-bar,
  .pdikm-page--end .pdikm-footer-bar,
  .pdikm-page--finish .pdikm-footer-bar {
    position: sticky;
    bottom: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, transparent 0%, rgba(8, 12, 22, 0.92) 28%);
    z-index: 5;
  }
}

/* Media page topbar + back */
.pdikm-page--media {
  padding-top: 0;
  padding-bottom: 24px;
}

.pdikm-game-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: rgba(8, 12, 22, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pdikm-game-back {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: color 0.15s ease;
}

.pdikm-game-back:hover {
  color: #fff;
}

.pdikm-game-topbar-title {
  flex: 1;
  text-align: center;
  font-family: var(--pdikm-font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffca28;
}

.pdikm-game-topbar-spacer {
  flex-shrink: 0;
  width: 72px;
}

.pdikm-page--media #game-media-root {
  width: 100%;
}

.pdikm-page--media .game-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  overflow: hidden;
}

.pdikm-page--media .media-panorama {
  width: 100%;
  min-height: 240px;
  height: 42vh;
}

.pdikm-page--media .media-video {
  display: block;
  width: 100%;
  max-height: 42vh;
  border-radius: 12px;
}

.pdikm-page--media .media-countdown {
  margin: 14px 0 8px;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.pdikm-page--media .btn-game {
  border: none;
  cursor: pointer;
}

.pdikm-page--finish .pdikm-footer-bar .pdikm-footer-link {
  margin-top: 4px;
}

.pdikm-page--end .pdikm-footer-bar .pdikm-footer-link {
  margin-top: 4px;
}

.pdikm-page--question .pdikm-footer-bar .btn-eticket--ghost {
  max-width: 100%;
}

/* Level info popup (SweetAlert2) */
body.pdikm-app .pdikm-level-swal {
  border: 1px solid rgba(255, 202, 40, 0.22) !important;
  border-radius: 20px !important;
  padding: 24px 20px 20px !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45) !important;
}

body.pdikm-app .pdikm-level-swal-title {
  font-family: var(--pdikm-font-display) !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: #ffca28 !important;
}

body.pdikm-app .pdikm-level-swal-text,
body.pdikm-app .pdikm-level-swal .swal2-html-container {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.82) !important;
  text-align: left;
}

body.pdikm-app .pdikm-level-swal-btn {
  margin-top: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffd54f 0%, #ffca28 100%);
  color: #3e2723;
  font-family: var(--pdikm-font-display);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #c9a020;
}

body.pdikm-app .pdikm-level-swal-btn:active {
  transform: scale(0.97);
  box-shadow: 0 3px 0 #c9a020;
}
