:root {
  --orange: #f47b20;
  --orange-dark: #d9600a;
  --cream: #fff6ec;
  --ink: #2b1a0e;
  --muted: #7a5a44;
  --white: #fff;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: "Poppins", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 20% 10%, #ffe3c7, var(--cream) 55%);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: default;
}
.brand {
  display: flex; align-items: center; gap: 1vw;
  padding: 2vh 3vw; flex: none;
}
.brand img { height: 6vh; }
.brand-text { font-size: 3vh; letter-spacing: .12em; color: var(--orange-dark); }
.brand img + .brand-text { display: none; }

.stage { position: relative; flex: 1; min-height: 0; }
.screen {
  position: absolute; inset: 0; padding: 2vh 4vw 4vh;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 2vh;
}
body[data-screen="boot"] .s-boot,
body[data-screen="idle"] .s-idle,
body[data-screen="choice"] .s-choice,
body[data-screen="play"] .s-play,
body[data-screen="processing"] .s-processing,
body[data-screen="result"] .s-result,
body[data-screen="error"] .s-error { display: flex; }

h1 { font-size: 8vh; line-height: 1.05; color: var(--orange-dark); font-weight: 800; }
h2 { font-size: 4.6vh; line-height: 1.15; font-weight: 700; }
h3 { font-size: 3.2vh; line-height: 1.15; font-weight: 800; }
p { font-size: 2.6vh; color: var(--muted); }
kbd { background: #fff; border: 1px solid #e3c9b3; border-radius: 6px; padding: 0 .4em; }
.hint { font-size: 1.8vh; position: absolute; bottom: 2vh; }
.pulse { color: var(--orange-dark); font-weight: 600; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

button {
  font: inherit; font-size: 3vh; font-weight: 700; color: #fff; background: var(--orange);
  border: 0; border-radius: 999px; padding: 1.6vh 6vh; cursor: pointer;
}

/* ---------- kamera ---------- */
.cam {
  position: absolute; z-index: 2; left: 50%; top: 50%;
  width: 46vh; height: 46vh; transform: translate(-50%, -50%);
  border-radius: 50%; overflow: hidden; background: #000;
  box-shadow: 0 2vh 6vh rgba(217, 96, 10, .3);
  transition: all .5s ease;
}
.cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-ring { position: absolute; inset: 0; border: 1vh solid var(--orange); border-radius: inherit; }
body[data-screen="boot"] .cam,
body[data-screen="processing"] .cam,
body[data-screen="result"] .cam,
body[data-screen="error"] .cam { opacity: 0; pointer-events: none; }
body[data-screen="idle"] .cam { top: 68%; width: 34vh; height: 34vh; }
body[data-screen="idle"] .s-idle { justify-content: flex-start; padding-top: 4vh; }
body[data-screen="choice"] .cam { top: 54%; width: 40vh; height: 40vh; }
body[data-screen="play"] .cam { top: 58%; width: 58vh; height: 58vh; }
body[data-screen="play"] .s-play { justify-content: flex-start; }

.count {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 26vh; font-weight: 800; color: #fff; text-shadow: 0 0 4vh rgba(0, 0, 0, .6);
}
.meter {
  position: absolute; left: 15%; right: 15%; bottom: 9%; height: 2vh;
  background: rgba(255, 255, 255, .35); border-radius: 99px; overflow: hidden; display: none;
}
.meter i { display: block; height: 100%; width: 0; background: var(--orange); border-radius: 99px; transition: width .1s; }
body.metering .meter { display: block; }

/* ---------- pilihan ---------- */
.s-choice { justify-content: flex-start; }
.cards { flex: 1; width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 44vh; }
.card {
  position: relative; overflow: hidden; flex: 1; max-width: 52vh; padding: 4vh 3vh;
  background: var(--white); border: .5vh solid #ffd2ad; border-radius: 4vh;
  display: flex; flex-direction: column; gap: 1.6vh;
  box-shadow: 0 1.5vh 4vh rgba(217, 96, 10, .12); transition: transform .2s, border-color .2s;
}
.card > * { position: relative; }
.card .fill, .again .fill {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0;
  background: linear-gradient(#ffd9b8, #ffb673);
}
.card.active { transform: scale(1.05); border-color: var(--orange); }
.card h3 { color: var(--orange-dark); }
.card p { font-size: 2.2vh; }
.hand { font-size: 2vh; font-weight: 700; color: var(--ink); background: #ffe9d6; border-radius: 99px; padding: .6vh 1.6vh; align-self: center; }
.warn { color: #fff; background: #c0392b; padding: 1vh 3vh; border-radius: 99px; font-weight: 700; }
.consent { font-size: 1.7vh; max-width: 110vh; }

/* ---------- proses ---------- */
.spinner {
  width: 14vh; height: 14vh; border-radius: 50%;
  border: 1.6vh solid #ffd9b8; border-top-color: var(--orange); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- hasil ---------- */
.s-result { justify-content: space-between; }
.result-main { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; gap: 5vw; }
.photos { display: flex; gap: 2vh; height: 100%; max-height: 58vh; align-items: center; }
.photos figure { height: 100%; display: flex; flex-direction: column; gap: 1vh; align-items: center; }
.photos img { height: calc(100% - 4vh); aspect-ratio: 1; object-fit: cover; border-radius: 3vh; border: .8vh solid #fff; box-shadow: 0 1.5vh 4vh rgba(0, 0, 0, .18); }
.photos figcaption { font-size: 2vh; font-weight: 700; color: var(--orange-dark); letter-spacing: .1em; }
.result-side { max-width: 60vh; display: flex; flex-direction: column; gap: 1.5vh; align-items: center; }
#resTitle { color: var(--orange-dark); }
#resChar { font-size: 5vh; }
#resChar:empty, #resDesc:empty { display: none; }
.close { font-size: 2.2vh; }
.qr { display: flex; align-items: center; gap: 2vh; background: #fff; border-radius: 3vh; padding: 1.6vh 2.4vh; text-align: left; }
.qr img { width: 20vh; height: 20vh; image-rendering: pixelated; }
.qr img:not([src]) { display: none; }
.qr span { font-size: 2.2vh; font-weight: 600; max-width: 22vh; }
.note { font-size: 1.5vh; }
.again {
  position: relative; overflow: hidden; background: #fff; border: .4vh solid #ffd2ad;
  border-radius: 99px; padding: 1.4vh 4vh; font-size: 2.3vh; font-weight: 700;
}
.again span { position: relative; }

@media (orientation: portrait) {
  h1 { font-size: 5.4vh; }
  h2 { font-size: 3.2vh; }
  .cards { align-items: flex-end; gap: 2vh; }
  .card { padding: 2vh 1.5vh; }
  .card h3 { font-size: 2.2vh; }
  body[data-screen="choice"] .cam { width: 34vh; height: 34vh; top: 40%; }
  body[data-screen="play"] .cam { width: 44vh; height: 44vh; }
  .result-main { flex-direction: column; gap: 2vh; }
  .photos { max-height: 34vh; }
  .hand { font-size: 1.5vh; }
}
