/* ============ BRAND & DASAR ============ */
:root {
  --coral: #ff5d73;
  --coral-soft: #ffe3e8;
  --teal: #00c2a8;
  --teal-soft: #d9f7f2;
  --yellow: #ffc531;
  --purple: #7c5cff;
  --ink: #2b2350;
  --cream: #fff8ed;
  --white: #ffffff;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(43, 35, 80, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #fff8ed 0%, #fff0f2 50%, #eafcf8 100%);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* blob dekorasi bergerak */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  z-index: 0;
  animation: float 12s ease-in-out infinite alternate;
  pointer-events: none;
}
.blob-1 { width: 340px; height: 340px; background: var(--coral); top: -100px; left: -80px; }
.blob-2 { width: 300px; height: 300px; background: var(--teal); bottom: -80px; right: -60px; animation-delay: -4s; }
.blob-3 { width: 220px; height: 220px; background: var(--yellow); top: 40%; left: 60%; animation-delay: -8s; }

@keyframes float {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, -30px) scale(1.15); }
}

/* ============ LAYAR ============ */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; animation: screenIn 0.45s cubic-bezier(0.22, 1.2, 0.36, 1); }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.hidden { display: none !important; }
.hl { color: var(--coral); }

/* ============ LOGO ============ */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.logo-tile {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  animation: bounceTile 2.2s ease-in-out infinite;
}
.logo-tile.t1 { background: var(--coral); animation-delay: 0s; }
.logo-tile.t2 { background: var(--yellow); animation-delay: 0.12s; }
.logo-tile.t3 { background: var(--teal); animation-delay: 0.24s; }
.logo-tile.t4 { background: var(--purple); animation-delay: 0.36s; }
.logo-word { font-size: 32px; font-weight: 900; margin-left: 6px; }

@keyframes bounceTile {
  0%, 20%, 100% { transform: translateY(0) rotate(0deg); }
  10% { transform: translateY(-8px) rotate(-6deg); }
}

.tagline { color: #6b648c; margin-bottom: 28px; }

/* ============ FORM SETUP ============ */
.field { text-align: left; margin-bottom: 20px; flex: 1; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.field input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  border: 3px solid #ece8f7;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, transform 0.2s;
}
.field input[type="text"]:focus { transform: scale(1.02); }
.field.p1 input:focus { border-color: var(--coral); }
.field.p2 input:focus { border-color: var(--teal); }

.field-row { display: flex; align-items: center; gap: 12px; }
.vs-badge {
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  padding: 8px 12px;
  border-radius: 999px;
  margin-top: 12px;
  box-shadow: 0 4px 0 rgba(43, 35, 80, 0.15);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.12); } }

/* pemilih mode permainan */
.mode-group { display: flex; gap: 12px; }
.mode-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 3px solid #ece8f7;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  text-align: center;
  transition: all 0.18s;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--yellow); }
.mode-card.selected {
  border-color: var(--purple);
  background: #f4f0ff;
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.25);
  transform: scale(1.03);
}
.mode-icon { font-size: 28px; }
.mode-title { font-weight: 900; font-size: 15px; }
.mode-desc { font-size: 11px; color: #6b648c; font-weight: 700; }

.chip-group { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  padding: 10px 18px;
  border: 3px solid #ece8f7;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.18s;
}
.chip:hover { transform: translateY(-2px); border-color: var(--purple); }
.chip.selected {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.35);
}

/* ============ TOMBOL ============ */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), #ff8a5c);
  box-shadow: 0 6px 0 #d63d55, 0 12px 24px rgba(255, 93, 115, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.2s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #d63d55; }
.btn-big { font-size: 18px; padding: 16px 32px; width: 100%; margin-top: 8px; }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 0 #dcd7ee;
  border: 3px solid #ece8f7;
  font-size: 16px;
  padding: 13px 24px;
}
.btn:disabled {
  filter: grayscale(0.8) opacity(0.6);
  cursor: not-allowed;
  transform: none;
}

/* ============ LAYAR RAHASIA ============ */
.secret-card { min-height: 340px; display: flex; flex-direction: column; justify-content: center; }
.cover-emoji { font-size: 64px; animation: pulse 1.8s infinite; }
.secret-cover h2, .secret-form h2 { margin: 12px 0 8px; font-size: 26px; }
.secret-cover p, .secret-form p { color: #6b648c; margin-bottom: 20px; }

.peek-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #6b648c;
  margin: 14px 0 6px;
  cursor: pointer;
}
.peek-toggle input { accent-color: var(--purple); width: 16px; height: 16px; }

/* ============ KOTAK DIGIT ============ */
.digit-boxes { display: flex; gap: 10px; justify-content: center; }
.digit-boxes input {
  width: 54px; height: 64px;
  border: 3px solid #ece8f7;
  border-radius: 14px;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  color: var(--ink);
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
}
.digit-boxes input:focus {
  border-color: var(--purple);
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.25);
}
.digit-boxes input:disabled { background: #f6f4fc; opacity: 0.55; }
.digit-boxes.small input { width: 42px; height: 50px; font-size: 20px; border-radius: 12px; }
.digit-boxes input.filled { border-color: var(--teal); animation: popIn 0.18s ease; }

@keyframes popIn { 0% { transform: scale(0.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* input angka tunggal (mode Naik Turun) */
.num-input {
  width: 100%;
  max-width: 240px;
  padding: 12px 16px;
  border: 3px solid #ece8f7;
  border-radius: 14px;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 3px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  transition: all 0.15s;
}
.num-input:focus {
  border-color: var(--purple);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.25);
}
.num-input::placeholder { letter-spacing: 0; font-size: 14px; color: #b6b0d0; }

/* penunjuk range (mode Naik Turun) */
.range-hint {
  background: #fff;
  border: 2px dashed var(--purple);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
  text-align: center;
  color: var(--ink);
}
.range-hint b { color: var(--purple); font-size: 15px; }

.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ============ ARENA GAME ============ */
#screen-game { justify-content: flex-start; padding-top: 20px; }

.game-header { margin-bottom: 18px; }
.turn-banner {
  background: var(--white);
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 18px;
  font-weight: 900;
  box-shadow: var(--shadow);
  border: 3px solid var(--yellow);
  animation: bannerGlow 1.6s ease-in-out infinite;
}
@keyframes bannerGlow {
  50% { box-shadow: 0 0 0 8px rgba(255, 197, 49, 0.25); }
}

.arena {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
}
.arena-vs { font-size: 34px; align-self: center; animation: pulse 1.2s infinite; }

.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  flex: 1;
  max-width: 430px;
  border-top: 8px solid transparent;
  transition: transform 0.3s, box-shadow 0.3s, opacity 0.3s;
}
.panel.p1 { border-top-color: var(--coral); }
.panel.p2 { border-top-color: var(--teal); }

.panel.turn-active {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 40px rgba(43, 35, 80, 0.2);
}
.panel.p1.turn-active { box-shadow: 0 18px 40px rgba(255, 93, 115, 0.35); }
.panel.p2.turn-active { box-shadow: 0 18px 40px rgba(0, 194, 168, 0.35); }
.panel.turn-idle { opacity: 0.65; }
.panel.turn-idle .guess-zone { pointer-events: none; filter: grayscale(0.5); }

.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; text-align: left; }
.avatar {
  font-size: 26px;
  background: var(--cream);
  border-radius: 14px;
  padding: 8px;
}
.panel-name { font-size: 20px; }
.panel-sub { font-size: 12px; color: #6b648c; font-weight: 700; }

/* angka rahasia (masked) */
.secret-display { display: flex; gap: 8px; margin-bottom: 16px; }
.secret-tile {
  width: 40px; height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
  background: var(--ink);
  color: var(--yellow);
  perspective: 200px;
}
.secret-tile.revealed {
  background: var(--yellow);
  color: var(--ink);
  animation: flipReveal 0.5s ease backwards;
}
@keyframes flipReveal {
  from { transform: rotateX(90deg); }
  to   { transform: rotateX(0); }
}

/* zona tebak */
.guess-zone {
  background: #f8f6ff;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.guess-label { font-size: 13px; font-weight: 800; margin-bottom: 10px; color: #6b648c; text-align: left; }
.btn-guess { width: 100%; margin-top: 12px; padding: 12px; font-size: 16px; }
.panel.p2 .btn-guess {
  background: linear-gradient(135deg, var(--teal), #4fd8c8);
  box-shadow: 0 6px 0 #00907d, 0 12px 24px rgba(0, 194, 168, 0.35);
}
.panel.p2 .btn-guess:active { box-shadow: 0 2px 0 #00907d; }

/* riwayat tebakan */
.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.history-empty { color: #b6b0d0; font-size: 13px; font-weight: 700; text-align: center; padding: 10px; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream);
  border-radius: 12px;
  padding: 8px 12px;
  animation: popIn 0.25s ease;
}
.history-guess { font-size: 18px; font-weight: 900; letter-spacing: 5px; }
.history-feedback { display: flex; gap: 6px; }

.badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.exact { background: var(--teal-soft); color: #00806f; }
.badge.partial { background: #fff3d1; color: #a87a00; }
.badge.zero { background: #f1eefb; color: #8d86ad; }
.badge.up { background: #e0f5e9; color: #1c8a4e; }
.badge.down { background: #ffe9e0; color: #c2410c; }

.hint-legend {
  margin-top: 18px;
  font-size: 13px;
  color: #6b648c;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.75);
  padding: 10px 18px;
  border-radius: 999px;
}

/* ============ OVERLAY MENANG ============ */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(43, 35, 80, 0.55);
  backdrop-filter: blur(6px);
}
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.win-card { animation: winPop 0.5s cubic-bezier(0.22, 1.4, 0.36, 1); position: relative; z-index: 2; }
@keyframes winPop {
  from { transform: scale(0.6) rotate(-4deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
.trophy { font-size: 72px; animation: trophyBounce 1s ease infinite; }
@keyframes trophyBounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12px) rotate(4deg); }
}
#win-title { font-size: 34px; margin: 8px 0 4px; }
#win-desc { color: #6b648c; margin-bottom: 18px; }

.win-secrets { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.win-secret-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
}
.win-secret-num { font-size: 20px; letter-spacing: 6px; color: var(--purple); }

.win-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============ FOTO PEMAIN (SETUP) ============ */
.photo-row { display: flex; gap: 14px; }
.photo-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #f8f6ff;
  border: 3px dashed #dcd7ee;
  border-radius: 16px;
  padding: 14px;
  transition: border-color 0.2s, background 0.2s;
}
.photo-slot.done { border-style: solid; background: #fff; }
.photo-slot.p1.done { border-color: var(--coral); }
.photo-slot.p2.done { border-color: var(--teal); }
.photo-slot.missing { border-color: var(--coral); background: var(--coral-soft); }

.photo-thumb {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: #ece8f7;
  display: grid;
  place-items: center;
  font-size: 36px;
  overflow: hidden;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; animation: popIn 0.3s ease; }

.btn-photo { font-size: 13px; padding: 9px 14px; background: linear-gradient(135deg, var(--purple), #9d85ff); box-shadow: 0 5px 0 #5a3fd6, 0 10px 20px rgba(124, 92, 255, 0.3); }
.btn-photo:active { box-shadow: 0 2px 0 #5a3fd6; }

.photo-note { color: var(--coral); font-size: 13px; font-weight: 800; margin-top: 10px; text-align: center; }

/* ============ MODAL KAMERA ============ */
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(43, 35, 80, 0.6);
  backdrop-filter: blur(6px);
}
.camera-card { max-width: 440px; animation: winPop 0.4s cubic-bezier(0.22, 1.4, 0.36, 1); }

.camera-stage {
  position: relative;
  width: 300px; height: 300px;
  margin: 18px auto;
  border-radius: 24px;
  overflow: hidden;
  background: var(--ink);
  border: 5px solid var(--yellow);
  box-shadow: 0 10px 30px rgba(255, 197, 49, 0.35);
}
.camera-stage video,
.camera-stage canvas {
  width: 100%; height: 100%;
  object-fit: cover;
}
.camera-stage video { transform: scaleX(-1); } /* mirror preview */

.camera-countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 110px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  background: rgba(43, 35, 80, 0.25);
  animation: pulse 0.7s infinite;
}

.camera-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.camera-flash.snap { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

.camera-error { color: var(--coral); font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.camera-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============ DUEL FOTO DI LAYAR AKHIR ============ */
.win-duel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 22px;
}
.win-duel-vs { font-size: 28px; animation: pulse 1.2s infinite; }

.win-player {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 30px;
  min-width: 140px;
}

.win-photo-wrap {
  width: 112px; height: 112px;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid #cfc9e6;
}
.win-photo { width: 100%; height: 100%; object-fit: cover; }

/* pemenang: lompat-lompat senang + mahkota jatuh */
.is-winner .win-photo-wrap {
  border-color: var(--yellow);
  box-shadow: 0 0 0 6px rgba(255, 197, 49, 0.3), 0 12px 28px rgba(255, 197, 49, 0.4);
  animation: winnerJump 1s ease-in-out infinite;
}
@keyframes winnerJump {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.crown {
  position: absolute;
  top: -8px;
  font-size: 38px;
  z-index: 2;
  animation: crownDrop 0.7s cubic-bezier(0.22, 1.6, 0.36, 1) 0.3s backwards, crownFloat 2s ease-in-out 1s infinite;
}
@keyframes crownDrop {
  from { transform: translateY(-60px) rotate(-30deg); opacity: 0; }
  to   { transform: translateY(0) rotate(0); opacity: 1; }
}
@keyframes crownFloat {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}

/* yang kalah: foto abu-abu + goyang sedih */
.is-loser .win-photo-wrap {
  animation: loserWobble 2.4s ease-in-out infinite;
}
.is-loser .win-photo { filter: grayscale(1) brightness(0.92); }
@keyframes loserWobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg) translateY(3px); }
}

/* karakter emosi */
.win-char {
  position: absolute;
  bottom: 62px;
  right: -6px;
  font-size: 36px;
  z-index: 2;
}
.is-winner .win-char { animation: charDance 0.6s ease-in-out infinite; }
@keyframes charDance {
  0%, 100% { transform: translateY(0) rotate(-12deg) scale(1); }
  50% { transform: translateY(-12px) rotate(12deg) scale(1.15); }
}
.is-loser .win-char { animation: charSob 1.4s ease-in-out infinite; }
@keyframes charSob {
  0%, 100% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.08) rotate(-6deg); }
  75% { transform: scale(0.94) rotate(6deg); }
}

/* percikan pesta pemenang */
.sparks span {
  position: absolute;
  font-size: 20px;
  animation: sparkPop 1.4s ease-in-out infinite;
}
.sparks span:nth-child(1) { top: 26px; left: -10px; animation-delay: 0s; }
.sparks span:nth-child(2) { top: 8px; right: -12px; animation-delay: 0.4s; }
.sparks span:nth-child(3) { bottom: 70px; left: -16px; animation-delay: 0.8s; }
@keyframes sparkPop {
  0%, 100% { transform: scale(0.5) rotate(0); opacity: 0.4; }
  50% { transform: scale(1.3) rotate(20deg); opacity: 1; }
}

/* air mata yang kalah */
.tears span {
  position: absolute;
  top: 60px;
  font-size: 16px;
  opacity: 0;
  animation: tearFall 1.6s ease-in infinite;
}
.tears span:nth-child(1) { left: 18px; animation-delay: 0s; }
.tears span:nth-child(2) { right: 18px; animation-delay: 0.55s; }
.tears span:nth-child(3) { left: 46px; animation-delay: 1.1s; }
@keyframes tearFall {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(55px) scale(1); opacity: 0; }
}

.win-player-name { font-weight: 900; font-size: 16px; margin-top: 4px; }

.status-badge {
  font-size: 12px;
  font-weight: 900;
  padding: 5px 14px;
  border-radius: 999px;
  letter-spacing: 1px;
}
.status-badge.win { background: var(--yellow); color: var(--ink); box-shadow: 0 4px 12px rgba(255, 197, 49, 0.5); }
.status-badge.lose { background: #f1eefb; color: #8d86ad; }

/* avatar foto di panel game */
.avatar.has-photo { padding: 0; }
.avatar-photo {
  width: 46px; height: 46px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 760px) {
  .arena { flex-direction: column; align-items: stretch; }
  .arena-vs { align-self: center; }
  .panel { max-width: none; }
  .field-row { flex-direction: column; gap: 4px; }
  .vs-badge { margin: 4px 0; }
  .digit-boxes input { width: 46px; height: 56px; }
}
