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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #111827;
  color: #e5e7eb;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header / Controls ── */
#header {
  background: #1f2937;
  border-bottom: 1px solid #374151;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
#header h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #86efac;
  white-space: nowrap;
}
#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ctrl-group label {
  font-size: 0.75rem;
  color: #9ca3af;
  white-space: nowrap;
}
select, input[type="text"] {
  background: #111827;
  border: 1px solid #374151;
  color: #f9fafb;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: border-color 0.15s;
}
select:focus, input[type="text"]:focus {
  outline: none;
  border-color: #60a5fa;
}
input[type="text"] {
  font-family: monospace;
  font-size: 1rem;
  width: 78px;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-ghost   { background: #374151; color: #d1d5db; }
#status {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 5px;
  background: transparent;
  min-width: 160px;
}
#status.ok    { color: #4ade80; background: rgba(74,222,128,0.08); }
#status.err   { color: #f87171; background: rgba(248,113,113,0.08); }
#status.warn  { color: #fb923c; background: rgba(251,146,60,0.08); }

/* ── Viewport ── */
#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#viewport canvas { display: block; }

/* ── Damage info card ── */
#damage-card {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(17,24,39,0.88);
  backdrop-filter: blur(8px);
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.78rem;
  min-width: 210px;
  display: none;
}
#damage-card h3 {
  font-size: 0.82rem;
  color: #f87171;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#damage-card table { width: 100%; border-collapse: collapse; }
#damage-card td { padding: 3px 0; vertical-align: top; }
#damage-card td:first-child { color: #6b7280; padding-right: 10px; white-space: nowrap; }
#damage-card td:last-child  { color: #f3f4f6; font-weight: 500; }

/* ── Legend ── */
#legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(17,24,39,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.73rem;
  line-height: 1.9;
}
#legend h4 { color: #86efac; font-size: 0.74rem; margin-bottom: 4px; }
.leg { display: flex; align-items: center; gap: 7px; }
.leg-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ── Code guide ── */
#guide {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(17,24,39,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.72rem;
  line-height: 1.8;
  max-width: 230px;
}
#guide h4 { color: #86efac; font-size: 0.74rem; margin-bottom: 4px; }
.guide-row { display: grid; grid-template-columns: 18px 1fr; gap: 4px; }
.guide-code { font-family: monospace; color: #93c5fd; }

/* ── Auth user info (injected by auth.js) ── */
#auth-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
#auth-username {
  font-size: 0.78rem;
  color: #9ca3af;
  white-space: nowrap;
}
