/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html, body { height: 100%; width: 100%; overflow: hidden; background: #f8fafc; color: #1e293b; }

/* Header Responsif HP */
header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  height: auto; min-height: 72px; padding: 8px;
  background: linear-gradient(90deg, #3b82f6, #2563eb); color: white;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: bold; font-size: 18px; }
.title { font-size: 16px; }

/* Tab Navigasi untuk Layar HP Kecil */
.tabs { display: inline-flex; flex: 1; gap: 4px; justify-content: center; order: 3; width: 100%; max-width: 480px; }
.tab-btn {
  flex: 1; padding: 8px 10px; border: none; border-radius: 8px;
  background: rgba(255,255,255,0.15); color: white; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s ease;
}
.tab-btn:hover { background: rgba(255,255,255,0.25); }
.tab-btn.active { background: white; color: #2563eb; }

/* Tombol Aksi */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 6px 12px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: bold; background: rgba(255,255,255,0.9); color: #1e293b;
  transition: transform .06s ease, filter .1s ease;
}
.btn.green { background: #10b981; color: white; }
.btn.red { background: #ef4444; color: white; }
.btn:hover { filter: brightness(0.9); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

/* Banner Error / Peringatan */
.error-banner {
  position: fixed; top: calc(72px + 12px); left: 50%; transform: translateX(-50%);
  background: #fee2e2; color: #991b1b; border: 2px solid #dc2626; border-radius: 10px;
  padding: 10px 16px; display: flex; align-items: center; gap: 8px; z-index: 1000;
  font-size: 13px; font-weight: 600; max-width: 90vw; white-space: nowrap;
}
.error-banner.hidden { display: none; }
#btn-close-error { background: #dc2626; color: white; border: none; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-weight: bold; }

/* Container Aplikasi Utama (Responsif) */
#app-container { position: relative; height: calc(100% - 72px); width: 100%; overflow: hidden; }
.panel { position: absolute; inset: 0; display: none; overflow: hidden; }
.panel.active { display: block; }

/* Panel Balok (Workspace Blockly) */
#blocklyDiv { height: 100%; width: 100%; }

/* Panel Game (Canvas) */
#panel-game { background: #f0f4f8; }
.canvas-wrapper { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 8px; }
.game-hud {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; background: rgba(255,255,255,0.95);
  padding: 6px 12px; border-radius: 10px; font-weight: bold; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 10;
}
#gameCanvas {
  width: 100%; max-width: 360px; aspect-ratio: 1/1; background: radial-gradient(circle at center, #fffaf0, #e0e7ff);
  border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); border: none; touch-action: none;
}

/* D-Pad Sentuh untuk Android */
.mobile-dpad {
  display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 8px; margin-top: 16px;
}
.drow { grid-column: 2; display: flex; gap: 8px; align-self: center; }
.dbtn {
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: linear-gradient(180deg, #60a5fa, #3b82f6); color: white;
  font-size: 20px; font-weight: bold; box-shadow: 0 2px 6px rgba(59,130,246,0.35);
  cursor: pointer; user-select: none; touch-action: manipulation;
}
.dbtn:active { transform: scale(0.95); background: linear-gradient(180deg, #3b82f6, #2563eb); }

/* Panel Kode JS (Penjelasan) */
.code-container {
  height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; padding: 16px; overflow: auto;
  background: #111827; color: #e5e7eb; border-radius: 12px; margin: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.code-info { text-align: left; width: 100%; margin-bottom: 12px; }
.code-info h3 { font-size: 16px; color: #34d399; margin-bottom: 6px; }
.code-info p { font-size: 13px; color: #9ca3af; }
#js-code {
  width: 100%; max-width: 540px; height: 100%; overflow: auto; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  background: transparent; color: #f3f4f6;
}

/* Responsive Breakpoints */
@media (min-width: 768px) {
  #app-container { display: flex; }
  #panel-blocks, #panel-game, #panel-code { position: static; display: none; }
  #panel-blocks.active, #panel-game.active, #panel-code.active { display: block; }
  #panel-blocks.active { flex: 1; }
  #panel-game.active, #panel-code.active { width: 400px; background: #f8fafc; border-left: 2px solid #cbd5e1; padding: 12px; }
  #gameCanvas { border-radius: 12px; }
  .tabs { display: none; } /* Sembunyikan tab di desktop */
}

/* Pesan Help Ramah Anak (Pop Up Ringan) */
.help-tip {
  position: fixed; bottom: 12px; right: 12px; background: #fef3c7; color: #92400e;
  border: 2px solid #f59e0b; border-radius: 10px; padding: 10px 14px; font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); max-width: 85%; z-index: 1001;
}
.help-tip.hidden { display: none; }