:root {
--bg: #0b1020;
--panel: #11172a;
--muted: #2a3350;
--text: #e8eefc;
--text-dim: #b9c3dd;
--accent: #7aa2ff;
--accent-2: #55d6be;
--shadow: 0 8px 24px rgba(0,0,0,.35);
}


* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin: 0; background: var(--bg); color: var(--text); overflow: hidden;
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #0d152a;
  image-rendering: pixelated;
}

/* Floating action buttons */
#fab-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 1000;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--muted);
  box-shadow: var(--shadow);
  font-size: 1.5em;
  text-align: center;
  transition: transform 0.2s, opacity 0.2s;
}

.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Dialog menus */
.overlay::backdrop { background: rgba(0, 0, 0, 0.6); }
.overlay { border: none; padding: 0; background: transparent; }
.overlay > div {
  background: var(--panel);
  border: 1px solid var(--muted);
  border-radius: 16px;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 16px;
  max-width: 90vw;
}
.overlay.small > div { width: min(320px, 90vw); }

.palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.palette button {
  padding: 8px 6px;
  background: #141b33;
  border: 1px solid var(--muted);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.palette button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-col button {
  padding: 8px;
  font-size: 15px;
}

.card {
background: color-mix(in oklab, var(--panel) 85%, black 15%);
border: 1px solid var(--muted);
border-radius: 16px;
box-shadow: var(--shadow);
}

#toolbar {
  position: fixed;
  left: 50%;
  bottom: env(safe-area-inset-bottom, 12px);
  transform: translateX(-50%);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: color-mix(in oklab, var(--panel) 85%, black 10%);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 96vw;
  overflow: hidden;
}

.tool-row {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.tool-row::-webkit-scrollbar { display: none; }

.tool {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 12px;
  font-size: 14px;
  background: #141b33;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.controls-row button, .controls-row input[type="range"] {
  flex: 1 1 22%;
  min-width: 60px;
}


button, .control input[type="range"] {
-webkit-tap-highlight-color: transparent;
}
button {
appearance: none; border: 1px solid var(--muted); background: #141b33; color: var(--text);
padding: 8px 10px; border-radius: 12px; cursor: pointer; font-weight: 600;
}
button:hover { border-color: var(--accent); }
button.active { outline: 2px solid var(--accent); }


.control { display: inline-flex; gap: 8px; align-items: center; color: var(--text-dim); font-size: 14px; }
input[type="range"] { accent-color: var(--accent-2); }


/* Dialog */
dialog { border: none; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog article { width: min(520px, 92vw); padding: 16px; }
dialog article header { display: flex; gap: 12px; align-items: center; }
dialog article header img { width: 48px; height: 48px; border-radius: 10px; }
dialog article footer { display: flex; justify-content: space-between; margin-top: 12px; }


@media (max-width: 720px) {
.tool-row { grid-template-columns: repeat(5, 1fr); }
.controls-row { grid-template-columns: repeat(5, 1fr); }
}

.floating-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.5em;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--muted);
  box-shadow: var(--shadow);
  z-index: 50;
}
/* Startup splash overlay */
.intro-overlay {
  position: fixed;
  inset: 0;
  background: #0d152a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  /*animation: fadeOut 1s ease forwards;*/
  animation-delay: 2.8s; /* auto fade after ~3 s */
}

.intro-content {
  text-align: center;
  color: #e8eefc;
  animation: fadeIn 0.8s ease;
}

.intro-logo {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  margin-bottom: 1rem;
  animation: pulse 2s infinite ease-in-out;
}

.intro-title {
  font-size: 1.8rem;
  margin: 0;
}

.intro-sub {
  font-size: 1rem;
  color: #b9c3dd;
  opacity: 0.7;
  margin-top: .5rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.05); }
}
@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; }
}
