* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0f14; font-family: 'Sarabun', 'Tahoma', sans-serif; color: #e9eef5; }
canvas { display: block; }

#app { position: relative; width: 100%; height: 100%; }
#scene { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* Top bar */
#topbar {
  position: absolute; top: 18px; left: 18px;
  display: flex; gap: 18px; align-items: center;
  padding: 14px 18px;
  background: rgba(15, 23, 33, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  pointer-events: auto;
  z-index: 10;
  max-width: calc(100% - 320px);
}
#topbar .brand { display: flex; gap: 14px; align-items: center; }
.bts-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #00a651, #00753a);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18), 0 6px 18px rgba(0,166,81,0.3);
}
.bts-logo-inner {
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.brand-text .th { font-family: 'Prompt', sans-serif; font-weight: 700; font-size: 22px; line-height: 1.1; }
.brand-text .en { font-size: 13px; color: #a8b6c8; margin-top: 2px; }
.brand-text .en .code {
  display: inline-block; margin-left: 6px;
  background: #00a651; color: white;
  padding: 1px 8px; border-radius: 4px;
  font-weight: 700; font-size: 12px;
}
.brand-text .line { font-size: 12px; color: #6b7d92; margin-top: 2px; }

#topbar .meta {
  display: flex; flex-direction: column; gap: 4px;
  padding-left: 18px; border-left: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}
.kv span { color: #6b7d92; margin-right: 6px; }
.kv b { color: #d8e0eb; font-weight: 600; }

/* Sidebar */
#sidebar {
  position: absolute; top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 12px;
  width: 280px;
  z-index: 10;
  pointer-events: auto;
}
.panel {
  background: rgba(15, 23, 33, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.panel h3 {
  font-family: 'Prompt', sans-serif;
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: #6b7d92;
  margin-bottom: 10px;
}
.btn-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.btn-grid button {
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e9eef5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-grid button:hover {
  background: #00a651;
  border-color: #00a651;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,166,81,0.3);
}
.switch {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 6px 0;
  cursor: pointer; user-select: none;
}
.switch input { 
  appearance: none;
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  position: relative; cursor: pointer;
  transition: background 0.2s;
}
.switch input::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
}
.switch input:checked {
  background: #00a651;
}
.switch input:checked::after {
  left: 18px;
}

.panel.small ul { list-style: none; padding: 0; }
.panel.small li {
  font-size: 12px; color: #a8b6c8;
  padding: 4px 0;
}
kbd {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', monospace;
  font-size: 11px;
  color: #e9eef5;
  margin-right: 4px;
}

/* Loading */
#loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: #0b0f14;
  z-index: 100;
  transition: opacity 0.6s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: #00a651;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  color: #a8b6c8;
}

@media (max-width: 800px) {
  #topbar { max-width: calc(100% - 36px); flex-wrap: wrap; }
  #topbar .meta { display: none; }
  #sidebar { width: calc(100% - 36px); top: auto; bottom: 18px; right: 18px; }
  .btn-grid { grid-template-columns: repeat(3, 1fr); }
}
