:root {
  --bg: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --dim: #64748b;
  --primary: #8b5cf6;
  --secondary: #4f46e5;
  --green: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --warn: #b45309;
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #475569;
  --dim: #94a3b8;
  --warn: #b45309;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.header-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}
.btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.btn-add {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
}
.btn-add:hover {
  filter: brightness(1.1);
}
select.btn {
  appearance: none;
  padding-right: 1.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}
.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pixi-stage {
  width: 100%;
  height: 100%;
}
.hint {
  position: absolute;
  bottom: 0.7rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  white-space: nowrap;
  z-index: 4;
}
.sidebar {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
}
.panel-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 0.28rem 0;
  color: var(--muted);
}
.hud-row b {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 0.92em;
}
.album {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.album-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  opacity: 0.45;
  transition: all 0.2s ease;
}
.album-item.captured {
  opacity: 1;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.4);
}
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ctrl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.ctrl {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  font-size: 1.05rem;
  padding: 0.55rem 0;
  cursor: pointer;
  transition: all 0.12s ease;
}
.ctrl:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.12);
}
.ctrl-main {
  background: rgba(139, 92, 246, 0.16);
}
.ctrl-shot {
  font-size: 1rem;
}
.log-panel {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}
#log {
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  max-height: 260px;
}
#log .log-warn {
  color: var(--warn);
  font-weight: 600;
}
#log .log-good {
  color: var(--green);
  font-weight: 600;
}
#log .log-bad {
  color: var(--rose);
  font-weight: 600;
}

/* Guide modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.6rem 1.8rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.9rem;
}
.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
.modal-close:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
}
.guide-section {
  margin-bottom: 1.1rem;
}
.guide-section h3 {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  margin-bottom: 0.45rem;
  color: var(--primary);
}
.guide-section p,
.guide-section li {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.guide-section ul {
  padding-left: 1.1rem;
}
.guide-section code {
  font-family: var(--font-mono);
  font-size: 0.78em;
  background: rgba(139, 92, 246, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}
.guide-section pre {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  overflow-x: auto;
  margin: 0.4rem 0;
}
.guide-section pre code {
  background: none;
  padding: 0;
}
.guide-note {
  font-size: 0.76rem;
  font-style: italic;
  opacity: 0.85;
}

/* In-canvas game-over / victory notification (DOM card over the board) */
.game-banner {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--bg-card);
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1.1rem;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.35);
  pointer-events: none;
}
.game-banner.hidden {
  display: none;
}
.game-banner-emoji {
  font-size: 1.7rem;
  line-height: 1;
}
.game-banner-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.15;
}
.game-banner-sub {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 0.12rem;
}
.game-banner.fail {
  border-color: #b91c1c;
}
.game-banner.fail .game-banner-title {
  color: #b91c1c;
}
.game-banner.win {
  border-color: #059669;
}
.game-banner.win .game-banner-title {
  color: #059669;
}
[data-theme="dark"] .game-banner.fail {
  border-color: #f87171;
}
[data-theme="dark"] .game-banner.fail .game-banner-title {
  color: #f87171;
}
[data-theme="dark"] .game-banner.win {
  border-color: #34d399;
}
[data-theme="dark"] .game-banner.win .game-banner-title {
  color: #34d399;
}

.last-key {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
}
.last-key b {
  font-family: var(--font-mono);
  color: var(--primary);
  font-size: 0.72rem;
  text-align: right;
}
.ctrl.key-pressed {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.28);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}
.btn.key-pressed {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35);
}

/* Sidebar Mission-panel result state */
.hud-result {
  margin-top: 0.55rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.55rem;
}
.hud-result.hidden {
  display: none;
}
.hud-result-inner {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
}
.hud-result-inner b {
  font-family: var(--font-heading);
  font-size: 0.85rem;
}
.hud-result-inner.win {
  background: rgba(5, 150, 105, 0.14);
  border: 1px solid rgba(5, 150, 105, 0.45);
  color: var(--green);
}
.hud-result-inner.fail {
  background: rgba(185, 28, 28, 0.12);
  border: 1px solid rgba(185, 28, 28, 0.45);
  color: var(--rose);
}
.hud-result-inner span {
  color: var(--text);
  font-weight: 500;
}

.guide-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
}
.guide-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.guide-tab.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 18%, var(--panel-2));
}
.guide-panel h3 {
  margin-top: 18px;
}
.guide-panel p {
  line-height: 1.6;
}
.guide-panel .math {
  text-align: center;
  padding: 8px 0;
}

/* wisesloth.app-style scrollbars */
::-webkit-scrollbar {
  width: 20px;
  height: 20px;
}
::-webkit-scrollbar-track {
  background-color: transparent;
}
::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
::-webkit-scrollbar-thumb {
  background-color: #d6dee1;
  border-radius: 20px;
  border: 6px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #a8bbbf;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #d6dee1 transparent;
}

/* unified theme button + GitHub link (navbar right) */
.theme-btn,
.gh-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1;
}
.gh-link svg,
.theme-btn svg {
  flex-shrink: 0;
}
.theme-btn .ic-moon {
  display: none;
}
[data-theme="dark"] .theme-btn .ic-sun {
  display: none;
}
[data-theme="dark"] .theme-btn .ic-moon {
  display: block;
}
