:root {
  --bg: #101c16;
  --panel: #16261f;
  --text: #e0f8cf;
  --muted: #86c06c;
  --accent: #306850;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top, #1d3329, var(--bg));
  color: var(--text);
}

.app-header { padding: 1rem; text-align: center; }
.app-header h1 { margin: 0; }
.app-header p { margin-top: .25rem; color: var(--muted); }

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  color: var(--muted);
}

.lang-switcher select {
  width: auto;
  background: #1e352b;
  color: var(--text);
  border: 1px solid #5f8b75;
  border-radius: 6px;
  padding: .25rem .4rem;
}

.tab-nav {
  display: flex;
  gap: .5rem;
  justify-content: center;
  padding: 0 1rem 1rem;
}
.tab-btn {
  border: 1px solid #5f8b75;
  background: #1e352b;
  color: var(--text);
  border-radius: 999px;
  padding: .5rem 1rem;
}
.tab-btn.active { background: #3d6f57; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: color-mix(in srgb, var(--panel), black 10%);
  border: 1px solid #325845;
  border-radius: 12px;
  padding: 1rem;
}

.drop-zone {
  border: 2px dashed #4e7d64;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: .75rem;
}
.drop-zone.drag-over { border-color: #e0f8cf; background: #223b2f; }

.toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}

button {
  border: 1px solid #5f8b75;
  background: #29463a;
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .75rem;
}
button.active { background: #3d6f57; }
button:hover { filter: brightness(1.1); }

#previewCanvas,
#validatePreviewCanvas,
#validateOverlayCanvas {
  width: 100%;
  max-height: 70vh;
  border: 1px solid #3b5f4d;
  border-radius: 8px;
  background: #071821;
  image-rendering: pixelated;
}

.preview-stack {
  position: relative;
}
#validateOverlayCanvas {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

details { margin-bottom: .75rem; }
summary { cursor: pointer; font-weight: 700; }
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .6rem;
  margin-top: .5rem;
}
label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
input, select { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-top: .75rem; }
#statusText { margin-left: auto; font-size: .85rem; color: var(--muted); }

.result-card {
  margin-top: .75rem;
  border: 1px solid #446b58;
  border-radius: 10px;
  padding: .75rem;
  background: #183024;
}

.tile-grid {
  margin-top: .5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: .5rem;
}
.tile-item {
  border: 1px solid #4b7461;
  border-radius: 8px;
  padding: .35rem;
  text-align: center;
  cursor: pointer;
  background: #1b3328;
}
.tile-item.active {
  outline: 2px solid #e0f8cf;
}
.tile-item canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  border: 1px solid #365948;
}
.tile-item small { display: block; margin-top: .25rem; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
