/* games.css — lapisan minigame WIZPAW (Modul D).
   Bingkai memakai token base.css; warna di dalam kanvas digambar oleh JS. */

.wg-root {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--night-solid) 42%, transparent);
  backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15);
  font-family: var(--font-ui); color: var(--night-ink);
  animation: wg-fade .32s var(--ease);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.wg-root.wg-out { animation: wg-fade-out .2s ease forwards; }
@keyframes wg-fade { from { opacity: 0; } }
@keyframes wg-fade-out { to { opacity: 0; } }

.wg-frame {
  position: relative; display: flex; flex-direction: column;
  width: min(1240px, 100%); height: min(800px, 100%);
  background: var(--night); border: 1px solid var(--night-line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-night), 0 0 0 1px color-mix(in srgb, var(--violet-light) 10%, transparent), 0 40px 120px -40px color-mix(in srgb, var(--violet) 45%, transparent);
  overflow: hidden;
  animation: wg-rise .42s var(--ease);
}
@keyframes wg-rise { from { transform: translateY(14px) scale(.985); opacity: 0; } }

/* ---------- kepala ---------- */
.wg-head { display: flex; align-items: center; gap: 18px; padding: 12px 14px 12px 20px; min-height: 64px; }
.wg-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; margin-right: auto; }
.wg-eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--violet-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-name { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.01em; line-height: 1.1; }
.wg-stats { display: flex; gap: 22px; }
.wg-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 54px; }
.wg-stat-l { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--night-ink-2); }
.wg-stat-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 19px; color: var(--night-ink); white-space: nowrap; }
.wg-clock { display: flex; align-items: center; justify-content: center; min-width: 76px; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--night-line); background: color-mix(in srgb, var(--night-solid) 60%, transparent); }
.wg-clock-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 18px; color: var(--lantern); }
.wg-low .wg-clock { border-color: color-mix(in srgb, var(--ember) 60%, transparent); }
.wg-low .wg-clock-v { color: var(--ember); animation: wg-beat 1s ease-in-out infinite; }
@keyframes wg-beat { 50% { opacity: .55; } }
.wg-ico {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0;
  border-radius: 50%; border: 1px solid var(--night-line); background: transparent; color: var(--night-ink-2); cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.wg-ico svg { width: 20px; height: 20px; }
.wg-ico:hover { color: var(--night-ink); border-color: color-mix(in srgb, var(--violet-light) 55%, transparent); background: color-mix(in srgb, var(--violet) 14%, transparent); }
.wg-ico:focus-visible { outline: 2px solid var(--violet-light); outline-offset: 2px; }
.wg-snd.off { color: var(--ink-3); }

.wg-bar { height: 3px; background: var(--night-line); }
.wg-bar i { display: block; height: 100%; transform-origin: left; background: linear-gradient(90deg, var(--violet-light), var(--lantern)); transition: transform .12s linear; }
.wg-low .wg-bar i { background: linear-gradient(90deg, var(--ember), var(--lantern)); }

/* ---------- panggung ---------- */
.wg-stage { position: relative; flex: 1; min-height: 0; background: var(--night-solid); overflow: hidden; }
.wg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.wg-layer { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.wg-layer[hidden] { display: none; }
.wg-rules, .wg-result { pointer-events: auto; background: color-mix(in srgb, var(--night-solid) 38%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

.wg-card {
  position: relative; width: min(460px, 100%);
  background: color-mix(in srgb, var(--night-2) 86%, transparent);
  border: 1px solid var(--night-line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-night), inset 0 1px 0 color-mix(in srgb, var(--night-ink) 8%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: wg-rise .38s var(--ease);
}
.wg-h { margin: 4px 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -0.015em; line-height: 1.1; color: var(--night-ink); }
.wg-p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--night-ink-2); }

/* kartu aturan */
.wg-rules-card { display: flex; flex-direction: column; overflow: hidden; }
.wg-illu { display: block; width: 100%; height: 150px; background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--violet) 22%, transparent), transparent 70%); border-bottom: 1px solid var(--night-line); }
.wg-rules-body { padding: 18px 22px 22px; display: flex; flex-direction: column; align-items: flex-start; }
.wg-controls { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 18px; }
.wg-ctl { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; color: var(--night-ink-2); }
.wg-ctl b { color: var(--night-ink); font-weight: 800; }
.wg-start { min-height: 46px; padding: 0 22px; font-size: 16px; }
.wg-start .key, .wg-close .key { background: color-mix(in srgb, var(--night-ink) 22%, transparent); box-shadow: none; }

/* hitung mundur & spanduk */
.wg-count-n, .wg-banner-t {
  font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; line-height: 1;
  color: var(--night-ink); text-shadow: 0 0 40px color-mix(in srgb, var(--violet) 90%, transparent), 0 4px 30px rgba(0,0,0,.5);
}
.wg-count-n { font-size: clamp(90px, 22vh, 180px); }
.wg-banner-t { font-size: clamp(48px, 12vh, 96px); color: var(--lantern); text-shadow: 0 0 40px color-mix(in srgb, var(--lantern) 60%, transparent), 0 4px 30px rgba(0,0,0,.5); }
.pop { animation: wg-pop .72s var(--ease) both; }
@keyframes wg-pop { 0% { transform: scale(1.7); opacity: 0; } 22% { transform: scale(1); opacity: 1; } 78% { opacity: 1; } 100% { transform: scale(.92); opacity: 0; } }
.wg-banner-t.pop { animation: wg-pop-stay .6s var(--ease) both; }
@keyframes wg-pop-stay { 0% { transform: scale(1.5); opacity: 0; } 40% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* kartu hasil */
.wg-result-card { width: min(520px, 100%); padding: 24px 26px 22px; display: flex; flex-direction: column; gap: 14px; }
.wg-result-main { display: flex; flex-direction: column; align-items: center; text-align: center; }
.wg-result-main .wg-h { margin: 6px 0 4px; }
.wg-score { display: flex; align-items: baseline; gap: 4px; margin: 2px 0 6px; }
.wg-score-n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 64px; line-height: 1; color: var(--night-ink); }
.wg-score-of { font-family: var(--font-mono); font-size: 18px; color: var(--night-ink-2); }
.wg-stars { display: flex; gap: 10px; }
.wg-stars svg { width: 34px; height: 34px; fill: color-mix(in srgb, var(--night-ink) 12%, transparent); transition: fill .2s; }
.wg-stars svg.on { fill: var(--lantern); filter: drop-shadow(0 0 10px color-mix(in srgb, var(--lantern) 70%, transparent)); }
.wg-stars svg.pop { animation: wg-star .5s var(--ease); }
@keyframes wg-star { 0% { transform: scale(.4) rotate(-30deg); } 60% { transform: scale(1.25) rotate(6deg); } 100% { transform: none; } }
.wg-result-side { display: flex; flex-direction: column; gap: 14px; }
.wg-lines { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--night-line); border: 1px solid var(--night-line); border-radius: var(--r); overflow: hidden; }
.wg-lines > div { background: color-mix(in srgb, var(--night-solid) 70%, transparent); padding: 9px 12px; }
.wg-lines > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.wg-lines dt { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--night-ink-2); }
.wg-lines dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 16px; color: var(--night-ink); }
.wg-marks { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--night-ink-2); border: 1px dashed var(--night-line); }
.wg-marks.on { border: 1px solid color-mix(in srgb, var(--lantern) 40%, transparent); background: color-mix(in srgb, var(--lantern) 12%, transparent); color: var(--night-ink-2); animation: wg-glow 1.6s ease-in-out .6s 2; }
.wg-marks b { font-size: 16px; font-weight: 900; color: var(--lantern); }
.wg-mark-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lantern); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lantern) 25%, transparent); }
@keyframes wg-glow { 50% { box-shadow: 0 0 24px -2px color-mix(in srgb, var(--lantern) 55%, transparent); } }
.wg-actions { display: flex; gap: 10px; }
.wg-actions .btn { flex: 1; min-height: 46px; }

/* kaki: petunjuk kontrol */
.wg-foot { display: flex; align-items: center; justify-content: center; gap: 22px; min-height: 40px; padding: 0 16px; border-top: 1px solid var(--night-line); }
.wg-foot .wg-ctl { font-size: 12.5px; }
.wg-foot-esc { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--night-ink-2); }
.wg-foot-esc:empty { display: none; }

/* ---------- layar pendek (HP lanskap) ---------- */
@media (max-height: 520px) {
  .wg-root { padding: 6px; }
  .wg-frame { width: 100%; height: 100%; border-radius: 14px; }
  .wg-head { min-height: 44px; padding: 5px 8px 5px 14px; gap: 12px; }
  .wg-eyebrow { font-size: 9.5px; letter-spacing: .12em; }
  .wg-name { font-size: 17px; }
  .wg-stats { gap: 14px; }
  .wg-stat { min-width: 0; }
  .wg-stat-l { font-size: 9px; }
  .wg-stat-v { font-size: 15px; }
  .wg-clock { height: 32px; min-width: 60px; padding: 0 9px; }
  .wg-clock-v { font-size: 15px; }
  .wg-ico { width: 34px; height: 34px; }
  .wg-ico svg { width: 18px; height: 18px; }
  .wg-foot { display: none; }
  .wg-layer { padding: 8px; }
  .wg-rules-card { flex-direction: row; width: min(640px, 100%); }
  .wg-illu { width: 42%; height: auto; min-height: 150px; border-bottom: 0; border-right: 1px solid var(--night-line); }
  .wg-rules-body { flex: 1; padding: 14px 18px 16px; }
  .wg-h { font-size: 22px; }
  .wg-p { font-size: 13.5px; line-height: 1.42; }
  .wg-controls { margin: 8px 0 12px; }
  .wg-start { min-height: 40px; }
  .wg-result-card { flex-direction: row; align-items: center; width: min(660px, 100%); padding: 14px 18px; gap: 18px; }
  .wg-result-main { flex: 0 0 38%; }
  .wg-score-n { font-size: 50px; }
  .wg-stars svg { width: 26px; height: 26px; }
  .wg-result-side { flex: 1; gap: 10px; }
  .wg-lines > div { padding: 6px 10px; }
  .wg-lines dd { font-size: 14px; }
  .wg-marks { min-height: 34px; }
  .wg-actions .btn { min-height: 40px; }
}
@media (max-width: 640px) {
  .wg-stats .wg-stat:nth-child(n+3) { display: none; }
  .wg-eyebrow { max-width: 46vw; }
}
@media (prefers-reduced-motion: reduce) {
  .wg-root, .wg-frame, .wg-card { animation: none; }
}

/* ---------- kulit Observatory Brass (hanya bingkai & kartu; kanvas permainan tidak disentuh) ---------- */
.wg-frame {
  border: 9px solid transparent; border-radius: 10px;
  background:
    var(--enamel-night) padding-box,
    linear-gradient(135deg, #f8e2a2 0%, #c99a45 18%, #8a611e 34%, #e8c777 52%, #a5762a 70%, #f2d48a 86%, #8a611e 100%) border-box;
  box-shadow: 0 0 0 1px #3a2708, inset 0 0 0 1px #3a2708, inset 0 0 0 2.5px rgba(255, 236, 180, .45), 0 40px 80px -30px rgba(0, 0, 0, .8);
}
.wg-eyebrow { color: #e9c977; }
.wg-name { color: #fff7e2; }
.wg-stat-l { color: rgba(233, 225, 255, .6); }
.wg-clock { border-color: rgba(231, 197, 116, .55); background: rgba(20, 14, 46, .6); box-shadow: inset 0 0 0 1px rgba(60, 40, 8, .6); }
.wg-clock-v { color: #f2d48a; }
.wg-ico { position: relative; border: 0; color: #4a3210; background: var(--brass-ring); box-shadow: 0 0 0 1px #3a2708, 0 3px 6px -2px rgba(0, 0, 0, .6); }
.wg-ico::after { content: ''; position: absolute; inset: 3.5px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #3c2d8c, #1d1650); box-shadow: inset 0 0 0 1px #3a2708; }
.wg-ico svg { position: relative; z-index: 1; color: #f2d48a; }
.wg-ico:hover { background: var(--brass-ring); border: 0; }
.wg-ico:hover svg { color: #fff7e2; }
.wg-bar { background: rgba(231, 197, 116, .18); }
.wg-bar i { background: linear-gradient(90deg, #a8792c, #f2d48a); }
.wg-card { border: 0; border-radius: 6px; background: color-mix(in srgb, #1b1540 92%, transparent);
  box-shadow: 0 0 0 1px #3a2708, 0 0 0 3.5px #c99a45, 0 0 0 4.5px #6f4c14, 0 24px 50px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(200, 185, 255, .15); }
.wg-h { color: #fff7e2; }
.wg-illu { border-bottom-color: rgba(231, 197, 116, .35); }
.wg-lines { border-color: rgba(231, 197, 116, .3); background: rgba(231, 197, 116, .3); border-radius: 4px; }
.wg-lines dt { color: #e9c977; font-family: var(--font-mono); font-weight: 500; letter-spacing: .14em; font-size: 10px; }
.wg-root .btn-primary { background: var(--enamel); color: #fff; border: 0; box-shadow: inset 0 1px 0 rgba(210, 195, 255, .45), 0 0 0 1px #2a1c6a, 0 0 0 2.5px #e2bd6b, 0 0 0 3.5px #6f4c14; }
.wg-root .btn-primary:hover { background: var(--enamel); filter: brightness(1.12); }
