@font-face { font-family: 'Cormorant'; src: url('/fonts/cormorant.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('/fonts/cormorant-italic.woff2') format('woff2'); font-style: italic; font-weight: 500; font-display: swap; }

:root {
  --bg: #121110;
  --surface: #1b1a18;
  --line: #2e2b27;
  --ink: #efe8d8;
  --muted: #a39c8e;
  --dim: #6f695f;
  --red: #c8452e;
  --yellow: #e6d98e;
  --serif: 'Cormorant', 'Cormorant Garamond', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gutter: clamp(16px, 3vw, 40px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* grain halus supaya hitamnya tidak datar */
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"); }
#app { position: relative; z-index: 1; }

/* ---------- label kecil di sudut ---------- */
.label { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.serif { font-family: var(--serif); }

/* ---------- kerangka layar ---------- */
.screen { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: var(--gutter); gap: 20px; }
.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.brand { font-family: var(--serif); font-size: 22px; font-style: italic; text-decoration: none; letter-spacing: .01em; }
.brand b { font-style: normal; font-weight: 600; }
.code-chip { text-align: right; }
.code-chip strong { display: block; font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: .18em; line-height: 1; }

/* ---------- tombol & input ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); font-weight: 600; letter-spacing: .02em; text-decoration: none; transition: transform .15s ease, opacity .15s ease, background-color .15s ease; }
.btn:hover { background: #fff; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .35; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; }
.btn.red { background: var(--red); border-color: var(--red); color: var(--ink); }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field input { min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 17px; }
.field input:focus { border-color: var(--ink); outline: none; }
.field input.code { font-family: var(--serif); font-size: 26px; letter-spacing: .3em; text-transform: uppercase; text-align: center; }

/* ---------- kartu ---------- */
.card { --w: 120px; width: var(--w); aspect-ratio: 5 / 8; perspective: 900px; flex: none; }
.card-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .2, 1); }
.card.flipped .card-in { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--w) * .07); overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.face.front { transform: rotateY(180deg); background: var(--c); }
.face.back { background: #221f1c; }
.frame { position: absolute; inset: calc(var(--w) * .05); border: calc(var(--w) * .012 + 1px) solid var(--ink); border-radius: calc(var(--w) * .05); display: flex; flex-direction: column; align-items: center; }
.face.back .frame { border-color: #5a554c; }
.face svg { width: 100%; flex: 1; display: block; }
.roman { font-family: var(--serif); font-weight: 600; font-size: calc(var(--w) * .12); padding-top: calc(var(--w) * .05); letter-spacing: .06em; line-height: 1; }
.cname { font-family: var(--serif); font-size: calc(var(--w) * .085); font-weight: 600; text-align: center; line-height: 1.1; padding: 0 6% calc(var(--w) * .07); text-transform: uppercase; letter-spacing: .05em; }
.card.mini { --w: 64px; }
.card.mini .cname { display: none; }

/* ---------- cincin kartu (3D) ---------- */
.ring-wrap { position: relative; display: grid; place-items: center; }
.stage { position: relative; width: 100%; height: var(--stage-h, 300px); perspective: 1500px; perspective-origin: 50% 30%; overflow: hidden; touch-action: pan-y; user-select: none; cursor: grab; -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
.stage.dragging { cursor: grabbing; }
.ring { position: absolute; left: 50%; top: 50%; transform-style: preserve-3d; }
.ring.anim { transition: transform .55s cubic-bezier(.25, .8, .25, 1); }
.slot { position: absolute; transform-style: preserve-3d; transition: opacity .3s ease, filter .3s ease; }
.slot .card { cursor: pointer; }
.slot:not(.front) { opacity: .55; filter: saturate(.7) brightness(.8); }
.slot.front .face { box-shadow: 0 0 0 1px var(--yellow), 0 18px 40px rgba(0, 0, 0, .6); }
.ring-ctl { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; }
.round:hover { border-color: var(--ink); }
.ring-hint { font-size: 13px; color: var(--muted); text-align: center; min-width: 180px; }

/* ---------- pembacaan kartu ---------- */
.reading { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(20px, 4vw, 56px); align-items: center; max-width: 980px; margin: 0 auto; width: 100%; }
.reading .card { --w: clamp(150px, 22vw, 260px); }
.reading h2 { font-family: var(--serif); font-size: clamp(30px, 4.6vw, 56px); font-weight: 500; line-height: 1.02; }
.reading .asli { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 18px; margin-top: 4px; }
.reading .ramalan { font-family: var(--serif); font-size: clamp(19px, 2vw, 24px); line-height: 1.4; margin-top: 18px; }
.ask { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.ask p:not(.label) { font-family: var(--serif); font-style: italic; font-size: clamp(20px, 2.2vw, 27px); line-height: 1.3; margin-top: 6px; color: var(--yellow); }
.reveal-in { animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- skor energi ---------- */
.energy { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.energy button { min-height: 72px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 2px; transition: border-color .15s ease, background-color .15s ease; }
.energy button:hover { border-color: var(--ink); }
.energy b { font-family: var(--serif); font-size: 26px; line-height: 1; }
.energy span { font-size: 11px; color: var(--muted); }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.bars i { width: 4px; border-radius: 1px; background: var(--line); display: block; }
.bars i.on { background: var(--yellow); }

/* ---------- daftar pemain ---------- */
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.people li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.people li.now { color: var(--yellow); }
.people .n { font-family: var(--serif); font-size: 18px; color: var(--dim); }
.people li.now .n { color: var(--yellow); }
.people .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .meta { font-size: 12px; color: var(--muted); text-align: right; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); margin-right: 8px; vertical-align: middle; }
.dot.on { background: #7fbf7a; }
.move { display: inline-flex; gap: 4px; }
.move button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-size: 14px; }

/* ---------- beranda ---------- */
.home { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(24px, 5vw, 80px); align-items: center; }
.home h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(54px, 9vw, 128px); line-height: .9; letter-spacing: -.01em; }
.home h1 i { font-weight: 500; }
.home .lede { font-family: var(--serif); font-size: clamp(20px, 2.2vw, 26px); color: var(--muted); max-width: 30ch; margin-top: 18px; line-height: 1.3; }
.forms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 36px; max-width: 640px; }
.panel { border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: rgba(27, 26, 24, .6); }
.fan { position: relative; height: clamp(300px, 46vw, 560px); }
.fan .card { position: absolute; left: 50%; top: 50%; --w: clamp(130px, 15vw, 210px); }
.history { margin-top: 28px; max-width: 640px; }
.history a { text-decoration: none; }

/* ---------- ringkasan ---------- */
.summary { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(20px, 4vw, 60px); align-items: start; }
.avg { font-family: var(--serif); font-size: clamp(88px, 13vw, 170px); line-height: .85; font-weight: 500; }
.avg small { font-size: .3em; color: var(--muted); }
.spread { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; }
.spread figure { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; }
.spread figcaption { min-width: 0; }
.spread figcaption b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spread figcaption span { font-size: 12px; color: var(--muted); display: block; }

/* ---------- meja (proyektor) ---------- */
.table { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(20px, 3vw, 48px); align-items: start; }
.big-turn { font-family: var(--serif); font-size: clamp(30px, 4vw, 60px); line-height: 1; }
.big-turn em { color: var(--yellow); }
.lobby-cta { font-family: var(--serif); font-size: clamp(28px, 4vw, 58px); line-height: 1.05; }
.lobby-cta strong { letter-spacing: .14em; font-weight: 600; }
.host-ctl { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.hide-ctl .host-ctl, .hide-ctl .ctl-only { display: none !important; }
.foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.note { font-size: 13px; color: var(--muted); max-width: 46ch; }

.log-dialog { width: min(640px, calc(100vw - 32px)); max-height: 80vh; padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); }
.log-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.log-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 12px; border-bottom: 1px solid var(--line); }
.log-head h2 { font-size: 28px; font-weight: 500; }
.log-list { list-style: none; margin: 0; padding: 8px 20px 20px; overflow-y: auto; max-height: calc(80vh - 100px); }
.log-list li { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-list time { color: var(--muted); font-variant-numeric: tabular-nums; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }

@media (max-width: 860px) {
  .home, .table, .summary { grid-template-columns: minmax(0, 1fr); }
  .fan { height: 300px; order: -1; }
  .forms { grid-template-columns: minmax(0, 1fr); }
  .reading { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .reading .text { width: 100%; }
  .table .side { order: 2; }
}
@media (max-width: 400px) {
  .energy button { min-height: 64px; }
  .energy span { font-size: 10px; }
  .code-chip strong { font-size: 22px; }
}

/* proyektor 1920px: huruf dan daftar lebih besar supaya terbaca dari belakang ruangan */
@media (min-width: 1600px) {
  body { font-size: 18px; }
  .label { font-size: 13px; }
  .people li { padding: 15px 0; }
  .people .n { font-size: 22px; }
  .table { grid-template-columns: 340px minmax(0, 1fr); }
  .ring-hint { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .card-in, .ring.anim, .slot, .btn { transition: none !important; }
  .reveal-in { animation: none; }
}
