:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f8fafc;
  --panel2: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans",
    "Apple Color Emoji", "Segoe UI Emoji";
  background: #f8fafc;
  color: var(--text);
}

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.title {
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: end;
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field span {
  opacity: 0.9;
}

.field.grow {
  flex: 1;
  min-width: 260px;
}

select,
input {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

button:hover {
  border-color: var(--accent);
  background: #f1f5f9;
}

.main {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.hint {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 12px;
}

.muted {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

#gl {
  background: #000;
}

#gl, #overlay {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-icon, .fire-icon {
  background: transparent !important;
}

.map-wrapper {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  overflow: hidden;
  align-self: start;
  height: fit-content;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  background: transparent;
  border: 0;
}

.hud {
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
  z-index: 6;
  white-space: pre;
}

.touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0; /* Pin to the very bottom of map-wrapper */
  display: flex;
  justify-content: space-between;
  padding: 0 15px 15px 15px; /* Add bottom padding instead of bottom offset */
  pointer-events: none;
  z-index: 10;
}

.touch-left,
.touch-right {
  display: flex;
  gap: 10px;
  pointer-events: auto; /* Buttons DO catch clicks */
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.touch-btn:active {
  background: rgba(255, 255, 255, 0.6);
}

.touch-icon {
  width: 48px;
  height: 48px;
  opacity: 0.85;
}

.fire-btn {
  width: 88px;
}

.fire-icon {
  width: 52px;
  height: 40px;
}

.touch-jump {
  width: 88px;
}

.log {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  overflow: auto;
  max-height: 180px;
}

.lang-switcher {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 100;
}

.lang-switcher a {
  text-decoration: none;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  transition: all 0.2s;
}

.lang-switcher a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--panel2);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
    gap: 10px;
  }

  .controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .field {
    min-width: calc(50% - 4px);
  }

  .field.grow {
    min-width: 100%;
  }

  .hint {
    font-size: 11px;
  }

  .title {
    font-size: 14px;
  }
}
