:root {
  --navy: #1d2b6b;
  --navy-2: #13204f;
  --cream: #efe6d2;
  --cream-2: #e2d6bb;
  --ink: #1b1f33;
  --muted: #5b5a63;
  --teal: #17a88f;
  --teal-2: #0f7e6b;
  --ochre: #e7a63a;
  --red: #d6453a;
  --gray: #9a9a9a;
  --bevel-hi: #fffaf0;
  --bevel-lo: #8b7f66;
  --title: 'Silkscreen', ui-monospace, 'Courier New', monospace;
  --body: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--navy-2);
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-left: 4px solid var(--navy);
  border-right: 4px solid var(--navy);
  overflow: hidden;
}

/* ---------- chrome ---------- */

.titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--navy);
  color: #fff;
  padding: 6px 10px;
  flex: none;
}

.logo {
  font-family: var(--title);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 2px;
  white-space: nowrap;
}

.logo-emoji {
  font-family: system-ui, sans-serif;
  font-size: 18px;
  letter-spacing: 0;
  margin-right: 4px;
  vertical-align: 2px;
}

/* Timer di title bar: hanya tampil saat rapat, menggantikan logo */
.tb-timer {
  display: none;
  flex: 1;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.tb-timer i {
  font-style: normal;
  font-size: 16px;
  opacity: 0.8;
}

.tb-timer b {
  font-family: var(--title);
  font-size: 22px;
  letter-spacing: 2px;
}

.rapat .tb-timer {
  display: flex;
}

.rapat .logo,
.rapat .rec,
.rapat #btnMusik,
.rapat #btnSuara {
  display: none;
}

.rec {
  flex: 1;
  text-align: right;
  font-size: 13px;
  opacity: 0.9;
}

.rec {
  font-size: 12px;
  line-height: 1.2;
}

.rec .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #3ee07a;
  box-shadow: 0 0 0 2px rgba(62, 224, 122, 0.25);
  vertical-align: 1px;
}

.rec:not(.on) {
  visibility: hidden;
}

.icon-btn.off {
  opacity: 0.45;
  text-decoration: line-through;
}

.icon-btn {
  min-width: 36px;
  height: 36px;
  font-size: 18px;
  background: var(--cream);
  border: 2px solid;
  border-color: var(--bevel-hi) var(--bevel-lo) var(--bevel-lo) var(--bevel-hi);
  cursor: pointer;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
}

.panel {
  background: #fbf6ea;
  border: 2px solid;
  border-color: var(--bevel-hi) var(--bevel-lo) var(--bevel-lo) var(--bevel-hi);
  padding: 12px;
}

.row {
  display: flex;
  gap: 8px;
}

.row > .btn {
  flex: 1;
}

.btn {
  font-family: var(--title);
  font-size: 15px;
  letter-spacing: 1px;
  min-height: 48px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--cream-2);
  border: 3px solid;
  border-color: var(--bevel-hi) var(--bevel-lo) var(--bevel-lo) var(--bevel-hi);
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active {
  border-color: var(--bevel-lo) var(--bevel-hi) var(--bevel-hi) var(--bevel-lo);
}

.btn.primary {
  background: var(--teal);
  color: #fff;
  border-color: #6fe0cb var(--teal-2) var(--teal-2) #6fe0cb;
}

.btn.big {
  font-size: 20px;
  min-height: 56px;
  width: 100%;
}

.btn.wa {
  background: #25d366;
  color: #08331b;
}

.btn.ghost {
  background: transparent;
  border: none;
  text-decoration: underline;
  min-height: 40px;
}

/* ---------- menu ---------- */

.hero {
  position: relative;
  border: 3px solid var(--navy);
  overflow: hidden;
  flex: none;
  background: var(--navy);
}

.hero-img {
  width: 100%;
  aspect-ratio: 3 / 2;
  display: block;
  image-rendering: pixelated;
}

.hero-text {
  padding: 8px 12px;
  color: #fff;
  text-align: center;
}

.hero-text p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

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

.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  font-size: 14px;
}

.form small {
  font-weight: 400;
  color: var(--muted);
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 700;
  font-size: 13px;
}

.form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-weight: 700;
  font-size: 14px;
}

.seg {
  display: flex;
}

.seg-btn {
  flex: 1;
  font-family: var(--title);
  font-size: 13px;
  letter-spacing: 1px;
  min-height: 44px;
  background: var(--cream-2);
  color: var(--ink);
  border: 2px solid var(--bevel-lo);
  cursor: pointer;
  touch-action: manipulation;
}

.seg-btn + .seg-btn {
  border-left: none;
}

.seg-btn[aria-pressed='true'] {
  background: var(--navy);
  color: #fff;
}

.form .field > label {
  font-weight: 700;
  font-size: 14px;
}

.input-row {
  display: flex;
  gap: 6px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.icon-btn.dice {
  min-width: 48px;
  height: auto;
  font-size: 22px;
}

.form input {
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border: 2px solid;
  border-color: var(--bevel-lo) var(--bevel-hi) var(--bevel-hi) var(--bevel-lo);
  background: #fff;
}

.modal h2 {
  font-family: var(--title);
  margin: 0 0 8px;
}

/* ---------- papan skor ---------- */

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 8px 4px;
  min-height: 44px;
  background: var(--cream-2);
  border: 2px solid var(--bevel-lo);
  cursor: pointer;
}

.tab.active {
  background: var(--navy);
  color: #fff;
}

.mini-board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}

.mini-title {
  font-family: var(--title);
  font-size: 15px;
  letter-spacing: 1px;
  margin: 0;
}

.mini-board .btn {
  font-size: 13px;
}

.board-note {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
}

.board-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
}

.board-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 6px;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--cream-2);
}

/* Baris pesan ("Memuat…", "Belum ada skor") memakai lebar penuh, bukan kolom nomor peringkat. */
.board-list li.pesan {
  display: block;
  color: var(--muted);
  text-align: center;
}

.board-list li.me {
  background: #d9f3ec;
}

.board-list .pos {
  font-weight: 700;
}

.board-list .mahkota {
  height: 1.15em;
  width: auto;
  margin-right: 6px;
  vertical-align: -0.2em;
}

.board-list .nm small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.board-list .sc {
  font-weight: 700;
  text-align: right;
}

/* ---------- game ---------- */

.game {
  position: relative;
  gap: 6px;
  padding: 6px;
  overflow: hidden;
}

.status {
  display: flex;
  gap: 6px;
  flex: none;
}

.stat {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  background: var(--navy);
  color: #fff;
  padding: 4px 6px;
  font-size: 13px;
}

.stat i {
  font-style: normal;
  white-space: nowrap;
  opacity: 0.75;
  font-size: 11px;
}

.stat b {
  font-family: var(--title);
  font-size: 17px;
}

.stat em {
  font-style: normal;
  color: var(--ochre);
  font-weight: 700;
}

.combo.hot {
  background: var(--teal-2);
}

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 6px;
}

.tile {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--navy-2);
  border: 3px solid var(--bevel-lo);
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.06s;
}

.tile:active {
  transform: scale(0.97);
}

.tile.adit {
  cursor: default;
  border-color: var(--teal);
}

.tile.adit:active {
  transform: none;
}

.tile.z-hijau {
  border-color: var(--teal);
}

.tile.z-pas {
  border-color: var(--ochre);
  box-shadow: inset 0 0 0 2px var(--ochre);
}

.tile.z-merah {
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px var(--red);
}

.tile.genz {
  border-color: #6b8fa8;
  box-shadow: none;
}

.cam {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cam img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  image-rendering: pixelated;
  pointer-events: none;
}

.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.placeholder .face {
  font-size: clamp(28px, 9vw, 52px);
  line-height: 1;
}

.placeholder .mood {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 20px;
}

.placeholder .tag {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
}

.cam.off {
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7d0ff;
  font-size: 12px;
  text-align: center;
}

.meta {
  flex: none;
  background: var(--cream);
  padding: 3px 5px 4px;
}

.nm-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}

.nm-row .pct {
  font-family: var(--title);
}

.key {
  display: inline-block;
  min-width: 14px;
  padding: 0 3px;
  margin-right: 3px;
  background: var(--navy);
  color: #fff;
  font-size: 10px;
  text-align: center;
}

.bar {
  position: relative;
  height: 10px;
  margin-top: 2px;
  background: #cfc6b0;
  border: 1px solid var(--bevel-lo);
  overflow: hidden;
}

.bar .band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(231, 166, 58, 0.35);
}

.bar .band.mepet {
  background: rgba(231, 166, 58, 0.6);
}

.bar .fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--teal);
}

.z-pas .bar .fill {
  background: var(--ochre);
}

.z-merah .bar .fill {
  background: var(--red);
}

.genz .bar .fill {
  background: #6b8fa8;
}

.adit .bar .fill {
  background: #c45bd0;
}

.adit .bar.hot .fill {
  background: var(--red);
}

.bubble {
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  background: #fff;
  border: 2px solid var(--ink);
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.3;
  pointer-events: none;
  animation: pop 0.15s ease-out;
}

.pop {
  position: absolute;
  left: 50%;
  top: 35%;
  transform: translateX(-50%);
  font-family: var(--title);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  color: #fff;
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink);
  pointer-events: none;
  animation: rise 0.9s ease-out forwards;
}

.pop.pas {
  color: #ffe08a;
}

.pop.mepet {
  color: #ffb347;
  font-size: 19px;
}

.pop.cepat,
.pop.genz {
  color: #ff8a80;
}

.badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--ochre);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
}

.badge.anti {
  background: #6b8fa8;
  color: #fff;
}

.grid.padat .nm-row {
  font-size: 10px;
}

.grid.padat .key {
  display: none;
}

.badge.sapa {
  background: var(--red);
  color: #fff;
  animation: blink 0.6s steps(2) infinite;
}

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(214, 69, 58, 0.55);
  color: #fff;
  font-family: var(--title);
  font-size: 15px;
  text-align: center;
  pointer-events: none;
}

.dialog {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff;
  border: 2px solid var(--navy);
  padding: 6px 8px;
  min-height: 52px;
}

.dialog .who {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  font-weight: 700;
}

.dialog p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dialog.izin p {
  font-weight: 700;
  color: var(--teal-2);
}

.hintbar {
  flex: none;
  min-height: 18px;
  font-size: 12px;
  text-align: center;
  color: var(--navy);
  font-weight: 700;
}

.bomb {
  position: relative;
  flex: none;
  min-height: 58px;
  overflow: hidden;
  background: var(--red);
  color: #fff;
  border-color: #ff9a8f #8c2219 #8c2219 #ff9a8f;
  font-size: 16px;
}

.bomb:disabled {
  background: #b8b2a3;
  color: #4b4b4b;
  border-color: var(--bevel-hi) var(--bevel-lo) var(--bevel-lo) var(--bevel-hi);
  cursor: default;
}

.bomb-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.bomb-label {
  position: relative;
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(19, 32, 79, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 10;
}

.overlay.start {
  background: var(--navy-2);
  z-index: 20;
}

.start-card {
  font: inherit;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.start-logo {
  font-family: var(--title);
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 6px;
}

.start-logo .logo-emoji {
  font-size: 40px;
  vertical-align: 8px;
}

.start-sub {
  font-size: 14px;
  opacity: 0.85;
  text-align: center;
}

.start-cta {
  font-family: var(--title);
  font-size: 18px;
  margin-top: 18px;
  padding: 12px 18px;
  background: var(--teal);
  border: 3px solid;
  border-color: #6fe0cb var(--teal-2) var(--teal-2) #6fe0cb;
}

.start-note {
  font-size: 12px;
  opacity: 0.7;
}

/* Sarung tangan putih yang menunjuk tombol saat pemain diam. */
.start-card {
  position: relative;
}

.glove {
  position: absolute;
  width: 54px;
  height: 60px;
  pointer-events: none;
  animation: tunjuk 0.7s ease-in-out infinite alternate;
}

.glove svg {
  width: 100%;
  height: 100%;
  display: block;
  shape-rendering: crispEdges;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.35));
}

@keyframes tunjuk {
  from {
    transform: translate(0, 0) rotate(-28deg);
  }
  to {
    transform: translate(-7px, -9px) rotate(-28deg);
  }
}

/* ---------- tutorial ---------- */

/* Lapisan tutorial di atas layar rapat (di bawah title bar). Tembus sentuhan kecuali kartunya, supaya peserta yang disorot
   bisa di-tap; kelas .blok menahan sentuhan saat menunggu LANJUT. */
.tutor {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.tutor.blok {
  pointer-events: auto;
  cursor: pointer;
}

.tutor.gelap {
  background: rgba(19, 32, 79, 0.72);
}

.tutor-sorot {
  position: absolute;
  border: 3px solid var(--ochre);
  box-shadow: 0 0 0 9999px rgba(19, 32, 79, 0.72);
  pointer-events: none;
  transition:
    left 0.2s,
    top 0.2s,
    width 0.2s,
    height 0.2s;
  animation: sorot 0.9s ease-in-out infinite alternate;
}

@keyframes sorot {
  to {
    border-color: #fff3c4;
  }
}

.tutor-glove {
  z-index: 1;
}

.tutor-kartu {
  position: absolute;
  left: 12px;
  right: 12px;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 3px solid var(--navy);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: default;
  animation: pop 0.15s ease-out;
}

.tutor-kartu h3 {
  font-family: var(--title);
  font-size: 17px;
  margin: 0;
  color: var(--navy);
}

.tutor-kartu p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.tutor-aksi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tutor-aksi .btn.ghost {
  font-size: 12px;
  min-height: 40px;
  padding: 4px 0;
  color: var(--muted);
}

.tutor-aksi .btn.primary {
  min-width: 140px;
}

.tutor-tap {
  font-family: var(--title);
  font-size: 13px;
  color: var(--red);
  animation: blink 0.8s steps(2) infinite;
}

.tutor-poin {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.tutor-nama {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  font-size: 14px;
}

.tutor-nama input {
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border: 2px solid;
  border-color: var(--bevel-lo) var(--bevel-hi) var(--bevel-hi) var(--bevel-lo);
  background: #fff;
}

.modal {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal p {
  margin: 0;
}

.btn.toggle {
  font-size: 13px;
  white-space: nowrap;
}

.btn.toggle b {
  color: var(--teal-2);
}

.btn.toggle[aria-pressed='false'] {
  opacity: 0.7;
}

.btn.toggle[aria-pressed='false'] b {
  color: var(--red);
}

/* Kartu hasil: ringkas, mirip gambar yang dibagikan. */
.result {
  gap: 8px;
}

.kartu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  background: var(--cream);
  border: 2px solid var(--bevel-lo);
}

.kartu-foto {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 34vh;
  background: var(--navy-2);
  overflow: hidden;
}

.kartu-foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  image-rendering: pixelated;
  display: block;
}

.result .kartu-alasan {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 4px 8px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  text-align: center;
  text-transform: uppercase;
}

.kartu-rekor {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  font-family: var(--title);
  font-size: 12px;
  font-weight: 700;
  background: var(--ochre);
  color: var(--ink);
  border: 2px solid;
  border-color: #ffd98a #9c6a14 #9c6a14 #ffd98a;
  transform: rotate(6deg);
}

.kartu-jabatan {
  margin-top: 4px;
  font-family: var(--title);
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--ochre);
  padding: 2px 12px;
}

.bigscore {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: center;
}

.bigscore span {
  font-family: var(--title);
  font-size: 44px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.kartu-stat {
  margin: 0;
  font-size: 13px;
  text-align: center;
}

.rank {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  min-height: 1.3em;
}

.btn.ig {
  background: linear-gradient(45deg, #c92a6e, #b02a8a 50%, #7a35b0);
  color: #fff;
  border-color: #f7b3c8 #7a1f45 #7a1f45 #f7b3c8;
}

.row.share .btn {
  font-size: 14px;
  padding: 8px 6px;
}

.row.links {
  justify-content: center;
}

.row.links .btn {
  flex: 0 1 auto;
  font-size: 13px;
  min-height: 36px;
}

.gambar img {
  display: block;
  max-height: 55vh;
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid var(--bevel-lo);
}

.gambar .btn {
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gambar .btn.ghost {
  text-decoration: underline;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@keyframes rise {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -36px);
  }
}

@keyframes pop {
  from {
    transform: scale(0.6);
  }
  to {
    transform: scale(1);
  }
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

@keyframes shake {
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

.shake {
  animation: shake 0.2s linear;
}

@media (prefers-reduced-motion: reduce) {
  .glove,
  .tutor-sorot,
  .tutor-kartu,
  .tutor-tap,
  .pop,
  .bubble,
  .badge.sapa,
  .shake {
    animation: none;
  }
}

.gambar h2 {
  font-size: 18px;
}
