
:root {
  --ink: #2c241b;
  --ink-light: #52473a;
  --paper: #f4edd8;
  --paper-dark: #e8dcc4;
  --accent-gold: #b38b4d;
  --accent-red: #8b3a3a;
  --border-color: #3b3127;
  --border-light: rgba(44, 36, 27, 0.2);
  --shadow-color: rgba(44, 36, 27, 0.2);
  --alert: #a83232;
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh;
  background-color: var(--paper);
  background-image: 
    linear-gradient(rgba(44, 36, 27, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44, 36, 27, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  font-family: 'Courier Prime', monospace;
  color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  padding: 50px 16px 60px;
  overflow-x: hidden;
}

/* Vintage Noise & Vignette Overlays — dimatiin, bikin noise-noise di kamera. Div-nya masih ada
   di HTML tapi CSS-nya di-nolkan di sini biar ga perlu ngubek2 tiap file .html satu-satu. */
.film-grain {
  display: none;
}

.vignette-overlay {
  display: none;
}

.camera-flash {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: #fff; z-index: 10000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease-out;
}
.camera-flash.firing { opacity: 1; transition: none; }

/* Typography */
h1, h2, h3, h4, .title { font-family: 'Playfair Display', serif; margin: 0; font-weight: 700;}
.sys-text { font-size: 11px; font-weight: bold; letter-spacing: 1px; color: var(--ink-light);}
.text-alert { color: var(--alert); }

.brand { display: flex; align-items: center; gap: 15px; margin-bottom: 5px; }
.brand-icon { font-size: 32px; color: var(--ink); }
.brand h1 { font-size: 42px; color: var(--ink); letter-spacing: 1px;}
.tag { font-size: 12px; font-weight: bold; letter-spacing: 2px; margin-bottom: 35px; color: var(--ink-light); border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 5px 0;}

/* Vintage Panels */
.vintage-panel {
  background: var(--paper-dark);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  width: 100%; max-width: 850px;
  box-shadow: 6px 6px 0px var(--shadow-color);
  position: relative; z-index: 10;
  margin-bottom: 20px;
}
.panel-header {
  background: var(--border-color); color: var(--paper);
  padding: 10px 15px; font-family: 'Courier Prime', monospace; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 2px solid var(--border-color);
}
.panel-header .dots { font-size: 8px; letter-spacing: 2px; opacity: 0.7;}
.card-body { padding: 30px; background: var(--paper); border-radius: 0 0 4px 4px;}

#lobby .row { display: flex; gap: 20px; flex-wrap: wrap; }
.solo-divider { display: flex; align-items: center; text-align: center; padding: 0 30px; background: var(--paper); }
.solo-divider::before, .solo-divider::after { content: ''; flex: 1; border-bottom: 1px dashed var(--border-light); }
.solo-divider span { padding: 0 14px; font-size: 11px; font-weight: bold; letter-spacing: 2px; color: var(--ink-light); }
#lobby .card-body:nth-of-type(2) { border-radius: 0; padding-bottom: 0; }
#lobby .card-body:last-of-type { border-radius: 0 0 4px 4px; }
.pane { flex: 1; min-width: 260px; border: 1px solid var(--border-light); border-radius: 4px; padding: 25px; background: rgba(255,255,255,0.4); display: flex; flex-direction: column; position: relative; }
.pane h3 { font-size: 18px; color: var(--ink); letter-spacing: 1px; margin-bottom: 12px;}
.pane p { font-size: 13px; line-height: 1.6; color: var(--ink-light); margin: 0 0 25px; flex-grow: 1; }

input[type=text] { width: 100%; padding: 14px 16px; border-radius: 4px; border: 1px dashed var(--border-color); background: rgba(255,255,255,0.6); color: var(--ink); font-family: 'Courier Prime', monospace; font-weight:bold; font-size: 16px; letter-spacing: 3px; text-align: center; text-transform: uppercase; margin-bottom: 15px; outline: none; transition: all 0.3s;}
input[type=text]:focus { border: 1px solid var(--border-color); background: #fff; box-shadow: inset 2px 2px 5px rgba(0,0,0,0.05); }

/* Classic Buttons */
.btn-vintage { font-size: 13px; border-radius: 4px; padding: 14px 20px; cursor: pointer; font-family: 'Courier Prime', monospace; font-weight: bold; letter-spacing: 1px; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px;}
.btn-vintage:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; transform: translateY(2px); box-shadow: none !important;}
.btn-vintage:active:not(:disabled) { transform: translateY(2px); box-shadow: none !important; }

.btn-primary { background: var(--border-color); color: var(--paper); border: 2px solid var(--border-color); box-shadow: 3px 3px 0px var(--shadow-color);}
.btn-primary:hover:not(:disabled) { background: var(--ink); }

.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: rgba(0,0,0,0.05); }

.pulse-anim { animation: btnPulse 2s infinite alternate; }
@keyframes btnPulse { 0% { box-shadow: 3px 3px 0px var(--shadow-color); } 100% { box-shadow: 5px 5px 0px rgba(44, 36, 27, 0.4); } }

.code-badge { font-weight: bold; border-bottom: 1px solid var(--border-light); padding-bottom: 5px;}
.code-chip { color: var(--accent-red); font-size: 16px; letter-spacing: 2px; margin-left: 5px; font-weight: bold;}

.status-wrap { display: flex; align-items: center; font-weight: bold; font-size: 12px; color: var(--ink-light);}
.status-dot { display: inline-block; width: 10px; height: 10px; background: #999; margin-right: 8px; border-radius: 50%; border: 1px solid var(--border-color);}
.status-dot.on { background: #5a8250; }
.blink-smooth { animation: blinker 1.5s ease-in-out infinite alternate; }
@keyframes blinker { 0% { opacity: 1; } 100% { opacity: 0.4; } }

#room { display: none; }
.room-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; border-bottom: 2px solid var(--border-light); padding-bottom: 15px; }

/* Stage Video - Classic Viewfinder */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  border: 4px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 4px 4px 0px var(--shadow-color);
  margin-bottom: 15px;
  touch-action: none;
}
.camera-corner { position: absolute; width: 30px; height: 30px; border: 2px solid rgba(255,255,255,0.4); z-index: 10; pointer-events: none;}
.top-left { top: 15px; left: 15px; border-right: none; border-bottom: none; }
.top-right { top: 15px; right: 15px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 15px; left: 15px; border-right: none; border-top: none; }
.bottom-right { bottom: 15px; right: 15px; border-left: none; border-top: none; }

.rec-indicator { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #d64040; font-size: 12px; font-weight: bold; z-index: 10; letter-spacing: 2px; text-shadow: 0 0 5px rgba(214,64,64,0.8); animation: blinker 1s linear infinite;}

/* Kamera tetap clear */
#bgVideoView { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* CUTOUT WRAP & CANVAS */
.cutout-wrap { 
  position: absolute; 
  touch-action: none;
  transform-origin: 0 0;
  top: 0; left: 0;
  z-index: 11;
}

#cutCanvas { 
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(5px 5px 10px rgba(0,0,0,0.6));
}

.cutout-wrap:not(.locked) { cursor: grab; }
.cutout-wrap:not(.locked):active { cursor: grabbing; }
.cutout-wrap.locked { cursor: default; }
.cutout-wrap.locked .handle { display: none; }

.handle { 
  position: absolute; 
  width: 30px; height: 30px; 
  background: var(--paper); 
  border-radius: 50%; border: 2px solid var(--ink); 
  right: -15px; bottom: -15px; 
  cursor: nwse-resize; 
  box-shadow: 2px 2px 5px rgba(0,0,0,0.5); 
  touch-action: none; 
  display: flex; align-items: center; justify-content: center; color: var(--ink); font-size: 12px;
}
.handle:hover { transform: scale(1.1); background: #fff; }

.badge { position: absolute; top: 20px; font-size: 10px; padding: 4px 10px; border-radius: 2px; z-index: 10; font-family: 'Courier Prime', monospace; font-weight: bold; letter-spacing: 1px; border: 1px solid rgba(255,255,255,0.4); background: rgba(0,0,0,0.6); color: #fff;}
.badge-me { left: 20px; }
.badge-peer { background: rgba(44, 36, 27, 0.8); border-color: var(--accent-gold); color: var(--paper);}

.waiting { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; color: #fff; background: rgba(0,0,0,0.8); text-align: center; z-index: 20; letter-spacing: 2px;}

/* PIP (desktop/tablet) */
#selfPipVideo { 
  position: absolute; left: 20px; bottom: 20px; 
  width: 100px; height: 75px; 
  object-fit: cover; border-radius: 4px; 
  border: 2px solid #fff; 
  transform: scaleX(-1); z-index: 5; background: #000; 
  box-shadow: 4px 4px 10px rgba(0,0,0,0.6); 
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#selfPipVideo:hover { border-color: var(--accent-gold); }
#selfPipVideo.expanded { width: 220px; height: 165px; border-width: 3px; }

.pip-label { 
  position: absolute; left: 20px; bottom: 100px; 
  font-size: 10px; font-weight: bold; color: #000; background: #fff; 
  padding: 3px 8px; border-radius: 2px; z-index: 5; 
  box-shadow: 2px 2px 5px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transform: translateY(5px);
  transition: all 0.3s ease;
}
.pip-label.expanded { opacity: 1; transform: translateY(0); }

/* PIP for mobile */
@media (max-width: 600px) {
  #selfPipVideo { width: 60px; height: 45px; left: 10px; bottom: 10px; border-width: 1px;}
  #selfPipVideo.expanded { width: 160px; height: 120px; border-width: 2px;}
  .pip-label { bottom: 65px; left: 10px; font-size: 8px; padding: 2px 5px; }
  .pip-label.expanded { bottom: 140px; }
  .countdown { font-size: 80px; }
  .pc-only-handle { display: none !important; }
}

.mode-bar, .filter-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; background: rgba(0,0,0,0.03); padding: 12px 16px; border-radius: 4px; border: 1px solid var(--border-light); }
.seg-toggle, .bg-toggle { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 11px;}
.mode-btn { font-size: 11px; border: 1px solid var(--border-color); background: transparent; color: var(--ink); padding: 8px 12px; font-family: 'Courier Prime', monospace; font-weight: bold; border-radius: 4px; cursor: pointer; transition: all 0.2s;}
.mode-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mode-btn.small { padding: 5px 10px; }
.mode-btn.active { background: var(--border-color); color: var(--paper); box-shadow: inset 0 2px 5px rgba(0,0,0,0.4); }

.split-wrap { position: absolute; inset: 0; display: none; z-index: 1; }
.split-half { flex: 1; position: relative; overflow: hidden; }
.split-half video { width: 100%; height: 100%; object-fit: cover; display: block; }
.split-half video.mirrored { transform: scaleX(-1); }
.split-half:first-child { border-right: 2px solid var(--border-color); }

.countdown { position: absolute; inset: 0; z-index: 15; display: none; align-items: center; justify-content: center; font-size: 120px; color: #fff; text-shadow: 2px 2px 20px rgba(0,0,0,0.8); background: rgba(0,0,0,0.3); font-family: 'Playfair Display', serif; font-weight: 700;}

.controls { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; flex-wrap: wrap; gap: 12px; }
.controls .left { display: flex; gap: 15px; flex-wrap: wrap; align-items: center; }

.note { font-size: 11px; color: var(--ink-light); margin-top: 20px; line-height: 1.6;}
.mt-10 { margin-top: 10px; }

.phase-eyebrow { color: var(--ink-light); font-size: 12px; font-weight: bold; margin-bottom: 8px; letter-spacing: 2px; }
.phase-title { font-size: 24px; margin: 0 0 25px; color: var(--ink); font-weight: 700; letter-spacing: 1px; }

.layout-grid { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 25px; }
.layout-card { flex: 1; min-width: 160px; border: 1px dashed var(--border-color); border-radius: 4px; padding: 25px 15px; text-align: center; cursor: pointer; background: rgba(255,255,255,0.5); transition: all 0.2s ease; position: relative; overflow: hidden;}
.layout-card:hover { border: 1px solid var(--border-color); background: #fff;}
.layout-card.selected { border: 2px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0px var(--border-light); transform: translate(-1px,-1px);}
.layout-card.disabled { opacity: 0.5; pointer-events: none; filter: grayscale(1); }
.layout-card .prev { display: flex; flex-direction: column; gap: 5px; align-items: center; margin: 0 auto 20px; width: 60px; position: relative; z-index: 1;}
.layout-card .prev .cell { width: 60px; height: 38px; border: 1px solid var(--border-color); background: #ddd; }
.layout-card.selected .prev .cell { background: var(--border-color); }
.layout-card h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink); position: relative; z-index: 1; letter-spacing: 1px;}

.timer-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 13px; font-weight: bold; color: var(--paper); background: var(--border-color); padding: 10px 18px; border-radius: 4px; box-shadow: 2px 2px 0px var(--shadow-color);}
.timer-num { font-size: 18px; font-weight: 700; color: var(--accent-gold); font-family: 'Courier Prime', monospace;}

.gallery-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 25px; }
.gallery-thumb { position: relative; width: 95px; height: 70px; overflow: hidden; border-radius: 2px; border: 2px solid var(--border-light); cursor: pointer; background: #fff; transition: all 0.2s; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); }
.gallery-thumb.picked { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); transform: scale(1.05);}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb .pick-badge { position: absolute; top: 4px; right: 4px; background: var(--ink); color: var(--paper); font-size: 11px; font-weight: bold; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-family: 'Playfair Display', serif;}
.gallery-empty { font-size: 13px; color: var(--ink-light); margin-top: 20px; font-style: italic;}

/* Preview Button Overlay pada Thumbnail */
.preview-btn {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.6); color: #fff;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px; font-size: 12px; cursor: pointer;
  transition: all 0.2s; border: 1px solid rgba(255,255,255,0.4);
}
.preview-btn:hover { background: var(--accent-gold); transform: scale(1.1); border-color: var(--ink);}

/* Modal Pratinjau Foto */
.preview-modal {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 15, 10, 0.95);
  z-index: 99999;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
}
.preview-modal.active {
  display: flex; animation: fadeIn 0.3s ease;
}
.preview-img-container {
  position: relative; max-width: 100%; max-height: 75vh;
}
.preview-img-container img {
  max-width: 100%; max-height: 75vh;
  border: 4px solid var(--paper);
  box-shadow: 5px 5px 25px rgba(0,0,0,0.8);
  object-fit: contain;
  background: #000;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.strip-preview-wrap { display: flex; gap: 35px; flex-wrap: wrap; align-items: flex-start; margin-top: 25px; }
.strip-canvas-stage { position: relative; max-width: 320px; width: 100%; }
#stripCanvas { display: block; max-width: 320px; width: 100%; border-radius: 2px; box-shadow: 5px 5px 15px rgba(0,0,0,0.3); border: 1px solid var(--border-light); background: #fff; }
.strip-actions { display: flex; flex-direction: column; gap: 16px; min-width: 220px; }

/* --- STIKER --- */
.sticker-layer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
.sticker-instance {
  position: absolute; top: 0; left: 0;
  width: 90px; height: 90px;
  touch-action: none; cursor: grab;
  user-select: none; -webkit-user-select: none;
}
.sticker-instance.selected { outline: 1px dashed var(--accent, #4a3b2c); outline-offset: 4px; }
.sticker-instance img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block; }
.sticker-delete-btn {
  position: absolute; top: -10px; right: -10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--alert, #a33); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 11px; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  touch-action: none; cursor: pointer;
}
.sticker-instance.selected .sticker-delete-btn { display: flex; }
.sticker-resize-handle {
  position: absolute; bottom: -10px; right: -10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent, #4a3b2c);
  display: none; touch-action: none; cursor: nwse-resize;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.sticker-instance.selected .sticker-resize-handle { display: block; }

.sticker-panel {
  margin-top: 18px; width: 100%; max-width: 320px;
  border: 1px dashed var(--border-color); border-radius: 4px; padding: 12px;
  background: rgba(0,0,0,0.03);
}
.sticker-panel-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px;
}
.sticker-panel-grid .sticker-thumb {
  width: 56px; height: 56px; border: 1px solid var(--border-light); border-radius: 4px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 4px; box-sizing: border-box;
  transition: transform 0.1s ease;
}
.sticker-panel-grid .sticker-thumb:hover { transform: scale(1.08); border-color: var(--accent, #4a3b2c); }
.sticker-panel-grid .sticker-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* --- TOMBOL MIC MENGAMBANG --- */
.mic-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 500;
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  box-shadow: 3px 3px 0px var(--shadow-color);
  transition: transform 0.12s ease, background 0.15s ease;
}
.mic-fab:active { transform: scale(0.92); }
.mic-fab.off { background: var(--paper, #f4ecd8); color: var(--ink, #2b2b2b); }
.mic-fab.on { background: #3d7a4f; color: #fff; border-color: #2c5a3a; }
.mic-fab.on::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(61,122,79,0.5); animation: micPulse 1.6s ease-out infinite;
}
@keyframes micPulse { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
.mic-fab-label {
  position: fixed; right: 18px; bottom: 78px; z-index: 500;
  font-family: 'Courier Prime', monospace; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,0.75); color: #fff; padding: 3px 8px; border-radius: 3px;
  letter-spacing: 0.5px; pointer-events: none;
}
@media (max-width: 480px){
  .mic-fab { right: 14px; bottom: 14px; width: 50px; height: 50px; font-size: 18px; }
  .mic-fab-label { right: 14px; bottom: 70px; }
}
.code-box { background: rgba(0,0,0,0.05); padding: 5px 10px; border-radius: 4px; display:inline-block; font-family:'Courier Prime', monospace; border: 1px dashed var(--border-color);}

/* --- SWEETALERT VINTAGE THEME --- */
.vintage-swal-popup {
  background: var(--paper) !important;
  border: 2px solid var(--border-color) !important;
  border-radius: 6px !important;
  box-shadow: 6px 6px 0px var(--shadow-color) !important;
  font-family: 'Courier Prime', monospace !important;
  color: var(--ink) !important;
}

.vintage-swal-title {
  font-family: 'Playfair Display', serif !important;
  color: var(--ink) !important;
  font-weight: 700 !important;
}

.vintage-swal-popup .swal2-icon.swal2-warning { border-color: var(--accent-gold); color: var(--accent-gold); }
.vintage-swal-popup .swal2-icon.swal2-error { border-color: var(--alert); color: var(--alert); }
.vintage-swal-popup .swal2-icon.swal2-info { border-color: var(--ink-light); color: var(--ink-light); }