/* ============================================================
   GALERI PIXEL — STYLE
   Palet gelap ala galeri + font pixel retro.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #0a0a0c;
  overflow: hidden;
  font-family: 'VT323', monospace;
  color: #f4f1e8;
  -webkit-tap-highlight-color: transparent;
}

/* Overlay retro: garis scanline halus + vignette gelap di pinggir */
#crt {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, rgba(0,0,0,0) 1px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* Kanvas: full-window, aset detail (smoothing di-handle di JS) */
#game {
  display: block;
  background: #000;
  position: absolute;
  inset: 0;
}

/* ---------- Layar umum ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 40%, #1b1826 0%, #0b0a0f 80%);
  z-index: 20;
  padding: 24px;
  text-align: center;
}
.hidden { display: none !important; }

#title-name {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 4vw, 34px);
  color: #f2cc8f;
  text-shadow: 3px 3px 0 #b5651d, 6px 6px 0 rgba(0,0,0,.4);
  letter-spacing: 2px;
}
#title-sub { font-size: clamp(16px, 2.6vw, 22px); color: #c9c2b4; opacity: .85; }

.hint { font-size: 18px; opacity: .6; }

/* ---------- Grid karakter ---------- */
#char-grid {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-top: 8px;
}
.char-card {
  width: 92px; height: 130px;
  background: #16131f;
  border: 3px solid #2e2a3d;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer;
  transition: transform .08s, border-color .08s, background .08s;
}
.char-card:hover { transform: translateY(-4px); border-color: #6d5a8a; }
.char-card.selected { border-color: #f2cc8f; background: #221d30; transform: translateY(-4px); }
.char-card canvas { image-rendering: pixelated; }
.char-card .char-preview { height: 104px; width: auto; max-width: 90px; object-fit: contain; image-rendering: auto; }
.char-card span { font-size: 18px; letter-spacing: 1px; }

/* ---------- Tombol pixel ---------- */
.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 14px 20px;
  color: #0b0a0f;
  background: #f2cc8f;
  border: none;
  border-bottom: 4px solid #b5651d;
  cursor: pointer;
  letter-spacing: 1px;
}
.pixel-btn:hover:not(:disabled) { background: #ffd98a; }
.pixel-btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.pixel-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Art viewer ---------- */
#art-viewer {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(6,5,9,.92);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.art-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  max-width: 92vw;
}
#art-canvas {
  width: min(74vw, 420px); height: min(50vh, 300px);
  max-width: 90vw; max-height: 74vh;
  border: 8px solid #2a2320;
  box-shadow: 0 0 0 3px #6b5a4a, 12px 12px 0 rgba(0,0,0,.5);
  image-rendering: auto;
}
#art-info { text-align: center; }
#art-title { font-family: 'Press Start 2P', monospace; font-size: 14px; color: #f2cc8f; margin-bottom: 10px; line-height: 1.5; }
#art-meta { font-size: 18px; color: #c9c2b4; margin-bottom: 8px; }
#art-desc { font-size: 18px; color: #a49e90; line-height: 1.3; }

/* ---------- Kontrol sentuh (mobile) ---------- */
#touch-controls {
  position: absolute; inset: 0; z-index: 15;
  pointer-events: none;
}
.tc-btn {
  position: absolute; bottom: 22px;
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 3px solid rgba(244,241,232,.4);
  background: rgba(20,18,30,.5);
  color: #f4f1e8; font-size: 26px;
  pointer-events: auto;
  user-select: none;
}
#tc-left { left: 20px; }
#tc-right { left: 100px; }
.tc-action { right: 24px; background: rgba(242,204,143,.25); border-color: #f2cc8f; }

/* ---------- Tombol kembali ke editor ---------- */
#back-editor {
  position: absolute; top: 14px; right: 16px; z-index: 12;
  font-family: 'VT323', monospace; font-size: 18px; letter-spacing: 1px;
  padding: 8px 16px; cursor: pointer;
  color: #0b0a0f; background: #f2cc8f; border: none; border-bottom: 4px solid #b5651d;
}
#back-editor:hover { background: #ffd98a; }
#back-editor:active { transform: translateY(2px); border-bottom-width: 2px; }

/* ---------- Help bar ---------- */
#help-bar {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 16px; color: #7a7488; z-index: 10;
  white-space: nowrap; opacity: .8;
}
@media (max-width: 720px) { #help-bar { display: none; } }

/* ---------- Admin link ---------- */
.admin-link {
  position: absolute; bottom: 14px; right: 16px;
  background: none; border: 1px solid #2e2a3d; color: #6a6478;
  font-family: 'VT323', monospace; font-size: 18px; padding: 4px 12px; cursor: pointer;
}
.admin-link:hover { color: #f2cc8f; border-color: #6d5a8a; }

/* ---------- Login modal ---------- */
#admin-login {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(6,5,9,.9); display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #16131f; border: 3px solid #2e2a3d; padding: 28px 26px;
  display: flex; flex-direction: column; gap: 12px; width: 320px; text-align: center;
}
.login-card h2 { font-family: 'Press Start 2P', monospace; font-size: 14px; color: #f2cc8f; }
.login-sub { font-size: 17px; color: #a49e90; }
#admin-email, #admin-pass, #admin-new-pass, #admin-new-pass2 {
  font-family: 'VT323', monospace; font-size: 20px; padding: 10px 12px;
  background: #0c0a12; border: 2px solid #2e2a3d; color: #f4f1e8;
}
#admin-email:focus, #admin-pass:focus, #admin-new-pass:focus, #admin-new-pass2:focus { outline: none; border-color: #6d5a8a; }
#login-reset-fields { display: flex; flex-direction: column; gap: 12px; }
#login-reset-fields.hidden { display: none; }
.login-err { color: #d97575; font-size: 17px; min-height: 20px; }
.login-actions { display: flex; gap: 10px; justify-content: center; }
.login-reset-link {
  align-self: center; width: fit-content; background: none; border: 0; color: #f2cc8f;
  font-family: 'VT323', monospace; font-size: 18px; cursor: pointer; padding: 0;
}
.login-reset-link:hover { color: #fff0c7; text-decoration: underline; }
.pixel-btn.ghost { background: #2a2536; color: #d8d2e0; border-bottom-color: #17141f; }
.pixel-btn.sm { font-size: 10px; padding: 10px 12px; }

/* ---------- Editor panel ---------- */
#editor { position: absolute; inset: 0; z-index: 35; pointer-events: none; }
.ed-panel {
  pointer-events: auto;
  position: absolute; top: 0; right: 0; width: 320px; height: 100%;
  background: #14121c; border-left: 3px solid #2e2a3d;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  overflow-y: auto; font-size: 17px;
}
.ed-head { display: flex; align-items: center; justify-content: space-between; }
.ed-head b { font-family: 'Press Start 2P', monospace; font-size: 11px; color: #f2cc8f; }
.ed-flashmsg { font-size: 14px; color: #7ec98a; opacity: 0; transition: opacity .3s; max-width: 130px; text-align: right; line-height: 1.1; }
.ed-sec { border-top: 1px solid #241f31; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ed-grow { flex: 1; }
.ed-lbl { font-size: 15px; color: #8a8398; text-transform: uppercase; letter-spacing: 1px; }
.ed-row { display: flex; gap: 6px; align-items: center; }
.ed-row label { width: 74px; color: #a49e90; font-size: 16px; }
.ed-row input, .ed-row select, .ed-row textarea {
  flex: 1; font-family: 'VT323', monospace; font-size: 17px;
  background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 5px 7px;
}
.ed-row input[type="range"] { padding: 0; }
.ed-row input[type="color"] { padding: 0; height: 28px; }
.ed-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-palette button, #ed-addfloor, #ed-delfloor {
  font-family: 'VT323', monospace; font-size: 16px; cursor: pointer;
  background: #221d30; border: 1px solid #3a3348; color: #e8e2f0; padding: 6px 10px;
}
.ed-palette button:hover { background: #2f2842; border-color: #6d5a8a; }
.ed-upload-btn {
  font-family: 'VT323', monospace; font-size: 16px; cursor: pointer;
  background: #221d30; border: 1px solid #3a3348; color: #f2cc8f; padding: 7px 10px;
  text-align: left;
}
.ed-upload-btn:hover { background: #2f2842; border-color: #6d5a8a; }
#ed-addfloor, #ed-delfloor { padding: 5px 9px; }
#ed-floor { flex: 1; font-family: 'VT323', monospace; font-size: 16px; background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 5px; }
#ed-floorname { font-family: 'VT323', monospace; font-size: 17px; background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 6px 8px; }
.ed-sec > input {
  width: 100%; font-family: 'VT323', monospace; font-size: 17px;
  background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 6px 8px;
}
.ed-sec > input:focus { outline: none; border-color: #6d5a8a; }
.ed-hint.ok { color: #7ec98a; }
.ed-hint.err { color: #d97575; }
/* thumbnail palet (scroll samping) */
.ed-thumbs { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
.ed-thumbs::-webkit-scrollbar { height: 7px; }
.ed-thumbs::-webkit-scrollbar-thumb { background: #3a3348; border-radius: 4px; }
.ed-thumb { flex: 0 0 auto; width: 88px; background: #221d30; border: 1px solid #3a3348; cursor: pointer; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ed-thumb img { width: 74px; height: 70px; object-fit: contain; background: #e8e0cf; border-radius: 3px; padding: 2px; }
.ed-thumb span { font-size: 14px; color: #d4cde0; white-space: nowrap; }
.ed-thumb:hover { border-color: #6d5a8a; background: #2f2842; }
.ed-thumb.active { border-color: #f2cc8f; background: #2a2438; }
#ed-rooms .ed-thumb { width: 138px; }
#ed-rooms .ed-thumb img { width: 126px; height: 46px; object-fit: cover; }
.ed-num { width: 66px; flex: 0 0 auto; font-family: 'VT323', monospace; font-size: 17px; background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 5px 6px; }
.ed-glyph { width: 74px; height: 70px; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #f2cc8f; background: linear-gradient(#2b2436, #171320); border-radius: 3px; }
#ed-floorwidth { flex: 1; font-family: 'VT323', monospace; font-size: 17px; background: #0c0a12; border: 1px solid #2e2a3d; color: #f4f1e8; padding: 5px 7px; }
.ed-unit { color: #7a7488; font-size: 15px; }

.ed-hint, .ed-note { font-size: 15px; color: #7a7488; line-height: 1.3; }
.ed-note { color: #7ec98a; margin-top: 2px; }
.ed-del { margin-top: 8px; background: #3a2020; border: 1px solid #6b3030; color: #e6b0b0; font-family: 'VT323', monospace; font-size: 16px; padding: 7px; cursor: pointer; width: 100%; }
.ed-del:hover { background: #4a2626; }
.ed-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border-top: 1px solid #241f31; padding-top: 10px; }
.ed-canvashint {
  pointer-events: none; position: absolute; bottom: 10px; left: 16px;
  font-size: 16px; color: #7a7488; background: rgba(10,8,14,.5); padding: 4px 10px;
}
